pub struct ToolMaterial {
pub id: String,
pub durability: u32,
pub speed: f32,
pub attack_damage: f32,
pub enchantability: u32,
pub level: String,
pub repair: String,
pub level_index: u32,
pub incorrect: String,
pub game_tools: String,
}Expand description
What tools are made of. The game’s are built in
(ToolMaterial::built_ins); a mod declares its own in a .ydef
(kind: "tool_material") or registers one
(Registry::register_tool_material).
Fields§
§id: String§durability: u32Uses before it breaks.
speed: f32How fast it mines (wood 2 … netherite 9, gold 12).
attack_damage: f32Attack damage it adds (wood 0 … netherite 4).
enchantability: u32§level: StringIts level on the tool ladder (minecraft:iron, mymod:mythril).
repair: StringWhat repairs it: an item id or #tag.
level_index: u32Minecraft 1.20’s level number of level (wood 0 … netherite 4).
incorrect: StringMinecraft 1.21’s tag of the blocks a tool of it can’t mine for
drops (minecraft:incorrect_for_iron_tool).
game_tools: StringWhat the game’s tools of it are named by (wooden_: minecraft:wooden_axe);
empty for a mod’s own.
Implementations§
Source§impl ToolMaterial
impl ToolMaterial
Sourcepub fn built_ins() -> &'static [ToolMaterial]
pub fn built_ins() -> &'static [ToolMaterial]
The game’s materials: wood, stone, iron, diamond, gold, netherite.
Sourcepub fn built_in(name: &str) -> Option<&'static ToolMaterial>
pub fn built_in(name: &str) -> Option<&'static ToolMaterial>
One of the game’s, by short name or id.
Sourcepub fn like(id: impl Into<String>, like: &str) -> Option<ToolMaterial>
pub fn like(id: impl Into<String>, like: &str) -> Option<ToolMaterial>
id with like’s level (one of the game’s: iron), durability,
speed, damage, enchantability and repair — change what differs.
Sourcepub fn game_tool(&self, kind: &str) -> Option<GameTool>
pub fn game_tool(&self, kind: &str) -> Option<GameTool>
The game’s tool of kind (a mod’s kind: REFERENCE_KIND) made of
this material, or — a mod’s — of REFERENCE_MATERIAL.
Trait Implementations§
Source§impl Clone for ToolMaterial
impl Clone for ToolMaterial
Source§fn clone(&self) -> ToolMaterial
fn clone(&self) -> ToolMaterial
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolMaterial
impl Debug for ToolMaterial
Source§impl PartialEq for ToolMaterial
impl PartialEq for ToolMaterial
Source§impl Schema for ToolMaterial
impl Schema for ToolMaterial
Source§fn encode(&self, __yog_w: &mut Writer)
fn encode(&self, __yog_w: &mut Writer)
Schema::write’s
value encoded, unless the type knows better (derived ones do).Source§fn decode(__yog_d: &mut Decoder<'_>) -> Option<ToolMaterial>
fn decode(__yog_d: &mut Decoder<'_>) -> Option<ToolMaterial>
None when it isn’t
what Schema::encode writes — then read_bytes reads the slow
way, which says what’s wrong. Through a value unless the type knows
better (derived ones do).Source§fn pack(&self, __yog_p: &mut Packer)
fn pack(&self, __yog_p: &mut Packer)
crate::frame): its binary form as
bytes, unless the type packs itself (derived ones and plain types do).Source§fn unpack(__yog_u: &mut Unpacker<'_>) -> Option<ToolMaterial>
fn unpack(__yog_u: &mut Unpacker<'_>) -> Option<ToolMaterial>
None if the bytes aren’t what
Schema::pack writes.Source§fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<ToolMaterial>
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<ToolMaterial>
v. Problems go to cx at its current path; None when the
value couldn’t be read (the problem is in cx).Source§fn absent() -> Option<Self>
fn absent() -> Option<Self>
None: the field is required.Source§fn pack_list(items: &[Self], p: &mut Packer)
fn pack_list(items: &[Self], p: &mut Packer)
Source§fn encode_list(items: &[Self], w: &mut Writer)
fn encode_list(items: &[Self], w: &mut Writer)
impl StructuralPartialEq for ToolMaterial
Auto Trait Implementations§
impl Freeze for ToolMaterial
impl RefUnwindSafe for ToolMaterial
impl Send for ToolMaterial
impl Sync for ToolMaterial
impl Unpin for ToolMaterial
impl UnsafeUnpin for ToolMaterial
impl UnwindSafe for ToolMaterial
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Message for Twhere
T: Schema,
impl<T> Message for Twhere
T: Schema,
Source§fn from_bytes(bytes: &[u8]) -> Option<Self>
fn from_bytes(bytes: &[u8]) -> Option<Self>
None if it isn’t one.Source§fn with_bytes<R>(&self, f: impl FnOnce(&[u8]) -> R) -> R
fn with_bytes<R>(&self, f: impl FnOnce(&[u8]) -> R) -> R
f on the payload, packed in this thread’s reused buffers: nothing
allocated once they’ve grown to the thread’s messages.