AgriCraft

AgriCraft

30M Downloads

GrowthRequirementHandler.addSoil() is not exposed in the API

HenryLoenwind opened this issue ยท 10 comments

commented

or API.registerGrowthRequirement() doesn't register the soil for custom growth requirements.

commented

On second thoughts, I"ll deprecate registerGrowthRequirement, and make an IBuilder interface instead.

commented

Please don't. That would limit the requirements to that what your builder can build.

And btw, aim I'm fighting with the lack of any callback for "is allowed to grow" that is only called when the plant is actually trying to grow. That one is needed for plants that need to consume resources to grow.

commented

Why not? It would be an interface for this class: https://github.com/InfinityRaider/AgriCraft/blob/master/src/main/java/com/InfinityRaider/AgriCraft/farming/growthrequirement/GrowthRequirement.java#L199-L238

Its basicly all that is needed.

And what do you mean "is allowed to grow"?

commented

Yes, I read your code. I use a GrowthRequirement to have my requirements and produce shown in NEI (at least partially). I had also hoped giving a GrowthReq to the API would register the soil.

onAllowedGrowthTick() is only called when the growing cannot be aborted anymore. But I don't only want it to not grow if there's no power, I also want it to use that power when it has the chance to grow.

...

Um, I just noticed that onAllowedGrowthTick() will only be called if isFertile() has checked that there actually is enough power, so I don't need to check in there but can just use it. Oookeey, that does make it simpler.

Now I only need to check for work.isRemote in isFertile()---capBanks only lazily sync to the client.

commented

Ah I see. Well in your case you don't need to use IGrowthRequirement because you're doing your own logic. Also when the plant actually grows, is this method with is called on allowed growth tick: https://github.com/HenryLoenwind/EnderIOAddons/blob/darkplant/src/main/java/info/loenwind/enderioaddons/plant/EioaCropPlant.java#L126

commented

Basicly I use the GrowthRequirement class internally for my own crops + the crops I add compatibility for. It can be used by other mods (and MineTweaker) to change the growth behaviour. If you register your own CropPlant, it uses CropPlant.isFertile(World world, int x, int y, int z), which in my code is forwarded to the GrowthRequirementHandler.

commented

Yes, I changed the soil thing, it"ll now be registered yes. Also be mindful that registering your growth requirement will allow it to be changed trough MineTweaker.

commented

I see now what you mean, if someone doesn't use IGrowthRequirement for the fertility logic for their plants, there's no way to easily register the soils.