Class PlayerInteractEvent.LeftClickBlock

All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
Enclosing class:
PlayerInteractEvent

public static class PlayerInteractEvent.LeftClickBlock extends PlayerInteractEvent implements net.neoforged.bus.api.ICancellableEvent
This event is fired when a player left clicks while targeting a block. This event controls which of BlockBehaviour.attack(BlockState, Level, BlockPos, Player) and/or the item harvesting methods will be called Canceling the event will cause none of the above noted methods to be called. There are various results to this event, see the getters below. This event is fired at various points during left clicking on blocks, at both the start and end on the server, and at the start and while held down on the client. Use getAction() to check which type of action triggered this event. Note that if the event is canceled and the player holds down left mouse, the event will continue to fire. This is due to how vanilla calls the left click handler methods. Also note that creative mode directly breaks the block without running any other logic. Therefore, in creative mode, setUseBlock(net.neoforged.neoforge.common.util.TriState) and setUseItem(net.neoforged.neoforge.common.util.TriState) have no effect.