Animania Base

Animania Base

11M Downloads

Crash when hitting a hedgehog with Tinkers Hatchet

Dyonovan opened this issue ยท 7 comments

commented

Expected Behavior

Not Crash

Actual Behavior

Crashed

Steps to Reproduce

Version of Minecraft, version of Animania, Single Player or Server

MC: 1.12.2
Forge: 14.23.4.2751
Animania - 1.5.1.1
Server

Screenshots encouraged

Crasglog: https://pastebin.com/8ngY0aEw

commented

Yes, will need to issue a hotfix. Until then, avoid killing Hedgehogs.

commented

The cause of this bug seems to be this line in EntityHedgehogBase.java:

this.tasks.addTask(13, new GenericAIHurtByTarget(this, false, new Class[0]));

GenericAIHurtByTarget belongs to targetTasks, not tasks. It is a subclass of EntityAITarget, which means its resetTask() will set the hedgehog's attack target to null, "pulling the target from under" the EntityAIAttackMelee already scheduled to execute. And that resetTask() will be called, because GenericAIHurtByTarget is mutually exclusive with EntityAIAttackMelee and the latter has a higher priority.

Actually, it seems that many animals put GenericAIHurtByTarget in tasks, but most of them don't actually have a melee attack so they are fine. For chickens and cattle, only adults have melee attacks, which are defined in the gender-specific subclasses after the problematic GenericAIHurtByTarget, so they also don't suffer from this particular bug. Peacocks would be problematic, except that for them panicking has a higher priority than attacking, so they are too busy panicking to actually trigger the crash.

Oh, and those times you attacked a hedgehog and didn't trigger the crash? Your attack probably sent it flying, so when it should be attacking you (which will be 3-5 ticks later, due to the game only checking for new AI tasks every 3 ticks), it still isn't on the ground. Since the pathfinder for the hedgehog only works on the ground (or in water), it cannot find a path to attack you, so the attack doesn't happen. Which means it panics instead, and the GenericAIHurtByTarget resets and harmlessly clears its attack target, leaving it running away without remembering that it was ever supposed to retaliate.

commented

Wow, this is very detailed, thanks for looking into this so closely. I will implement this fix immediately.

commented

Oh my god. Thank you so much. This one was killing me....

commented

PLEASE fix this, it happens so often...
crash-2018-10-25_17.45.30-server.txt

commented

@KenyMylankca Did you see the label?
" fixed in next release "

commented

@KenyMylankca If you can't wait, you can always pull the latest code from github and compile it (it's kind of easy with gradle). The fix should be in the repo already.