AppleCore

AppleCore

56M Downloads

ModulePlantFertilization causes StackOverflowError on super.grow(...)

FunnyMan3595 opened this issue ยท 3 comments

commented

With AppleCore installed, an IGrowable that calls super.grow(...) can create an infinite chain of calls leading to a StackOverflowError:

...
at squeek.applecore.asm.Hooks.fireAppleCoreFertilizeEvent(Hooks.java:284)
at net.minecraft.block.BlockCrops.func_176474_b(BlockCrops.java)
at com.blakebr0.mysticalagradditions.blocks.BlockTier6Crop.AppleCore_fertilize(BlockTier6Crop.java:56)
at squeek.applecore.asm.Hooks.fireAppleCoreFertilizeEvent(Hooks.java:296)
at net.minecraft.block.BlockCrops.func_176474_b(BlockCrops.java)
at com.blakebr0.mysticalagradditions.blocks.BlockTier6Crop.AppleCore_fertilize(BlockTier6Crop.java:56)
at squeek.applecore.asm.Hooks.fireAppleCoreFertilizeEvent(Hooks.java:296)
at net.minecraft.block.BlockCrops.func_176474_b(BlockCrops.java)
at com.blakebr0.mysticalagradditions.blocks.BlockTier6Crop.AppleCore_fertilize(BlockTier6Crop.java:56)
at squeek.applecore.asm.Hooks.fireAppleCoreFertilizeEvent(Hooks.java:296)
...

The specific trigger in this case is Mystical Aggraditions:
https://github.com/BlakeBr0/MysticalAgradditions/blob/423388d42d194268af5c440cb0a49fe0d02fd2c7/1.12/src/main/java/com/blakebr0/mysticalagradditions/blocks/BlockTier6Crop.java#L56

The call to super.grow(...) lands on BlockCrops.grow(...), which is replaced by ModulePlantFertilization:

private void replaceFertilizeMethod(MethodNode method, FertilizeMethodInfo methodInfo)

This in turn calls the AppleCore fertilization event, which does not object, so it calls back to AppleCore_fertilize:

fertilizableBlock.AppleCore_fertilize(world, random, pos, state);

...which is what the original method was renamed to:

ASMHelper.copyAndRenameMethod(classNode, method, "AppleCore_fertilize");

The end result being, in my case, a Flawless Greenhouse from Calculator that should be growing T6 Mystical Aggraditions crops, but instead causes Minecraft to hang whenever I enter the world. :(

commented

Should be fixed in v3.0.0 (decided to just remove that event): https://minecraft.curseforge.com/projects/applecore/files

commented

Thanks for reporting this, surprised it hasn't come up before.

commented

Hm... I'm tempted to just remove the fertilization event entirely and do a major version bump. FertilizationEvent has always been a pain to maintain (due to these sorts of issues, compounded by the fact that it touches every IGrowable), and as far as I'm aware it's never been used by any mod that depends on AppleCore (except Biota, but it was never finished).