Botania

Botania

133M Downloads

AOE break code references already removed tile Entity

maxhenkes opened this issue ยท 0 comments

commented

So to say upfront this not only happens with the terra shatterer, but also similarly coded AOE tools. I've just fixed this in SparksHammers for example, but the problem is also here:

When breaking blocks with nbt tag, like the IE conveyor, the middle block is broken fine, but all the other blocks around it that are broken in AOE lose their nbt tag. This is usually not a huge problem but IE conveyors don't have a default, nbt'less state, so they break.

Here you can see:
9 CRAFTED conveyors placed:
http://i.imgur.com/nrE4ddB.png

Broken with terra shatterer's aoe effect
http://i.imgur.com/5wPkLtU.png

They don't stack:
http://i.imgur.com/qPFnOfk.png

The one in the middle, broken by vanilla method has its nbt tag:
http://i.imgur.com/etiE2UW.png

The 8 others lost it:
http://i.imgur.com/OXHSLho.png

When placed again, only the middle one works:
http://i.imgur.com/DwHhXw3.png

Now before you say this is probably caused by IE's tile entities not properly calling the save method, here is the problem in your code:

https://github.com/Vazkii/Botania/blob/master/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java#L100

On line 100 you are getting the tileEntity that has already been destroyed on Line 97 by

blk.onBlockDestroyedByPlayer(world, pos, state);

and line 94:
blk.onBlockHarvested(world, pos, localState, player);
This line should be removed anyways as it's not needed. Removing the tile Entity in this case also removes the corresponding block, always

You simply need to get the tile Entity before making any calls, right after the IF statement like tcon does it (I assume your code was derived from this as well, similarities are there)
https://github.com/SlimeKnights/TinkersConstruct/blob/master/src/main/java/slimeknights/tconstruct/library/utils/ToolHelper.java#L403

Again I'm only noticing this because it came up as a bug on our server and I've fixed it in SparksHammers which also has AOE tools. You have the exact same lines of code as SparksHammers and tinkers, so I assume your problem is the same.