Skip to content

Commit

Permalink
BlockBreakEvent is only triggered in ServerWorld
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Sep 21, 2023
1 parent 9688027 commit 8b302c5
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
Expand All @@ -47,7 +48,7 @@ public class BlockEventDispatcher {
//For BlockBreakEvent
@SubscribeEvent(receiveCanceled = true)
public void onBreakBlockEvent(BlockEvent.BreakEvent event) {
if (!event.getWorld().isClientSide()) {
if (!event.getWorld().isClientSide() && event.getWorld() instanceof ServerWorld) {
CraftBlock craftBlock = CraftBlock.at(event.getWorld(), event.getPos());
BlockBreakEvent breakEvent = new BlockBreakEvent(craftBlock, ((ServerPlayerEntity) event.getPlayer()).getBukkitEntity());
breakEvent.setCancelled(event.isCanceled());
Expand Down

0 comments on commit 8b302c5

Please sign in to comment.