copygirl / WearableBackpacks

Minecraft mod which adds beautiful, balanced backpacks
MIT License
61 stars 35 forks source link

[1.11.2] Backpacks break when killed by a creeper #22

Closed SeriousCreeper closed 7 years ago

SeriousCreeper commented 7 years ago

Heya,

as far as i know the backpack should place itself when the player dies, which works in all cases except for when a creeper explodes. I understand that the backpacks are not immune to explosions, but when a creeper kills me, shouldn't that explosion ignore the backpack and just place it down? Is it being placed too early before the explosion is breaking blocks perhaps?

Using the latest verison,

Thanks, SC

copygirl commented 7 years ago

Hmm. Interesting. I don't think that was an issue with BetterStorage, and if I remember correctly it used the same events. I might look into it at some point, perhaps give the backpack explosion immunity for a few ticks if it turns out there is no other way around this.

copygirl commented 7 years ago

Found out the issue, might as well leave it here for the record.

Explosions work this way:

Player dies in the second step and the backpack is placed. It is then destroyed in the third step, and the placed block might as well be bedrock, as the explosion resistance is only checked in the first step.

SeriousCreeper commented 7 years ago

Thanks a lot for fixing this! :D

copygirl commented 7 years ago

Sure thing! ❤️

Unfortunately I had to break another part of the mod. The fix required me to use a different method to drop the backpack itself when the block is broken. So instead of dropping it the intended, normal way (through getDrops), it drops along with the contents.

This avoids a dupe glitch if the backpack was to be affected from an explosion right after being placed down after death, because getDrops is called before I can cancel it being destroyed. It also means you'll get the backpack when breaking it in creative. I guess I could treat that as a feature, though. Minecraft modding is a mess.