pub struct ItemDef {
pub id: String,
pub max_stack: u8,
pub name: Option<String>,
pub tooltip: Option<String>,
pub max_damage: u32,
pub fire_resistant: bool,
pub fuel_ticks: u32,
pub food: Option<FoodDef>,
pub tool: Option<ToolItem>,
pub armor: Option<ArmorPiece>,
pub wearable: Option<ArmorSlot>,
pub hangs: Option<Hangs>,
}Expand description
A custom item to register, identified by namespace:path.
Fields§
§id: String§max_stack: u8§name: Option<String>§tooltip: Option<String>§max_damage: u32Durability. 0 = non-damageable. If set, max_stack is forced to 1.
fire_resistant: boolImmune to fire and lava damage (like netherite items).
fuel_ticks: u32Furnace fuel burn time in ticks (0 = not fuel; 200 = one coal equivalent).
food: Option<FoodDef>Nutritional properties; None = not food.
tool: Option<ToolItem>A tool or a weapon of a material.
armor: Option<ArmorPiece>A piece of armor of a material.
wearable: Option<ArmorSlot>Worn in this slot without being armor.
hangs: Option<Hangs>Used on a block’s side, it hangs there as an entity of a hanging type.
Implementations§
Source§impl ItemDef
impl ItemDef
pub fn new(id: impl Into<String>) -> ItemDef
Sourcepub fn tool(
self,
kind: impl Into<String>,
material: impl Into<String>,
) -> ItemDef
pub fn tool( self, kind: impl Into<String>, material: impl Into<String>, ) -> ItemDef
A tool (pickaxe, axe, shovel, hoe, a mod’s mineable tag
mymod:mineable/hammer) or a sword, of material (a
[ToolMaterial]: the game’s iron… or a mod’s), attacking as the
game’s tool of the kind does (Self::tool_attack changes it).
Sourcepub fn tool_attack(self, damage: Option<f32>, speed: Option<f32>) -> ItemDef
pub fn tool_attack(self, damage: Option<f32>, speed: Option<f32>) -> ItemDef
The tool’s own attack damage (on top of the material’s) and speed
change; none: the game’s tool’s. Nothing without Self::tool.
Sourcepub fn armor(self, slot: ArmorSlot, material: impl Into<String>) -> ItemDef
pub fn armor(self, slot: ArmorSlot, material: impl Into<String>) -> ItemDef
A piece of armor for slot (head, chest, legs, feet) of
material (an [ArmorMaterial]: the game’s diamond… or a mod’s).
Sourcepub fn hangs(self, entity: impl Into<String>, size: Option<[u32; 2]>) -> ItemDef
pub fn hangs(self, entity: impl Into<String>, size: Option<[u32; 2]>) -> ItemDef
Used on a block’s side, it hangs an entity (a hanging type) there,
size blocks wide and high (None: the type’s own); the entity
keeps one of this item and drops it when it breaks.
Sourcepub fn max_stack(self, n: u8) -> ItemDef
pub fn max_stack(self, n: u8) -> ItemDef
Maximum stack size (default 64). Ignored when max_damage is set.
Sourcepub fn max_damage(self, durability: u32) -> ItemDef
pub fn max_damage(self, durability: u32) -> ItemDef
Make this a damageable item (tool/weapon/armour). Forces stack size to 1.
Sourcepub fn fire_resistant(self) -> ItemDef
pub fn fire_resistant(self) -> ItemDef
Make this item fire-resistant (won’t burn in fire or lava).
Trait Implementations§
Source§impl Schema for ItemDef
impl Schema for ItemDef
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<ItemDef>
fn decode(__yog_d: &mut Decoder<'_>) -> Option<ItemDef>
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<ItemDef>
fn unpack(__yog_u: &mut Unpacker<'_>) -> Option<ItemDef>
None if the bytes aren’t what
Schema::pack writes.Source§fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<ItemDef>
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<ItemDef>
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)
Auto Trait Implementations§
impl Freeze for ItemDef
impl RefUnwindSafe for ItemDef
impl Send for ItemDef
impl Sync for ItemDef
impl Unpin for ItemDef
impl UnsafeUnpin for ItemDef
impl UnwindSafe for ItemDef
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.