pub struct ToolRule {
pub blocks: ToolRuleBlocks,
pub speed: Option<f32>,
pub correct_for_drops: Option<bool>,
}Expand description
A single rule within a tool component.
Fields§
§blocks: ToolRuleBlocksBlocks to which this rule applies.
speed: Option<f32>Mining speed, or the tool’s default speed when absent.
correct_for_drops: Option<bool>Whether matching blocks drop items, when explicitly specified.
Implementations§
Source§impl ToolRule
impl ToolRule
Sourcepub const fn mines_and_drops(blocks: ToolRuleBlocks, speed: f32) -> Self
pub const fn mines_and_drops(blocks: ToolRuleBlocks, speed: f32) -> Self
Creates a rule that sets both mining speed and correct-tool behavior.
Sourcepub const fn denies_drops(blocks: ToolRuleBlocks) -> Self
pub const fn denies_drops(blocks: ToolRuleBlocks) -> Self
Creates a rule that explicitly denies drops.
Sourcepub const fn override_speed(blocks: ToolRuleBlocks, speed: f32) -> Self
pub const fn override_speed(blocks: ToolRuleBlocks, speed: f32) -> Self
Creates a rule that only overrides mining speed.
Sourcepub fn matches_block(&self, block_state_id: BlockStateId) -> bool
pub fn matches_block(&self, block_state_id: BlockStateId) -> bool
Returns whether this rule matches a block state.
Source§impl ToolRule
impl ToolRule
fn into_nbt_compound(self) -> NbtCompound
fn from_nbt_compound(compound: NbtCompound<'_, '_>) -> Option<Self>
Trait Implementations§
Source§impl FromNbtTag for ToolRule
impl FromNbtTag for ToolRule
fn from_nbt_tag(tag: NbtTag<'_, '_>) -> Option<Self>
fn from_optional_nbt_tag( tag: Option<NbtTag<'_, '_>>, ) -> Result<Option<Self>, DeserializeError>
Source§impl HashComponent for ToolRule
impl HashComponent for ToolRule
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 ToolRule
Source§impl ToNbtTag for ToolRule
impl ToNbtTag for ToolRule
fn to_nbt_tag(self) -> NbtTag
fn to_optional_nbt_tag(self) -> Option<NbtTag>
Auto Trait Implementations§
impl !RefUnwindSafe for ToolRule
impl !UnwindSafe for ToolRule
impl Freeze for ToolRule
impl Send for ToolRule
impl Sync for ToolRule
impl Unpin for ToolRule
impl UnsafeUnpin for ToolRule
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreWraps this value in an
Arc<SyncMutex<>>