Skip to content

Commit

Permalink
Added back the drops for the main item
Browse files Browse the repository at this point in the history
  • Loading branch information
Sfiguz7 committed Dec 16, 2023
1 parent 88ac05f commit 9e96e76
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -224,7 +225,7 @@ private void callBlockHandler(BlockBreakEvent e, ItemStack item, List<ItemStack>
}

@ParametersAreNonnullByDefault
private void dropItems(BlockBreakEvent e, List<ItemStack> drops) {
private void dropItems(BlockBreakEvent e, ItemStack item, List<ItemStack> drops) {
if (!drops.isEmpty()) {
// TODO: properly support loading inventories within unit tests
if (!Slimefun.instance().isUnitTest()) {
Expand All @@ -237,10 +238,16 @@ private void dropItems(BlockBreakEvent e, List<ItemStack> 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);
}
}
}
Expand Down

0 comments on commit 9e96e76

Please sign in to comment.