Fix TileEntities and Blocks getting out of sync. Fixes BUKKIT-3501

Also fixes: BUKKIT-3477 and BUKKIT-3488

Minecraft likes to double check that tile entities get set after they
are placed, however we didn't set tile entities until after our event
was called. This caused the world to have multiple tile entities in a
single block location; to fix this we now set tile entities before
the event.
This commit is contained in:
feildmaster
2013-01-27 09:13:06 -06:00
parent 6e438ccb32
commit 528bbbdcd8
3 changed files with 9 additions and 11 deletions

View File

@@ -80,22 +80,25 @@ public class ItemBlock extends Item {
org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, x, y, z);
world.suppressPhysics = true;
world.callingPlaceEvent = true;
world.setRawTypeIdAndData(x, y, z, id, data);
org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockstate, x, y, z);
if (event.isCancelled() || !event.canBuild()) {
blockstate.update(true);
world.suppressPhysics = false;
world.callingPlaceEvent = false;
return false;
}
world.suppressPhysics = false;
world.callingPlaceEvent = false;
int newId = world.getTypeId(x, y, z);
int newData = world.getData(x, y, z);
Block block = Block.byId[newId];
if (block != null) {
if (block != null && !(block instanceof BlockContainer)) { // Containers get placed automatically
block.onPlace(world, x, y, z);
}