Tool

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.api.item.component.Tool;

Description

Represents the tool properties of an item, including mining speed, damage per block, and rules for specific blocks. This class is used to define how a tool interacts with blocks in the game.

Members

Getter
Retrieves the amount of damage the tool takes per block mined.
script.zs
// Tool.damagePerBlock as int
myTool.damagePerBlock

Return Type: int

Getter
Retrieves the default mining speed of the tool when no specific rule applies.
script.zs
// Tool.defaultMiningSpeed as float
myTool.defaultMiningSpeed

Return Type: float

getMiningSpeed(state as BlockState) as float
Retrieves the mining speed of the tool for the given block state.

Returns: The mining speed of the tool for the given block state.

script.zs
// Tool.getMiningSpeed(state as BlockState) as float;
myTool.getMiningSpeed(myBlockState);

Parameters:

state Type: BlockState - The block state to check the mining speed for.

Return Type: float

isCorrectForDrops(state as BlockState) as bool
Checks if the tool is correct for harvesting drops from the given block state.

Returns: True if the tool is correct for harvesting drops, false otherwise.

script.zs
// Tool.isCorrectForDrops(state as BlockState) as bool;
myTool.isCorrectForDrops(myBlockState);

Parameters:

state Type: BlockState - The block state to check.

Return Type: bool

static of(rules as List<Rule>, defaultMiningSpeed as float, damagePerBlock as int) as Tool
Creates a new Tool instance with the specified rules, default mining speed, and damage per block.

Returns: A new Tool instance.

script.zs
// Tool.of(rules as List<ToolRule>, defaultMiningSpeed as float, damagePerBlock as int) as Tool;
Tool.of(myList, myFloat, myInt);

Parameters:

rules Type: List<ToolRule> - The list of rules that define how the tool interacts with specific blocks.
defaultMiningSpeed Type: float - The default mining speed of the tool when no specific rule applies.
damagePerBlock Type: int - The amount of damage the tool takes per block mined.

Return Type: Tool

Getter
Retrieves the list of rules that define how the tool interacts with specific blocks.
script.zs
// Tool.rules as List<ToolRule>
myTool.rules

Return Type: List<ToolRule>