Trait ItemsHost
pub trait ItemsHost {
// Provided methods
fn max_stack_size(&self, item: ItemKey) -> Option<u32> { ... }
fn max_damage(&self, item: ItemKey) -> Option<u32> { ... }
fn item_key(&self, id: &Identifier) -> Option<ItemKey> { ... }
fn item_default_component(
&self,
item: ItemKey,
component: &str,
) -> Option<Tag> { ... }
fn item_burn_time(&self, item: ItemKey) -> Option<i32> { ... }
fn item_compost_chance(&self, item: ItemKey) -> Option<f32> { ... }
fn enchantments_compatible(&self, a: &str, b: &str) -> bool { ... }
fn entity_type_in_tag(&self, entity_type: &str, tag: &str) -> bool { ... }
}Expand description
The host’s methods both sides share of the items area, implemented by the game and reached through Host.
Provided Methods§
fn max_stack_size(&self, item: ItemKey) -> Option<u32>
fn max_stack_size(&self, item: ItemKey) -> Option<u32>
Side: both.
The most of the item item one slot holds (Item.getDefaultMaxStackSize),
or None for an unknown item: for a mod’s container that fills or
merges stacks itself.
fn max_damage(&self, item: ItemKey) -> Option<u32>
fn max_damage(&self, item: ItemKey) -> Option<u32>
Side: both. Default durability of the resolved item, or none if its metadata is unavailable. Stack-specific component overrides are checked at the game’s write boundary.
fn item_key(&self, id: &Identifier) -> Option<ItemKey>
fn item_key(&self, id: &Identifier) -> Option<ItemKey>
Side: both. Resolve an item once at load, including vanilla items, to its process-local identity. None if the completed registry does not contain the identifier.
fn item_default_component(&self, item: ItemKey, component: &str) -> Option<Tag>
fn item_default_component(&self, item: ItemKey, component: &str) -> Option<Tag>
Side: both.
Item item‘s default value of component component, in its prototype
(Item.components().get): minecraft:max_damage on an iron sword is 250, data
packs’ and native mods’ changes included. Read from the item report’s JSON, so a
number is an Int, Long or Double and a boolean a Byte. None where the item
hasn’t the component, and for an unknown item.
fn item_burn_time(&self, item: ItemKey) -> Option<i32>
fn item_burn_time(&self, item: ItemKey) -> Option<i32>
Side: both.
Item item’s cooking-fuel burn time in ticks (FuelValues.burnDuration of its cooking_fuel
component, the data pack’s context int provider resolved), None where it is no fuel. API
@API:item_components@.
fn item_compost_chance(&self, item: ItemKey) -> Option<f32>
fn item_compost_chance(&self, item: ItemKey) -> Option<f32>
Side: both.
Item item’s chance to raise a composter’s level (its compostable component’s layers provider
resolved), None where it is not compostable. API @API:item_components@.
fn enchantments_compatible(&self, a: &str, b: &str) -> bool
fn enchantments_compatible(&self, a: &str, b: &str) -> bool
Side: both.
Whether enchantments a and b may share an item (Enchantment.areCompatible), by the
world’s enchantment definitions. API @API:item_components@.
fn entity_type_in_tag(&self, entity_type: &str, tag: &str) -> bool
fn entity_type_in_tag(&self, entity_type: &str, tag: &str) -> bool
Side: both.
EntityType.is(TagKey): whether entity_type (minecraft:player) is in the entity
type tag tag (minecraft:cannot_be_pushed_onto_boats).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".