diff options
author | Nate Mortensen <nate.richard.mortensen@gmail.com> | 2014-05-25 21:11:34 -0600 |
---|---|---|
committer | Nate Mortensen <nate.richard.mortensen@gmail.com> | 2014-05-26 17:54:51 -0600 |
commit | 3fbf4d3b5f3c5b74b73ba761ec278c9bdff448f5 (patch) | |
tree | 27378f3c9ec7c9d853af068eb6f6cff8bf6b878a /src/main | |
parent | e080bafa58c52dc5debf1e6da5ba1c4b5f017795 (diff) | |
download | craftbukkit-3fbf4d3b5f3c5b74b73ba761ec278c9bdff448f5.tar craftbukkit-3fbf4d3b5f3c5b74b73ba761ec278c9bdff448f5.tar.gz craftbukkit-3fbf4d3b5f3c5b74b73ba761ec278c9bdff448f5.tar.lz craftbukkit-3fbf4d3b5f3c5b74b73ba761ec278c9bdff448f5.tar.xz craftbukkit-3fbf4d3b5f3c5b74b73ba761ec278c9bdff448f5.zip |
Fix ItemStack state during BlockPlaceEvent. Fixes BUKKIT-5632
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/minecraft/server/BlockSapling.java | 3 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/ItemStack.java | 17 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java index 22197bb8..4152bd70 100644 --- a/src/main/java/net/minecraft/server/BlockSapling.java +++ b/src/main/java/net/minecraft/server/BlockSapling.java @@ -34,8 +34,7 @@ public class BlockSapling extends BlockPlant implements IBlockFragilePlantElemen this.grow(world, i, j, k, random); // CraftBukkit start world.captureTreeGeneration = false; - if (world.capturedBlockStates.size() > 0) - { + if (world.capturedBlockStates.size() > 0) { TreeType treeType = BlockSapling.treeType; BlockSapling.treeType = null; Location location = new Location(world.getWorld(), i, j, k); diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java index bae352b2..73428488 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -100,6 +100,10 @@ public final class ItemStack { } } boolean flag = this.getItem().interactWith(this, entityhuman, world, i, j, k, l, f, f1, f2); + int newData = this.getData(); + int newCount = this.count; + this.count = count; + this.setData(data); world.captureBlockStates = false; if (flag && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { world.captureTreeGeneration = false; @@ -114,6 +118,11 @@ public final class ItemStack { org.bukkit.Bukkit.getPluginManager().callEvent(event); } if (event == null || !event.isCancelled()) { + // Change the stack to its new contents if it hasn't been tampered with. + if (this.count == count && this.getData() == data) { + this.setData(newData); + this.count = newCount; + } for (BlockState blockstate : blocks) { blockstate.update(true); } @@ -139,10 +148,12 @@ public final class ItemStack { for (BlockState blockstate : blocks) { blockstate.update(true, false); } - // make sure to restore stack after cancel - this.setData(data); - this.count = count; } else { + // Change the stack to its new contents if it hasn't been tampered with. + if (this.count == count && this.getData() == data) { + this.setData(newData); + this.count = newCount; + } for (BlockState blockstate : blocks) { int x = blockstate.getX(); int y = blockstate.getY(); |