AgriCraft

AgriCraft

30M Downloads

[Enhancement] Allow Blood Magic Rituals to Harvest Crops

WayofTime opened this issue ยท 4 comments

commented

Hello there, hope you are having a wonderful day!

I'm the author of the mod Blood Magic and got the chance to play with your mod through the modpack "Regrowth," and I must say I like the mechanics of the crops. Unfortunately, I noticed that there isn't an API that I am able to hook into myself in order to harvest the crops with my own harvesting methods (it's a ritual called "Reap of the Harvest Moon", which is meant to harvest the plants and replant them without destroying the seeds, dropping the items onto the ground). I would thus like to suggest an enhancement that will allow this compatibility.

This method should only need the use of my API to register a Harvest Handler to handle the crop block, and should be simple enough. The class below is the HarvestRegistry where you register the HarvestHandler, which does the brunt of the work. The one below that is the interface needed to be implemented.

https://github.com/WayofTime/BloodMagic/blob/master/src/main/java/WayofTime/alchemicalWizardry/api/harvest/HarvestRegistry.java
https://github.com/WayofTime/BloodMagic/blob/master/src/main/java/WayofTime/alchemicalWizardry/api/harvest/IHarvestHandler.java

Finally, here is a reference implementation of a HarvestHandler that I've used - this one would be more complicated then you'd need, because this one handles most/all of the standard vanilla plants.

https://github.com/WayofTime/BloodMagic/blob/master/src/main/java/WayofTime/alchemicalWizardry/common/harvest/BloodMagicHarvestHandler.java

From what I understand, it seems that all that you would need to do is make a HarvestHandler that checks if it is a BlockCrop - if it is, you'd just need to do a:

return crop.isMature() && crop.harvest(world, x, y, z);

Thanks for your time, and I hope you will consider this addition!
-Way

commented

@WayofTime, I noticed from your changelog that you added this from your side, however I already added it from my side (https://github.com/InfinityRaider/AgriCraft/blob/CropRewrite/src/main/java/com/InfinityRaider/AgriCraft/compatibility/bloodmagic/BloodMagicHarvesthandler.java) a while ago.
Do I need to get rid of mine or are you going to remove it from your side? I'm not sure if you're using reflection or directly referencing my classes, but either way I think having it on my side is cleaner, so what do you suggest?

commented

Guessing it might be better if I remove mine, since I do use quite a bit of reflection. That will happen in my next update!

commented

No hurry, I'll notify you when I release my next version so you can remove it on your side and in the meantime the users can play with it.

commented

Hello WayofTime, first off all thanks for your message, I was planning to do this from my side anyway (#92) so I'll certainly implement this soon enough. I'm going to close this because there is already an issue open for automation via other mods, feel free to continue this conversation here or there and reference where deemed necessary.

P.S. There is an API in the making, it's just not yet on the master branch because it is not a finished version, it is right here: https://github.com/InfinityRaider/AgriCraft/tree/CropRewrite
If you should start using this I would ask not to release any version of Blood Magic that uses that API as it is not finished and might change.