pub struct ToolRule {
pub blocks: Vec<Identifier>,
pub speed: Option<f32>,
pub correct_for_drops: Option<bool>,
}Expand description
A single rule within a Tool component. Rules are evaluated in order; the first matching rule determines the speed/drop behavior.
Fields§
§blocks: Vec<Identifier>The blocks this rule applies to (can be a tag like “#minecraft:mineable/pickaxe”, a single block like “minecraft:cobweb”, or a list of blocks).
speed: Option<f32>The mining speed for these blocks. If None, uses the tool’s default_mining_speed.
correct_for_drops: Option<bool>Whether the tool is “correct” for dropping items from these blocks. If None, falls back to the block’s requiresCorrectToolForDrops property.
Implementations§
Source§impl ToolRule
impl ToolRule
Sourcepub fn mines_and_drops(blocks: Vec<Identifier>, speed: f32) -> Self
pub fn mines_and_drops(blocks: Vec<Identifier>, speed: f32) -> Self
Creates a rule that sets both mining speed and marks the tool as correct for drops.
Sourcepub fn denies_drops(blocks: Vec<Identifier>) -> Self
pub fn denies_drops(blocks: Vec<Identifier>) -> Self
Creates a rule that explicitly denies drops (e.g., incorrect tool tier).
Sourcepub fn override_speed(blocks: Vec<Identifier>, speed: f32) -> Self
pub fn override_speed(blocks: Vec<Identifier>, speed: f32) -> Self
Creates a rule that only overrides the mining speed.
Sourcepub fn matches_block(&self, block_state_id: BlockStateId) -> bool
pub fn matches_block(&self, block_state_id: BlockStateId) -> bool
Checks if this rule matches a block state. Handles both direct block identifiers and block tags (prefixed with #).