GrowthRequirementHandler.addSoil() is not exposed in the API
HenryLoenwind opened this issue ยท 10 comments
or API.registerGrowthRequirement() doesn't register the soil for custom growth requirements.
You're right, I'm registering the soil in the GrowthRequirement builder class: https://github.com/InfinityRaider/AgriCraft/blob/master/src/main/java/com/InfinityRaider/AgriCraft/farming/growthrequirement/GrowthRequirement.java#L224
I should probably do it while registering:
https://github.com/InfinityRaider/AgriCraft/blob/master/src/main/java/com/InfinityRaider/AgriCraft/farming/GrowthRequirementHandler.java#L34
However I'll also add an addSoil() method to the API
On second thoughts, I"ll deprecate registerGrowthRequirement, and make an IBuilder interface instead.
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.
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"?
Work in progress:
(try to prevent growing if it cannot use power)
(check if surrounded by dark bar fence)
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.
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
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.
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.