From bb06b24af3efcb83163da84924f6ed766a6a0305 Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Sat, 30 Nov 2024 14:03:55 -0600 Subject: [PATCH] Added playerWillDestroy call to WorldUtil.breakExtraBlock --- .../actuallyadditions/mod/util/WorldUtil.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java index 0c58c8ed6..acce2c825 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java @@ -287,10 +287,11 @@ public final class WorldUtil { * @return If the break was successful. */ public static boolean breakExtraBlock(ItemStack stack, Level level, Player player, BlockPos pos) { - BlockState state = level.getBlockState(pos); - Block block = state.getBlock(); + if (player.isCreative()) { + BlockState state = level.getBlockState(pos); + Block block = state.getBlock(); if (block.onDestroyedByPlayer(state, level, pos, player, false, state.getFluidState())) { block.destroy(level, pos, state); } @@ -302,6 +303,14 @@ public final class WorldUtil { return true; } + BlockState tempstate = level.getBlockState(pos); + BlockState state = tempstate.getBlock().playerWillDestroy(level, pos, tempstate, player); + Block block = state.getBlock(); + + if (state.isAir()) { + return false; + } + // callback to the tool the player uses. Called on both sides. This damages the tool n stuff. stack.mineBlock(level, state, pos, player);