copygirl's Wearable Backpacks

copygirl's Wearable Backpacks

15M Downloads

[1.11.2] Backpacks break when killed by a creeper

SeriousCreeper opened this issue · 4 comments

commented

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

commented

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.

commented

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

Explosions work this way:

  • Collect all blocks that would be destroyed by the explosion.
  • Damage entities.
  • Destroy all collected blocks.

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.

commented

Thanks a lot for fixing this! :D

commented

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.