LeftClickBlockEvent

Link to leftclickblockevent

This event is fired when a player left clicks while targeting a block. This event controls which of Block#attack(BlockState, Level, BlockPos, Player) and/or the item harvesting methods will be called.

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.

The event is cancelable.

If the event is canceled, none of the above noted methods to be called.

The event does not have a result.

Importing the class

Link to importing-the-class

Importing the class is recommended for events, simply add this line to the top of your script file.

ZenScript
Copy
import crafttweaker.neoforge.api.event.interact.LeftClickBlockEvent;

Listening to the event

Link to listening-to-the-event

ZenScript
Copy
events.register<crafttweaker.neoforge.api.event.interact.LeftClickBlockEvent>(event => {
    println("LeftClickBlockEvent ran!");
});

LeftClickBlockEvent extends PlayerInteractEvent. That means all methods available in PlayerInteractEvent are also available in LeftClickBlockEvent

Implemented Interfaces

Link to implemented-interfaces

LeftClickBlockEvent implements the following interfaces. That means all methods defined in these interfaces are also available in LeftClickBlockEvent

NameTypeHas GetterHas Setter
Name
useBlock
Type
EventResult
Has Getter
true
Has Setter
true
Name
useItem
Type
EventResult
Has Getter
true
Has Setter
true