MysticMods / Roots

Home of the Roots Minecraft Mod
GNU Lesser General Public License v3.0
44 stars 33 forks source link

[FORWARDED] Roots Non-Detection Effect Causes Crash #816

Open ByThePowerOfScience opened 5 months ago

ByThePowerOfScience commented 5 months ago

Divine-Journey-2/Divine-Journey-2#1134

ByThePowerOfScience commented 5 months ago

Issue is caused by this line:

if (this.taskOwner != entitycreature && entitycreature.getAttackTarget() == null
                && (
                        !(this.taskOwner instanceof EntityTameable)
                        || ((EntityTameable)this.taskOwner).getOwner() == ((EntityTameable)entitycreature).getOwner())
                && !entitycreature.isOnSameTeam(this.taskOwner.getRevengeTarget()))

where this.taskOwner.getRevengeTarget() is null. The method is marked as nullable, but the isOnSameTeam method doesn't account for that. I can't see a way to resolve this short of patching the isOnSameTeam method via ASM.

ByThePowerOfScience commented 5 months ago

I tried doing an ASM-only implementation, but I forgot how much I hate coremods in 1.12. I'm adding Mixin as an optional dependency to patch this bug specifically.

noobanidus commented 5 months ago

I'm assuming that, within Vanilla contexts, this piece of code would never fire is getRevengeTarget is null.

ByThePowerOfScience commented 5 months ago

I'm assuming that, within Vanilla contexts, this piece of code would never fire is getRevengeTarget is null.

Likewise, though getRevengeTarget does change to returning null after a few seconds, so it's really just luck that they never encountered this NPE.