LeftClickEmptyEvent

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.forge.api.event.interact.LeftClickEmptyEvent;

Description

This event is fired when a player left clicks while targeting a block. This event controls which of 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.
canceled none of the above noted methods to be called.

Extends

LeftClickEmptyEvent extends PlayerInteractEvent.

Listening to the event

This event can be listened to like so:

script.zs
events.register<crafttweaker.forge.api.event.interact.LeftClickEmptyEvent>(event => {
println("LeftClickEmptyEvent ran!");
});

Members

Getter
If the interaction was on an entity, will be a BlockPos centered on the entity. If the interaction was on a block, will be the position of that block. Otherwise, will be a BlockPos centered on the player.
script.zs
// LeftClickEmpty.blockPos as BlockPos
event.blockPos

Return Type: BlockPos

cancel()
Cancels the event. Same as setCanceled(true)
script.zs
// LeftClickEmpty.cancel();
event.cancel();
Getter
script.zs
// LeftClickEmpty.cancelable as bool
event.cancelable

Return Type: bool

cancelable() as bool
script.zs
// LeftClickEmpty.cancelable() as bool;
event.cancelable();

Return Type: bool

Getter
script.zs
// LeftClickEmpty.canceled as bool
event.canceled

Return Type: bool

Setter
script.zs
// LeftClickEmpty.canceled = (cancel as bool);
event.canceled = myBool;

Parameters:

cancel Type: bool
canceled() as bool
script.zs
// LeftClickEmpty.canceled() as bool;
event.canceled();

Return Type: bool

canceled(cancel as bool)
script.zs
// LeftClickEmpty.canceled(cancel as bool);
event.canceled(myBool);

Parameters:

cancel Type: bool
Getter
script.zs
// LeftClickEmpty.cancellationResult as InteractionResult
event.cancellationResult

Return Type: InteractionResult

Setter
Set the EnumActionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant method of the event.
Note that this only has an effect on RightClickBlockEvent, RightClickItemEvent, EntityInteractEvent.
script.zs
// LeftClickEmpty.cancellationResult = (result as InteractionResult);
event.cancellationResult = myInteractionResult;

Parameters:

Getter
script.zs
// LeftClickEmpty.entity as Player
event.entity

Return Type: Player

Getter
script.zs
// LeftClickEmpty.entity as LivingEntity
event.entity

Return Type: LivingEntity

Getter
script.zs
// LeftClickEmpty.entity as Entity
event.entity

Return Type: Entity

Getter
The face involved in this interaction. For all non-block interactions, this will return null
script.zs
// LeftClickEmpty.face as Direction
event.face

Return Type: Direction

Getter
script.zs
// LeftClickEmpty.hand as InteractionHand
event.hand

Return Type: InteractionHand

Getter
script.zs
// LeftClickEmpty.hasResult as bool
event.hasResult

Return Type: bool

hasResult() as bool
script.zs
// LeftClickEmpty.hasResult() as bool;
event.hasResult();

Return Type: bool

Getter
The stack involved in this interaction. May be empty, but will never be null.
script.zs
// LeftClickEmpty.itemStack as IItemStack
event.itemStack

Return Type: IItemStack

Getter
script.zs
// LeftClickEmpty.result as Result
event.result

Return Type: EventResult

Setter
script.zs
// LeftClickEmpty.result = (result as Result);
event.result = myResult;

Parameters:

result Type: EventResult
result() as Result
script.zs
// LeftClickEmpty.result() as Result;
event.result();

Return Type: EventResult

result(result as Result)
script.zs
// LeftClickEmpty.result(result as Result);
event.result(myResult);

Parameters:

result Type: EventResult
setAllow()
sets the event's result to allow
script.zs
// LeftClickEmpty.setAllow();
event.setAllow();
setDefault()
sets the event's result to default
script.zs
// LeftClickEmpty.setDefault();
event.setDefault();
setDeny()
sets the event's result to deny
script.zs
// LeftClickEmpty.setDeny();
event.setDeny();