RightClickItemEvent

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.player.interact.RightClickItemEvent;

Description

The rightClickItem event is fired whenever the player right clicks with an item in their hand. It does not offer any special getters, but you can still access all members from PlayerInteractEvent
canceled Item#onItemRightClick will not be called

Extends

RightClickItemEvent extends PlayerInteractEvent.

Listening to the event

This event can be listened to like so:

script.zs
events.register<crafttweaker.forge.api.player.interact.RightClickItemEvent>(event => {
println("RightClickItemEvent 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
// RightClickItem.blockPos as BlockPos
event.blockPos

Return Type: BlockPos

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

Return Type: bool

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

Return Type: bool

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

Return Type: bool

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

Parameters:

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

Return Type: bool

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

Parameters:

cancel Type: bool
Getter
script.zs
// RightClickItem.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
// RightClickItem.cancellationResult = (result as InteractionResult);
event.cancellationResult = myInteractionResult;

Parameters:

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

Return Type: Player

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

Return Type: LivingEntity

Getter
script.zs
// RightClickItem.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
// RightClickItem.face as Direction
event.face

Return Type: Direction

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

Return Type: InteractionHand

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

Return Type: bool

hasResult() as bool
script.zs
// RightClickItem.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
// RightClickItem.itemStack as IItemStack
event.itemStack

Return Type: IItemStack

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

Return Type: EventResult

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

Parameters:

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

Return Type: EventResult

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

Parameters:

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