Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Explosive pickaxe not properly dropping blocks #4062

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
WalshyDev marked this conversation as resolved.
Show resolved Hide resolved
import org.bukkit.block.data.BlockData;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -147,7 +148,8 @@ public void onBlockBreak(BlockBreakEvent e) {
}

ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
SlimefunItem sfItem = BlockStorage.check(e.getBlock());
Block b = e.getBlock();
SlimefunItem sfItem = BlockStorage.check(b);

// If there is a Slimefun Block here, call our BreakEvent and, if cancelled, cancel this event and return
if (sfItem != null) {
Expand All @@ -174,7 +176,7 @@ public void onBlockBreak(BlockBreakEvent e) {

callBlockHandler(e, item, drops, sfItem);

dropItems(e, drops);
dropItems(e, item, b, sfItem==null, drops);

// Checks for vanilla sensitive blocks everywhere
checkForSensitiveBlocks(e.getBlock(), 0, e.isDropItems());
Expand Down Expand Up @@ -224,7 +226,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, Block b, boolean isBlockstorageNull, List<ItemStack> drops) {
if (!drops.isEmpty()) {
// TODO: properly support loading inventories within unit tests
if (!Slimefun.instance().isUnitTest()) {
Expand All @@ -237,10 +239,15 @@ private void dropItems(BlockBreakEvent e, List<ItemStack> drops) {
// Disable normal block drops
e.setDropItems(false);

// Fixes #4051
if (isBlockstorageNull) {
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);
Sfiguz7 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
Loading