BlockToolModificationEvent

Fired when this block is right clicked by a tool to change its state. For example: Used to determine if an axe can strip a log, a shovel can turn grass into a path, or a hoe can till dirt into farmland.

The event is cancelable.

If the event is canceled, this will prevent the tool from changing the block’s state.

The event does not have a result.

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

script.zs
import crafttweaker.api.event.block.BlockToolModificationEvent;

Extending BlockEvent

BlockToolModificationEvent extends BlockEvent. That means all methods available in BlockEvent are also available in BlockToolModificationEvent

Methods

Gets the transformed state after tool use. If setFinalState is not called, it will return the original state. This will be bypassed if canceled, returning null instead.

Return Type: BlockState?

script.zs
// BlockToolModificationEvent.getFinalState() as BlockState?
myBlockToolModificationEvent.getFinalState();

Return Type: IItemStack

script.zs
// BlockToolModificationEvent.getHeldItemStack() as IItemStack
myBlockToolModificationEvent.getHeldItemStack();

Return Type: Player

script.zs
// BlockToolModificationEvent.getPlayer() as Player
myBlockToolModificationEvent.getPlayer();

Return Type: ToolAction

script.zs
// BlockToolModificationEvent.getToolType() as ToolAction
myBlockToolModificationEvent.getToolType();

Return Type: boolean

script.zs
// BlockToolModificationEvent.isSimulated() as boolean
myBlockToolModificationEvent.isSimulated();

Sets the transformed state after tool use. If not set, will return the original state. This will be bypassed if canceled, returning null instead.

script.zs
BlockToolModificationEvent.setFinalState(state as BlockState)
ParameterType
Parameter
state
Type
BlockState

Properties

NameTypeHas GetterHas SetterDescription
Name
finalState
Type
BlockState?
Has Getter
true
Has Setter
true
Description
Gets the transformed state after tool use.
If setFinalState is not called, it will return the original state.
This will be bypassed if canceled, returning null instead.
Name
heldItemStack
Type
IItemStack
Has Getter
true
Has Setter
false
Description
Name
player
Type
Player
Has Getter
true
Has Setter
false
Description
Name
simulated
Type
boolean
Has Getter
true
Has Setter
false
Description
Name
toolAction
Type
ToolAction
Has Getter
true
Has Setter
false
Description