Don't update physics when block place is cancelled. Fixes BUKKIT-3939
When a block placement happens we currently update physics on the attempted placement and update again if the placement is cancelled. To correct the first one we simply set the block without applying physics. To correct the second we have to add a new method to BlockState that lets us update without applying physics and use this method method when putting the block back.
This commit is contained in:
@@ -80,11 +80,11 @@ public class ItemBlock extends Item {
|
||||
org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, x, y, z);
|
||||
|
||||
world.callingPlaceEvent = true;
|
||||
world.setTypeIdAndData(x, y, z, id, data, 3);
|
||||
world.setTypeIdAndData(x, y, z, id, data, 2);
|
||||
|
||||
org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockstate, clickedX, clickedY, clickedZ);
|
||||
if (event.isCancelled() || !event.canBuild()) {
|
||||
blockstate.update(true);
|
||||
blockstate.update(true, false);
|
||||
world.callingPlaceEvent = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user