@@ -51,22 +51,23 @@ public void onPacketPlayReceive(PacketPlayReceiveEvent event) {
5151
5252 // Check if block is breakable, if not, send block change packet to cancel the break
5353 if (!view .isBreakable ()) {
54- player . sendBlockChange ( position . toLocation ( player . getWorld ()), blockData );
54+ event . setCancelled ( true );
5555 return ;
5656 }
5757
5858 // Block break functionality
5959 if (actionType == DiggingAction .FINISHED_DIGGING || canInstantBreak (player , blockData )) {
6060 Bukkit .getScheduler ().runTask (Blockify .getInstance (), () -> {
61+ // Set block to air
62+ view .setBlock (position , Material .AIR .createBlockData ());
63+ Blockify .getInstance ().getBlockChangeManager ().sendBlockChange (view .getStage (), view .getStage ().getAudience (), position );
6164 // Call BlockifyBreakEvent
6265 BlockifyBreakEvent blockifyBreakEvent = new BlockifyBreakEvent (player , position , blockData , view , view .getStage ());
6366 blockifyBreakEvent .callEvent ();
6467 // If block is not cancelled, break the block, otherwise, revert the block
65- if (!blockifyBreakEvent .isCancelled ()) {
66- view .setBlock (position , Material .AIR .createBlockData ());
67- Blockify .getInstance ().getBlockChangeManager ().sendBlockChange (view .getStage (), view .getStage ().getAudience (), position );
68- } else {
68+ if (blockifyBreakEvent .isCancelled ()) {
6969 player .sendBlockChange (position .toLocation (player .getWorld ()), blockData );
70+ view .setBlock (position , blockData );
7071 }
7172 });
7273 }
0 commit comments