Class BlockEvent.BreakEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.level.BlockEvent
net.neoforged.neoforge.event.level.BlockEvent.BreakEvent
All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
Enclosing class:
BlockEvent

public static class BlockEvent.BreakEvent extends BlockEvent implements net.neoforged.bus.api.ICancellableEvent
This event is fired on the server when a player attempts to break a block, upon receipt of a block break packet. The following conditions may cause this event to fire in a cancelled state: In the first two cases, un-cancelling the event will not permit the block to be broken. In the third case, un-cancelling will allow the break, bypassing the behavior of Item.canAttackBlock(net.minecraft.world.level.block.state.BlockState, net.minecraft.world.level.Level, net.minecraft.core.BlockPos, net.minecraft.world.entity.player.Player).
  • Field Details

    • player

      private final Player player
  • Constructor Details

  • Method Details

    • getPlayer

      public Player getPlayer()
      Returns the player who is attempting to break the block.
      Returns:
      the player who is attempting to break the block
    • setCanceled

      public void setCanceled(boolean canceled)
      Cancelling this event will prevent the block from being broken, and notifies the client of the refusal.
      Specified by:
      setCanceled in interface net.neoforged.bus.api.ICancellableEvent