Added playerWillDestroy call to WorldUtil.breakExtraBlock

This commit is contained in:
Flanks255 2024-11-30 14:03:55 -06:00
parent d0f8c24a6d
commit bb06b24af3

View file

@ -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);