PlayerInteractBlock
The PlayerInteractBlock Event is fired whenever a player right clicks a block.
It can be canceled to prevent any other events from taking place.
If the event is canceled, a specific result of success, fail or pass can be provided. By default, the result is pass.
Event Class
You will need to cast the event in the function header as this class:
crafttweaker.event.PlayerInteractBlockEvent
You can, of course, also import the class before and use that name then.
Event interface extensions
PlayerInteractBlock Events implement the following interfaces and are able to call all of their methods/getters/setters as well:
- IEventCancelable
- PlayerInteract
- IHasCancellationResult
ZenGetters/ZenSetters
The following information can be retrieved from the event:
ZenGetter | ZenSetter | Type |
---|---|---|
ZenGetter hitvector | ZenSetter | Type IVector3d |
ZenGetter useblock | ZenSetter useblock | Type string (“allow” / “deny” / “default”) |
ZenGetter useitem | ZenSetter useitem | Type string (“allow” / “deny” / “default”) |
ZenGetters/ZenSetters/ZenMethods from extensions
The following information can be retrieved from the event:
ZenGetter | ZenSetter | Type |
---|---|---|
ZenGetter cancellationResult | ZenSetter cancellationResult | Type string (“success” / “pass” / “fail”) |
ZenGetter world | ZenSetter | Type IWorld |
ZenGetter blockState | ZenSetter | Type IBlockState |
ZenGetter block | ZenSetter | Type IBlock |
ZenGetter face | ZenSetter | Type IFacing |
ZenGetter item | ZenSetter | Type IItemStack |
ZenGetter dimension | ZenSetter | Type int |
ZenGetter hand | ZenSetter | Type string |
ZenGetter player | ZenSetter | Type IPlayer |
ZenGetter canceled | ZenSetter canceled | Type bool |
ZenMethods
-
event.damageItem(int amount)
damages the item by the specified amount -
event.cancel();
Method, returns void (nothing). Can cancel the event and stop something from happening
From extension of extension
ZenGetter | ZenSetter | Type |
---|---|---|
ZenGetter player | ZenSetter | Type IPlayer |
ZenGetter position | ZenSetter | Type IBlockPos |
ZenGetter x | ZenSetter | Type int |
ZenGetter y | ZenSetter | Type int |
ZenGetter z | ZenSetter | Type int |
ZenGetter entityLivingBase | ZenSetter | Type IEntityLivingBase |
Notes
If you browse through the CT source directorys, this eventname is a exclusion to normal syntax.
Its found below PlayerRightClickBlockEvent
which got renamed in the file to playerInteractBlock