Evil Wizard summoned Lightning Wraith attack causes NPE
CheshireSwift opened this issue ยท 2 comments
Minecraft version: 1.12.2
Wizardry version: 4.1.4
Environment: Singleplayer
Issue details: Fighting an Evil Wizard. He spawned a Lightning Wraith. Shortly after (when the Wraith went to attack?) the game crashed.
Other mods involved: Wild speculation, but given it's causing an NPE inside the getDistanceSq
, I was wondering if maybe it was related to the Dynamic Stealth mod's changes to entity senses? NPE'ing because it's being blocked from getting the player's position, or something.
Link to crash report (if applicable): https://gist.github.com/CheshireSwift/3c50eadea33370ac0227ed48d365a01a
I was wondering if maybe it was related to the Dynamic Stealth mod's changes to entity senses?
Pretty sure you're right. The line that's crashing is part of some AI code I had to copy from the vanilla blaze mob, so I had a dig through dynamic stealth's issue tracker and sure enough, there's an old issue on there with the exact same crash report but for vanilla blazes Laike-Endaril/Dynamic-Stealth#6. It was fixed by substituting that AI class with an edited version via reflection, but that of course doesn't affect my custom AI.
This is a simple one-line fix so I'll add it in.
Technical explanation: the NPE is due to there being no attack target when the attack AI is run. This never happens in vanilla Minecraft because the attack AI doesn't run if there's no target, so it is usually safe to assume there is one. However, dynamic stealth clearly messes with a fair amount of the AI code such that this assumption no longer holds, causing the crash. The fix is therefore to explicitly check there's a target.