From 46a138606655ce6a79e62c63a0d27e10643975ea Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 9 May 2020 16:05:17 +1000 Subject: [PATCH] SPIGOT-5718: Block.BreakBlockNaturally does not reflect tool used --- .../java/org/bukkit/craftbukkit/block/CraftBlock.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 5c1c4d5837..6bf73af21c 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -593,11 +593,14 @@ public class CraftBlock implements Block { @Override public boolean breakNaturally(ItemStack item) { // Order matters here, need to drop before setting to air so skulls can get their data - net.minecraft.server.Block block = this.getNMSBlock(); + net.minecraft.server.IBlockData iblockdata = this.getNMS(); + net.minecraft.server.Block block = iblockdata.getBlock(); + net.minecraft.server.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); boolean result = false; - if (block != null && block != Blocks.AIR) { - net.minecraft.server.Block.dropItems(getNMS(), world.getMinecraftWorld(), position, world.getTileEntity(position), null, CraftItemStack.asNMSCopy(item)); + // Modelled off EntityHuman#hasBlock + if (block != Blocks.AIR && (iblockdata.getMaterial().isAlwaysDestroyable() || nmsItem.canDestroySpecialBlock(iblockdata))) { + net.minecraft.server.Block.dropItems(iblockdata, world.getMinecraftWorld(), position, world.getTileEntity(position), null, nmsItem); result = true; }