diff options
author | feildmaster <admin@feildmaster.com> | 2012-03-25 17:53:59 -0500 |
---|---|---|
committer | Warren Loo <evilseph@gmail.com> | 2012-03-25 18:57:27 -0400 |
commit | c30e339af6dd7594cca7e0c1ca31f0ea34a0afa9 (patch) | |
tree | 0542eb206109014946aa1f8b54afd2cceff7bb0f /src | |
parent | 0c9b59e071194dd737c69809d6f41b22014eeec7 (diff) | |
download | craftbukkit-c30e339af6dd7594cca7e0c1ca31f0ea34a0afa9.tar craftbukkit-c30e339af6dd7594cca7e0c1ca31f0ea34a0afa9.tar.gz craftbukkit-c30e339af6dd7594cca7e0c1ca31f0ea34a0afa9.tar.lz craftbukkit-c30e339af6dd7594cca7e0c1ca31f0ea34a0afa9.tar.xz craftbukkit-c30e339af6dd7594cca7e0c1ca31f0ea34a0afa9.zip |
[Bleeding] Fixed item duping in certain occasions. Fixes BUKKIT-1310
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/Block.java | 7 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/BlockVine.java | 3 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 11 |
3 files changed, 9 insertions, 12 deletions
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java index 7b3962a7..43430951 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java @@ -164,7 +164,7 @@ public class Block { public final Material material; public float frictionFactor; private String name; - protected ArrayList<ItemStack> dropList = new ArrayList<ItemStack>(); // CraftBukkit + public ArrayList<ItemStack> dropList = new ArrayList<ItemStack>(1); // CraftBukkit protected Block(int i, Material material) { this.bR = true; @@ -338,6 +338,7 @@ public class Block { } public final void b(World world, int i, int j, int k, int l, int i1) { + this.dropList.clear(); // CraftBukkit this.dropNaturally(world, i, j, k, l, 1.0F, i1); this.doActualDrop(world, i, j, k); // CraftBukkit } @@ -549,10 +550,6 @@ public class Block { this.dropList.clear(); } - public void setDrops(ArrayList<ItemStack> drops) { - this.dropList = drops; - } - public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { // CraftBukkit end if (this.h() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman.inventory)) { diff --git a/src/main/java/net/minecraft/server/BlockVine.java b/src/main/java/net/minecraft/server/BlockVine.java index 2180dc17..93d8876b 100644 --- a/src/main/java/net/minecraft/server/BlockVine.java +++ b/src/main/java/net/minecraft/server/BlockVine.java @@ -300,9 +300,8 @@ public class BlockVine extends Block { // CraftBukkit start - Calculate drops public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) { if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) { - super.dropList = new ArrayList<ItemStack>(); this.a(world, i, j, k, new ItemStack(Block.VINE, 1, 0)); - return super.dropList; + return this.dropList; } else { return super.calculateDrops(world, entityhuman, i, j, k, l); } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 39f01117..243c3339 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -528,9 +528,10 @@ public class CraftEventFactory { ((EntityPlayer) player).netServerHandler.sendPacket(packet); } - List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>(); + List<ItemStack> calculatedDrops = blockType.calculateDrops(world, player, x, y, z, data); + List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>(calculatedDrops.size()); if (!creative && player.b(blockType)) { - for (ItemStack stack : blockType.calculateDrops(world, player, x, y, z, data)) { + for (ItemStack stack : calculatedDrops) { drops.add(new CraftItemStack(stack)); } } @@ -539,17 +540,17 @@ public class CraftEventFactory { world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { - blockType.setDrops(new ArrayList<ItemStack>()); + blockType.dropList.clear(); // Let the client know the block still exists ((EntityPlayer) player).netServerHandler.sendPacket(new Packet53BlockChange(x, y, z, world)); return true; } - ArrayList<ItemStack> toDrop = new ArrayList<ItemStack>(); + ArrayList<ItemStack> toDrop = new ArrayList<ItemStack>(drops.size()); for (org.bukkit.inventory.ItemStack stack : drops) { toDrop.add(CraftItemStack.createNMSItemStack(stack)); } - blockType.setDrops(toDrop); + blockType.dropList = toDrop; return false; // Event not cancelled } |