The PlayerInteract Event is fired whenever a player interacts with a block.

You will need to cast the event in the function header as this class:
crafttweaker.event.PlayerInteractEvent
You can, of course, also import the class before and use that name then.

Event interface extensions

Link to event-interface-extensions

PlayerInteract Events implement the following interfaces and are able to call all of their methods/getters/setters as well:

The following information can be retrieved from the event:

ZenGetter返回值类型
ZenGetter
canceled
返回值类型
布尔值
ZenGetter
usingItem
返回值类型
布尔值
ZenGetter
usingBlock
返回值类型
布尔值
ZenGetter
x
返回值类型
int
ZenGetter
y
返回值类型
int
ZenGetter
z
返回值类型
int
ZenGetter
face
返回值类型
IFacing
ZenGetter
player
返回值类型
IPlayer
ZenGetter
world
返回值类型
IWorld
ZenGetter
block #方块
返回值类型
IBlock
ZenGetter
item
返回值类型
IItemstack
ZenGetter
dimension
返回值类型
int
  • event.cancel() sets the event as cancelled
  • event.useBlock() sets usingBlock to true
  • event.useItem() sets usingItem to true
  • event.damageItem(int amount) damages the item by the specified amount