summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/ItemBlock.java
diff options
context:
space:
mode:
authorTahg <tahgtahv@gmail.com>2012-02-02 07:54:51 -0500
committerEvilSeph <evilseph@gmail.com>2012-02-03 01:14:47 -0500
commit14bb771957ea4154bd1aa37a22012e3eb8e2ac53 (patch)
treec1d3997b70642291c27b8c1664c2f484049ee16d /src/main/java/net/minecraft/server/ItemBlock.java
parent1bb011a543a1aef267a38e79f3ed4de00a595a71 (diff)
downloadcraftbukkit-14bb771957ea4154bd1aa37a22012e3eb8e2ac53.tar
craftbukkit-14bb771957ea4154bd1aa37a22012e3eb8e2ac53.tar.gz
craftbukkit-14bb771957ea4154bd1aa37a22012e3eb8e2ac53.tar.lz
craftbukkit-14bb771957ea4154bd1aa37a22012e3eb8e2ac53.tar.xz
craftbukkit-14bb771957ea4154bd1aa37a22012e3eb8e2ac53.zip
Allow plugins to change ID and Data during BlockPlace event.
Fixes BUKKIT-674
Diffstat (limited to 'src/main/java/net/minecraft/server/ItemBlock.java')
-rw-r--r--src/main/java/net/minecraft/server/ItemBlock.java23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
index 7cd698ec..f910bee7 100644
--- a/src/main/java/net/minecraft/server/ItemBlock.java
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
@@ -80,28 +80,21 @@ public class ItemBlock extends Item {
world.suppressPhysics = true;
world.setTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()));
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block);
+ int id = world.getTypeId(i, j, k);
+ int data = world.getData(i, j, k);
replacedBlockState.update(true);
world.suppressPhysics = false;
if (event.isCancelled() || !event.canBuild()) {
return true;
}
- /**
- * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1)
- *
- * This replaces world.setTypeIdAndData(IIIII), we're doing this because we need to
- * hook between the 'placement' and the informing to 'world' so we can
- * sanely undo this.
- *
- * Whenever the call to 'world.setTypeIdAndData' changes we need to figure out again what to
- * replace this with.
- */
- 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);
+
+ if (world.setTypeIdAndData(i, j, k, id, data)) {
+ if (Block.byId[id] != null) {
+ Block.byId[id].postPlace(world, i, j, k, l);
+ Block.byId[id].postPlace(world, i, j, k, entityhuman);
}
+ // CraftBukkit end
world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F);
--itemstack.count;