BlockToolModificationEvent
Link to blocktoolmodificationevent
Fired when this block is interacted with 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.
导入类
Link to 导入类
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.
ZenScript Copyimport crafttweaker.api.event.block.BlockToolModificationEvent;
Extending BlockEvent
Link to extending-blockevent
BlockToolModificationEvent extends BlockEvent. That means all methods available in BlockEvent are also available in BlockToolModificationEvent
使用方式
Link to 使用方式
Name: getFinalState
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?
ZenScript Copy// BlockToolModificationEvent.getFinalState() as BlockState?
myBlockToolModificationEvent.getFinalState();
Name: getHeldItemStack
Return Type: IItemStack
ZenScript Copy// BlockToolModificationEvent.getHeldItemStack() as IItemStack
myBlockToolModificationEvent.getHeldItemStack();
Name: getPlayer
Return Type: Player
ZenScript Copy// BlockToolModificationEvent.getPlayer() as Player
myBlockToolModificationEvent.getPlayer();
Name: getToolType
Return Type: ToolAction
ZenScript Copy// BlockToolModificationEvent.getToolType() as ToolAction
myBlockToolModificationEvent.getToolType();
Name: setFinalState
Sets the transformed state after tool use. If not set, will return the original state. This will be bypassed if canceled, returning null instead.
ZenScript CopyBlockToolModificationEvent.setFinalState(state as BlockState)
参数 | 类型 |
---|---|
参数 state | 类型 BlockState |
名称 | 类型 | 可获得 | 可设置 | 描述 |
---|---|---|---|---|
名称 finalState | 类型 BlockState? | 可获得 true | 可设置 true | 描述 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. |
名称 heldItemStack | 类型 IItemstack | 可获得 true | 可设置 false | 描述 |
名称 player | 类型 Player | 可获得 true | 可设置 false | 描述 |
名称 toolAction | 类型 ToolAction | 可获得 true | 可设置 false | 描述 |