From f325b9beac7175bce792151340dbf399ac7c8cb4 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 5 Apr 2020 16:52:06 +1000 Subject: [PATCH] SPIGOT-5641: Add Block.getDrops(ItemStack, Entity) --- .../java/org/bukkit/craftbukkit/block/CraftBlock.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index c0f557568d..eb0201ebe1 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -38,9 +38,11 @@ import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftFluidCollisionMode; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.craftbukkit.util.CraftRayTraceResult; +import org.bukkit.entity.Entity; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; @@ -612,12 +614,17 @@ public class CraftBlock implements Block { @Override public Collection getDrops(ItemStack item) { + return getDrops(item, null); + } + + @Override + public Collection getDrops(ItemStack item, Entity entity) { IBlockData iblockdata = getNMS(); net.minecraft.server.ItemStack nms = CraftItemStack.asNMSCopy(item); // Modelled off EntityHuman#hasBlock if (iblockdata.getMaterial().isAlwaysDestroyable() || nms.canDestroySpecialBlock(iblockdata)) { - return net.minecraft.server.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), null, nms) + return net.minecraft.server.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms) .stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()); } else { return Collections.emptyList();