From 165eb39714a0f4e94ebfc8c3df6f6844aaac7bb5 Mon Sep 17 00:00:00 2001 From: Rosenthalk0 Date: Tue, 25 Oct 2022 14:53:24 -0500 Subject: [PATCH] #1025 - Fix Custom Block Drop / Breaking Power Bug --- .../listener/CustomBlockListener.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/CustomBlockListener.java b/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/CustomBlockListener.java index 4e1eba7c..4772ae2f 100644 --- a/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/CustomBlockListener.java +++ b/MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/CustomBlockListener.java @@ -51,20 +51,34 @@ public class CustomBlockListener implements Listener { CustomBlock block = opt.get(); final int power = MMOUtils.getPickaxePower(event.getPlayer()); - - if(block.requirePowerToBreak() && power < block.getRequiredPower()) { - event.setCancelled(true); - return; + + if ( block.requirePowerToBreak() && block.getRequiredPower()>0 ){ + if (power < block.getRequiredPower()) { + event.setCancelled(true); + return; + } + else if (power >= block.getRequiredPower()) { + event.setDropItems(false); + event.setExpToDrop(event.getPlayer().getGameMode() == GameMode.CREATIVE ? 0 + : MMOUtils.getPickaxePower(event.getPlayer()) >= block.getRequiredPower() + ? block.getMaxExpDrop() == 0 && block.getMinExpDrop() == 0 ? 0 + : RANDOM.nextInt((block.getMaxExpDrop() - block.getMinExpDrop()) + 1) + block.getMinExpDrop() + : 0); + return; + } + event.setCancelled(true); + return; } - + event.setDropItems(false); event.setExpToDrop(event.getPlayer().getGameMode() == GameMode.CREATIVE ? 0 : MMOUtils.getPickaxePower(event.getPlayer()) >= block.getRequiredPower() - ? block.getMaxExpDrop() == 0 && block.getMinExpDrop() == 0 ? 0 - : RANDOM.nextInt((block.getMaxExpDrop() - block.getMinExpDrop()) + 1) + block.getMinExpDrop() - : 0); + ? block.getMaxExpDrop() == 0 && block.getMinExpDrop() == 0 ? 0 + : RANDOM.nextInt((block.getMaxExpDrop() - block.getMinExpDrop()) + 1) + block.getMinExpDrop() + : 0); } + @Deprecated private static int getPickaxePower(Player player) { return MMOUtils.getPickaxePower(player);