diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 39f01117f6..243c3339a3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -528,9 +528,10 @@ public class CraftEventFactory { ((EntityPlayer) player).netServerHandler.sendPacket(packet); } - List drops = new ArrayList(); + List calculatedDrops = blockType.calculateDrops(world, player, x, y, z, data); + List drops = new ArrayList(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()); + blockType.dropList.clear(); // Let the client know the block still exists ((EntityPlayer) player).netServerHandler.sendPacket(new Packet53BlockChange(x, y, z, world)); return true; } - ArrayList toDrop = new ArrayList(); + ArrayList toDrop = new ArrayList(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 }