From 2f2bc28915f6b71e818c195e0e8e004bdf228ccd Mon Sep 17 00:00:00 2001 From: Brettflan Date: Thu, 3 Feb 2011 06:35:36 -0600 Subject: [PATCH] Fixes placement cancellation of single-step blocks, such as in protected areas like the spawn area. The first line edited fixes it so other blocks placed on a single-step block aren't considered (only single-step blocks), and so that they're only considered when placed on the top face of the existing single-step block. The second section of changed code keeps the final world.setTypeIdAndData() call from being incorrectly applied if it was indeed a single-block placed on an existing single-block. Best way to test before and after is to put a bunch of single-step blocks in the spawn area as an Op, then de-Op yourself and try placing more blocks (single-step and otherwise, for example I also tested dirt blocks) on the sides and tops of the ones which you previously added as an Op. --- .../java/net/minecraft/server/ItemBlock.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index 270b823e86..81e804fe3d 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -68,7 +68,7 @@ public class ItemBlock extends Item { /* We store the old data so we can undo it. Snow(78) and half-steps(44) are special in that they replace the block itself, * rather than the block touching the face we clicked on. */ - org.bukkit.block.Block replacedBlock = (blockClicked.getTypeId() == Block.SNOW.id || blockClicked.getTypeId() == Block.STEP.id) ? blockClicked:blockClicked.getFace(faceClicked); + org.bukkit.block.Block replacedBlock = ( blockClicked.getTypeId() == Block.SNOW.id || (blockClicked.getTypeId() == Block.STEP.id && itemstack.id == Block.STEP.id && faceClicked == BlockFace.UP) ) ? blockClicked : blockClicked.getFace(faceClicked); final BlockState replacedBlockState = new CraftBlockState(replacedBlock); // CraftBukkit end @@ -103,15 +103,20 @@ public class ItemBlock extends Item { if (event.isCancelled() || !event.canBuild()) { // CraftBukkit Undo! - if (this.a == block.ICE.id) { - // Ice will explode if we set straight to 0 - world.setTypeId(i, j, k, 20); - } else if ((this.a == Block.STEP.id) && (world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) && (world.getTypeId(i, j, k) == 0)) { + if ((this.a == Block.STEP.id) && (world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) && (world.getTypeId(i, j, k) == 0)) { // Half steps automatically set the block below to a double world.setTypeId(i, j - 1, k, 44); + + } else { + + if (this.a == block.ICE.id) { + // Ice will explode if we set straight to 0 + world.setTypeId(i, j, k, 20); + } + + world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getData().getData()); } - world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getData().getData()); } else { world.f(i, j, k, a); // <-- world.b does this on success (tell the world)