PlayerAnvilUpdate
The PlayerAnvilUpdate Event is fired when a player places items in both the left and right slots of a anvil.
- If the event is canceled, vanilla behavior will not run, and the output will be set to null.
- If the event is not canceled, but the output is not null, it will set the output and not run vanilla behavior.
- if the output is null, and the event is not canceled, vanilla behavior will execute.
Event Class
You will need to cast the event in the function header as this class:
crafttweaker.event.PlayerAnvilUpdateEvent
You can, of course, also import the class before and use that name then.
Event interface extensions
PlayerAnvilUpdate Events implement the following interfaces and are able to call all of their methods/getters/setters as well:
ZenGetters & ZenSetters
The following information can be retrieved from the event:
ZenGetter | ZenSetter | type | Description |
---|---|---|---|
ZenGetter leftItem | ZenSetter | type IItemStack | Description The left side of the input. |
ZenGetter rightItem | ZenSetter | type IItemStack | Description The right side of the input. |
ZenGetter outputItem | ZenSetter outputItem | type IItemStack | Description Set this to set the output stack. |
ZenGetter itemName | ZenSetter | type string | Description The name to set the item, if the user specified one. |
ZenGetter xpCost | ZenSetter xpCost | type int | Description The base cost, set this to change it if output != null. |
ZenGetter materialCost | ZenSetter materialCost | type int | Description The number of items from the right slot to be consumed during the repair. Leave as 0 to consume the entire stack. |
ZenGetters/ZenSetters/ZenMethods from extensions
The following information can be retrieved/set during the event:
ZenGetter | ZenSetter | Type |
---|---|---|
ZenGetter canceled | ZenSetter canceled | Type bool |
ZenMethods
event.cancel();
Method, returns void (nothing). Can cancel the event and stop something from happening