Um-Mitternacht / Bewitchment

Mod inspired by Witchery
118 stars 69 forks source link

Tool protection poppet handling crashes if a tool breaks inside a machine #699

Closed Barhandar closed 3 years ago

Barhandar commented 3 years ago

Expected Behavior

Tool breaking when used by machine doesn't crash and Bewitchment correctly ignores tool break events raised in non-player-held conditions.

Actual Behavior

It crashes the server.

Steps to Reproduce

Put a tool that raises PlayerDestroyItemEvent inside a tileentity capable of using tools, make it use the tool until the durability runs out, observe crash.
In specific circumstances used, it was Actually Additions knife inside Extra Utilities 2 Mechanical Crafter (first log)/RFTools Crafter (second log), used to make french fries.
Most likely cause is that the code is assuming that EntityPlayer exists, while for TEs it or EntityPlayer.world is null.
https://github.com/Um-Mitternacht/Bewitchment/blob/1.12.2/src/main/java/com/bewitchment/common/handler/PoppetHandler.java#L170

Version of Minecraft, Bewitchment, Forge, Patchouli, and Baubles used

1.12.2
bewitchment-1.12.2-0.0.22.49.jar/bewitchment-1.12.2-0.0.22.58.jar
Forge 14.23.5.2854
Patchouli-1.0-22.jar
Baubles-1.12-1.5.2.jar
While the first log has modified mixins version in Bewitchment (a mod that is needed for the pack and cannot be updated is incompatible with 0.8), the issue happens without that modification as well, as indicated by the second log.

Logs, in the event of a crash

https://pastebin.com/74NsqrYF https://paste.ee/p/fy0ST

Sunconure11 commented 3 years ago

I can take a look at it tomorrow or so. Not feeling very well. Incredibly bloated and gassy.

MoriyaShiine commented 3 years ago

tmi