pub struct Tool {
pub rules: Vec<ToolRule>,
pub default_mining_speed: f32,
pub damage_per_block: i32,
pub can_destroy_blocks_in_creative: bool,
}Expand description
The tool component data - defines mining speed and drop behavior for blocks.
Fields§
§rules: Vec<ToolRule>Rules evaluated in order to determine mining speed and drop behavior.
default_mining_speed: f32Default mining speed when no rule matches.
damage_per_block: i32Damage to apply to the item per block mined.
can_destroy_blocks_in_creative: boolWhether the tool can destroy blocks in creative mode.
Implementations§
Source§impl Tool
impl Tool
Sourcepub fn get_mining_speed(&self, block_state_id: BlockStateId) -> f32
pub fn get_mining_speed(&self, block_state_id: BlockStateId) -> f32
Returns the mining speed for a block state.
Evaluates rules in order; returns the first matching rule’s speed,
or default_mining_speed if no rule matches.
Sourcepub fn is_correct_for_drops(&self, block_state_id: BlockStateId) -> bool
pub fn is_correct_for_drops(&self, block_state_id: BlockStateId) -> bool
Returns true if this tool is “correct” for getting drops from the block.
Evaluates rules in order; returns the first matching rule’s correct_for_drops,
or false if no rule explicitly matches.
Trait Implementations§
Source§impl Component for Tool
impl Component for Tool
Source§fn into_data(self) -> ComponentData
fn into_data(self) -> ComponentData
Converts this component value into
ComponentData.Source§fn from_data(data: ComponentData) -> Option<Self>
fn from_data(data: ComponentData) -> Option<Self>
Attempts to extract this component type from
ComponentData.
Returns None if the data is a different variant.Source§fn from_data_ref(data: &ComponentData) -> Option<&Self>
fn from_data_ref(data: &ComponentData) -> Option<&Self>
Attempts to get a reference to this component type from
ComponentData.
Returns None if the data is a different variant or if the type
cannot be referenced directly (e.g., needs conversion).Source§impl FromNbtTag for Tool
impl FromNbtTag for Tool
fn from_nbt_tag(tag: NbtTag<'_, '_>) -> Option<Self>
fn from_optional_nbt_tag( tag: Option<NbtTag<'_, '_>>, ) -> Result<Option<Self>, DeserializeError>
Source§impl HashComponent for Tool
impl HashComponent for Tool
Source§fn hash_component(&self, hasher: &mut ComponentHasher)
fn hash_component(&self, hasher: &mut ComponentHasher)
Hashes this value into the given hasher.
Source§fn compute_hash(&self) -> i32
fn compute_hash(&self) -> i32
Computes the hash of this value.
impl StructuralPartialEq for Tool
Source§impl ToNbtTag for Tool
impl ToNbtTag for Tool
fn to_nbt_tag(self) -> NbtTag
fn to_optional_nbt_tag(self) -> Option<NbtTag>
Auto Trait Implementations§
impl Freeze for Tool
impl RefUnwindSafe for Tool
impl Send for Tool
impl Sync for Tool
impl Unpin for Tool
impl UnsafeUnpin for Tool
impl UnwindSafe for Tool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more