From 57e0a106fed3877827f8f7b7a7a61108d2645ff8 Mon Sep 17 00:00:00 2001 From: EvilSeph Date: Thu, 28 Jul 2011 01:05:07 -0400 Subject: [PATCH] Fixed BlockPlace event for doublesteps. Thanks DiddiZ! --- src/main/java/net/minecraft/server/ItemBlock.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index 3c1ee76e8f..3425366655 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -62,9 +62,13 @@ public class ItemBlock extends Item { // would happen if you place x step onto another y step, so let's just keep // track of the entire state CraftBlockState blockStateBelow = null; + // Toggles whether the normal or the block below is used for the place event + boolean eventUseBlockBelow = false; if ((world.getTypeId(i, j - 1, k) == Block.STEP.id || world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) && (itemstack.id == Block.DOUBLE_STEP.id || itemstack.id == Block.STEP.id)) { blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k); + // Step is placed on step, forms a doublestep replacing the original step, so we need the lower block + eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id; } /** @@ -78,7 +82,7 @@ public class ItemBlock extends Item { * replace this with. */ if (world.setRawTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block); + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block); if (event.isCancelled() || !event.canBuild()) { if (blockStateBelow != null) { // Used for steps