All rights reserved - None of my artwork is available to be used for FREE in your game EVER. If you want to HIRE ME, please contact me. Thank you. This code is here for people to learn from and to help find bugs ONLY.
If a mob returns true for isChild but does not inherit from AgeableEntity, then right-clicking it with an ItemPamGrain, ItemPamPig, ItemPamRabbit, or ItemPamSeed will crash the game because this exception is thrown:
java.lang.ClassCastException: mekanism.additions.common.entity.baby.EntityBabyCreeper cannot be cast to net.minecraft.entity.AgeableEntity
at pam.pamhc2crops.items.ItemPamRabbit.func_111207_a(ItemPamRabbit.java:51) ~[pamhc2crops:1.0.2] {re:classloading}
...
Mekanism Additions is one mod that will trigger this bug with its EntityBabyCreeper. Presumably all its other baby monsters have the same problem.
This PR fixes the problem by checking if the entity is an instance of AgeableEntity before casting it. I noticed that the first half of the method already does this, so I wrapped the rest of the method inside that check.
If a mob returns true for isChild but does not inherit from AgeableEntity, then right-clicking it with an ItemPamGrain, ItemPamPig, ItemPamRabbit, or ItemPamSeed will crash the game because this exception is thrown:
Mekanism Additions is one mod that will trigger this bug with its EntityBabyCreeper. Presumably all its other baby monsters have the same problem.
This PR fixes the problem by checking if the entity is an instance of AgeableEntity before casting it. I noticed that the first half of the method already does this, so I wrapped the rest of the method inside that check.