[SPIGOT-611] Tile data not cleaned up when replacing various blocks Created: 23/Feb/15  Updated: 25/Jun/16  Resolved: 25/Jun/16

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Mark Summers Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

Spigot 1.8, bug is new and was not present in the builds available at the end of December 2014


Issue Links:
Duplicate
is duplicated by SPIGOT-610 Tile data not cleaned up when replaci... Closed

 Description   

This may effect any block with an inventory or tile data, my users have reported it with enchanting tables, signs, and other blocks. But in my test case I used a furnace and I can verify it occurs with that block.

Basically if your plugin replaces a furnace with, say, a chest, and fills the inventory of the chest, the chest will then be empty and you may (but will not always) get this on the server console:

[Server thread/ERROR]: Block at 10,008,134,9,945 is CHEST but has net.minecraft.server.v1_8_R1.TileEntityFurnace@3224f772. Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.

I am not sure the exact build where this started, however I can confirm it does not happen with:
git-Spigot-"606148f" (MC: 1.8) (Implementing API version 1.8-R0.1-SNAPSHOT)

but it does happen with:
git-Spigot-35348a5-e
e6d0fa (MC: 1.8) (Implementing API version 1.8-R0.1-SNAPSHOT)

The code I am using to replace the block is similar to:
w.getBlockAt(x, y, z).setType(org.bukkit.Material.CHEST);
and then filling it with:
InventoryHolder inventoryHolder = ( InventoryHolder ) w.getBlockAt( l.getX(), l.getY(), l.getZ() ).getState();
inventoryHolder.getInventory().setContents( invData.getInvetory() );

Where x,y,z refers to a block that is a furnace.



 Comments   
Comment by Adam Taylor [ 22/Apr/15 ]

It still happens.
SPIGOT-825

Comment by Mark Summers [ 01/Apr/15 ]

I can say for sure that it still happens with comparators as described in SPIGOT-610, which has been merged into this ticket. I used the workaround of setting it to air first for other blocks, so I can't confirm if it still happens with those.

Comment by Thinkofname [ 29/Mar/15 ]

Does this still happen? I changed tile entity handling a few versions ago

Comment by Mark Summers [ 02/Mar/15 ]

Just in case anyone works on this bug, the error reported in SPIGOT-610 was erroneously listed as "duplicated by" this error. This isn't actually true, they are different errors (albeit similar in many ways). SPIGOT-610 is more severe, affects only comparators, can not be bypassed by first setting the block to air (or by any other means I have found), and has been around since at least Spigot 1.5. It can also cause permanent chunk damage, causing errors every time a chunk is loaded. I discovered you can avoid the permanent chunk damage by first replacing the comparator with a sign, setting the text on the sign, and then replacing it with air. I believe this forces Spigot to update the tile data on the back end before saving it to the chunk. However, it does still cause massive spam of error messages on the console. I probably get 100,000 of them a day.

Comment by Mark Summers [ 24/Feb/15 ]

Thanks Black Hole, I can confirm that this works. If I blank out any block with an inventory plus signs before I replace it, that seems to work. Still, I would like to leave this open as it did work without that workaround before, and this slows down the process. It's for Movecraft, a plugin that moves large crafts around the server, and it needs to process 10s of thousands of blocks a second. So every bit of speed matters.

Comment by Black Hole [ 24/Feb/15 ]

As a workaround you could set the block to air before applying the new state.

Comment by Mark Summers [ 23/Feb/15 ]

I went ahead and added a:
w.getBlockAt( l.getX(), l.getY(), l.getZ() ).getState().update();
after the setContents line, and it did not make a difference. The very first time I replace a furnace with a chest and try to fill it, I get:

[15:40:57 ERROR]: Block at 9,999,124,10,351 is CHEST but has net.minecraft.server.v1_8_R1.TileEntityFurnace@542b4a52. Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.

On the server console, and the chest is empty. It's also curious that this did not happen on the builds of Spigot 1.8 from December.

Comment by Antony Riley [ 23/Feb/15 ]

Generally if you don't call BlockState.update() after modifying a BlockState, it does not update.

Generated at Mon Apr 07 23:38:07 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.