From 9e96e764b42b6fda03515eac94caecb800c7ad55 Mon Sep 17 00:00:00 2001 From: Alessio Colombo Date: Sat, 16 Dec 2023 18:08:05 +0100 Subject: [PATCH] Added back the drops for the main item --- .../implementation/listeners/BlockListener.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 91fb9eb291..f4fe92c92b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -15,6 +15,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; +import org.bukkit.block.Container; import org.bukkit.block.data.BlockData; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -174,7 +175,7 @@ public void onBlockBreak(BlockBreakEvent e) { callBlockHandler(e, item, drops, sfItem); - dropItems(e, drops); + dropItems(e, item, drops); // Checks for vanilla sensitive blocks everywhere checkForSensitiveBlocks(e.getBlock(), 0, e.isDropItems()); @@ -224,7 +225,7 @@ private void callBlockHandler(BlockBreakEvent e, ItemStack item, List } @ParametersAreNonnullByDefault - private void dropItems(BlockBreakEvent e, List drops) { + private void dropItems(BlockBreakEvent e, ItemStack item, List drops) { if (!drops.isEmpty()) { // TODO: properly support loading inventories within unit tests if (!Slimefun.instance().isUnitTest()) { @@ -237,10 +238,16 @@ private void dropItems(BlockBreakEvent e, List drops) { // Disable normal block drops e.setDropItems(false); + // Fixes #4051 + Block b = e.getBlock(); + if (BlockStorage.check(b) == null) { + b.breakNaturally(item); + } + for (ItemStack drop : drops) { // Prevent null or air from being dropped if (drop != null && drop.getType() != Material.AIR) { - e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), drop); + b.getWorld().dropItemNaturally(b.getLocation(), drop); } } }