ToolRule

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.ToolRule;

Description

Represents a rule that defines how a tool interacts with specific blocks. Rules can override mining speed, determine if the tool is correct for harvesting drops, and more.

Members

Getter
Retrieves the list of blocks that this rule applies to.
script.zs
// Rule.blocks as List<Block>
myRule.blocks

Return Type: List<Block>

Getter
Retrieves whether the tool is correct for harvesting drops according to this rule. Throws an exception if the rule does not define this value.
IllegalStateException If the rule does not have a value for 'correctToolForDrops'.
script.zs
// Rule.correctToolForDrops as bool
myRule.correctToolForDrops

Return Type: bool

static deniesDrops(tag as KnownTag<Block>) as Rule
Creates a new rule that denies drops for blocks matching the specified tag.

Returns: A new Tool.Rule instance.

script.zs
// Rule.deniesDrops(tag as KnownTag<Block>) as ToolRule;
ToolRule.deniesDrops(myKnownTag);

Parameters:

tag Type: KnownTag<Block> - The tag identifying the blocks this rule applies to.

Return Type: ToolRule

Getter
Checks if this rule defines whether the tool is correct for harvesting drops.
script.zs
// Rule.hasCorrectToolForDrops as bool
myRule.hasCorrectToolForDrops

Return Type: bool

static minesAndDrops(tag as KnownTag<Block>, speed as float) as Rule
Creates a new rule that allows mining and harvesting drops for blocks matching the specified tag.

Returns: A new Tool.Rule instance.

script.zs
// Rule.minesAndDrops(tag as KnownTag<Block>, speed as float) as ToolRule;
ToolRule.minesAndDrops(myKnownTag, myFloat);

Parameters:

tag Type: KnownTag<Block> - The tag identifying the blocks this rule applies to.
speed Type: float - The mining speed override.

Return Type: ToolRule

static minesAndDrops(blocks as List<Block>, speed as float) as Rule
Creates a new rule that allows mining and harvesting drops for the specified blocks.

Returns: A new Tool.Rule instance.

script.zs
// Rule.minesAndDrops(blocks as List<Block>, speed as float) as ToolRule;
ToolRule.minesAndDrops(myList, myFloat);

Parameters:

blocks Type: List<Block> - The list of blocks this rule applies to.
speed Type: float - The mining speed override.

Return Type: ToolRule

static overrideSpeed(blocks as List<Block>, speed as float) as Rule
Creates a new rule that overrides the mining speed for the specified blocks.

Returns: A new Tool.Rule instance.

script.zs
// Rule.overrideSpeed(blocks as List<Block>, speed as float) as ToolRule;
ToolRule.overrideSpeed(myList, myFloat);

Parameters:

blocks Type: List<Block> - The list of blocks this rule applies to.
speed Type: float - The mining speed override.

Return Type: ToolRule

static overrideSpeed(tag as KnownTag<Block>, speed as float) as Rule
Creates a new rule that overrides the mining speed for blocks matching the specified tag.

Returns: A new Tool.Rule instance.

script.zs
// Rule.overrideSpeed(tag as KnownTag<Block>, speed as float) as ToolRule;
ToolRule.overrideSpeed(myKnownTag, myFloat);

Parameters:

tag Type: KnownTag<Block> - The tag identifying the blocks this rule applies to.
speed Type: float - The mining speed override.

Return Type: ToolRule

Getter
Retrieves the mining speed override defined by this rule, if any.
script.zs
// Rule.speed as Float
myRule.speed

Return Type: Float