summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrettflan <dsr@fenrisoft.com>2011-02-03 06:35:36 -0600
committerVictorD <victor.danell@gmail.com>2011-02-03 22:07:34 +0100
commit2f2bc28915f6b71e818c195e0e8e004bdf228ccd (patch)
treef203fe1873c9eef59e3df6659146668047ca5ea5 /src
parentdde3f5b47416106afea9a941154b49f680efcdb9 (diff)
downloadcraftbukkit-2f2bc28915f6b71e818c195e0e8e004bdf228ccd.tar
craftbukkit-2f2bc28915f6b71e818c195e0e8e004bdf228ccd.tar.gz
craftbukkit-2f2bc28915f6b71e818c195e0e8e004bdf228ccd.tar.lz
craftbukkit-2f2bc28915f6b71e818c195e0e8e004bdf228ccd.tar.xz
craftbukkit-2f2bc28915f6b71e818c195e0e8e004bdf228ccd.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/ItemBlock.java17
1 files 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 270b823e..81e804fe 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)