diff --git a/src/main/java/com/moulberry/axiom/packet/impl/SetBlockPacketListener.java b/src/main/java/com/moulberry/axiom/packet/impl/SetBlockPacketListener.java index 3141ea6..5a842c8 100644 --- a/src/main/java/com/moulberry/axiom/packet/impl/SetBlockPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/impl/SetBlockPacketListener.java @@ -137,21 +137,26 @@ public class SetBlockPacketListener implements PacketHandler { List blockStates = new ArrayList<>(); World world = player.serverLevel().getWorld(); for (Map.Entry entry : blocks.entrySet()) { - blockStates.add(new AxiomPlacingCraftBlockState(world, entry.getKey(), entry.getValue())); + BlockState existing = player.serverLevel().getBlockState(entry.getKey()); + if (existing.canBeReplaced()) { + blockStates.add(new AxiomPlacingCraftBlockState(world, entry.getKey(), entry.getValue())); + } } - Cancellable event = null; - if (blockStates.size() > 1) { - event = CraftEventFactory.callBlockMultiPlaceEvent(player.serverLevel(), - player, hand, blockStates, blockHit.getBlockPos().getX(), - blockHit.getBlockPos().getY(), blockHit.getBlockPos().getZ()); - } else if (blockStates.size() == 1) { - event = CraftEventFactory.callBlockPlaceEvent(player.serverLevel(), - player, hand, blockStates.get(0), blockHit.getBlockPos().getX(), - blockHit.getBlockPos().getY(), blockHit.getBlockPos().getZ()); - } - if (event != null && event.isCancelled()) { - return; + if (!blockStates.isEmpty()) { + Cancellable event; + if (blockStates.size() > 1) { + event = CraftEventFactory.callBlockMultiPlaceEvent(player.serverLevel(), + player, hand, blockStates, blockHit.getBlockPos().getX(), + blockHit.getBlockPos().getY(), blockHit.getBlockPos().getZ()); + } else { + event = CraftEventFactory.callBlockPlaceEvent(player.serverLevel(), + player, hand, blockStates.get(0), blockHit.getBlockPos().getX(), + blockHit.getBlockPos().getY(), blockHit.getBlockPos().getZ()); + } + if (event.isCancelled()) { + return; + } } }