diff options
author | Tahg <tahgtahv@gmail.com> | 2012-01-27 19:44:09 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-01-28 03:09:48 -0500 |
commit | 9b635aacc466afc756147ee92ecbe98e1a4f5c76 (patch) | |
tree | 76124c1d3c2757897737dde84f2903356b9feac2 /src/main/java | |
parent | 7bdfea48204655ec8158784bc6653be3f281a5cf (diff) | |
download | craftbukkit-9b635aacc466afc756147ee92ecbe98e1a4f5c76.tar craftbukkit-9b635aacc466afc756147ee92ecbe98e1a4f5c76.tar.gz craftbukkit-9b635aacc466afc756147ee92ecbe98e1a4f5c76.tar.lz craftbukkit-9b635aacc466afc756147ee92ecbe98e1a4f5c76.tar.xz craftbukkit-9b635aacc466afc756147ee92ecbe98e1a4f5c76.zip |
Moved BlockPlace event.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/net/minecraft/server/ItemBlock.java | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index 7045077a..78b29924 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -77,6 +77,11 @@ public class ItemBlock extends Item { eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id; } + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block); + + if (event.isCancelled() || !event.canBuild()) { + return true; + } /** * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1) * @@ -87,35 +92,8 @@ public class ItemBlock extends Item { * Whenever the call to 'world.setTypeIdAndData' changes we need to figure out again what to * replace this with. */ - if (world.setRawTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block - // Make sure the block-rotation already gets set before we call the event - if (Block.byId[this.id] instanceof BlockStairs) { - Block.byId[this.id].postPlace(world, i, j, k, entityhuman); - } - - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block); - - if (event.isCancelled() || !event.canBuild()) { - if (blockStateBelow != null) { // Used for steps - world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); - world.setTypeIdAndData(i, j - 1, k, blockStateBelow.getTypeId(), blockStateBelow.getRawData()); - - } else { - - if (this.id == 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.getRawData()); - } - return true; - - } - world.update(i, j, k, this.id); // <-- world.setTypeIdAndData does this on success (tell the world) - + if (world.setTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block // CraftBukkit end - if (world.getTypeId(i, j, k) == this.id) { Block.byId[this.id].postPlace(world, i, j, k, l); Block.byId[this.id].postPlace(world, i, j, k, entityhuman); |