c0508383 / Backhand

MIT License
16 stars 3 forks source link

Crash when extinguishing/igniting campfire using dispenser with Backhand installed #72

Open huihiuhuai opened 2 months ago

huihiuhuai commented 2 months ago

https://pastebin.com/TqXR2YGN

connor135246 commented 2 months ago

This is an incompatibility with Campfire Backport in case that wasn't clear. The crash occurs because I use a FakePlayer to damage the item in the dispenser, and the FakePlayer doesn't have an offhand.

This bug isn't exclusive to Campfire Backport. I've been able to cause the same crash with EnderIO's Killer Joe block (it attacks mobs automatically). There may be other blocks that have this issue.


Details:

I use a FakePlayer to do a couple things when extinguishing/igniting the campfire from a dispenser. It looks like Backhand excludes FakePlayers from getting the offhand extended entity property: https://github.com/c0508383/Backhand/blob/23dd30c14212c19f145c953adacfd5dd188f16ce/src/main/java/mods/battlegear2/BattlemodeHookContainerClass.java#L70-L75 So when I try to damage the item, this patch tries to get the offhand item on line 81: https://github.com/c0508383/Backhand/blob/23dd30c14212c19f145c953adacfd5dd188f16ce/src/main/java/net/tclproject/mysteriumlib/asm/fixes/MysteriumPatchesFixesO.java#L74-L81 And then there's a null pointer exception on line 79 here: https://github.com/c0508383/Backhand/blob/23dd30c14212c19f145c953adacfd5dd188f16ce/src/main/java/mods/battlegear2/api/core/BattlegearUtils.java#L75-L79 Because this returns null: https://github.com/c0508383/Backhand/blob/23dd30c14212c19f145c953adacfd5dd188f16ce/src/main/java/mods/battlegear2/api/core/BattlegearUtils.java#L83-L85 So I think some null checks around getting the offhand property would be a good way to fix it.