ItemComponent

Enum ItemComponent 

Source
pub enum ItemComponent {
Show 96 variants CustomData(Compound), MaxStackSize(VarInt), MaxDamage(VarInt), Damage(VarInt), Unbreakable, CustomName(TextComponent), ItemName(TextComponent), ItemModel(String), Lore(Vec<TextComponent>), Rarity(Rarity), Enchantments(Vec<(RegistryId, VarInt)>), CanPlaceOn(Vec<BlockPredicate>), CanBreak(Vec<BlockPredicate>), AttributeModifiers { modifiers: Vec<AttributeModifier>, }, CustomModelData { floats: Vec<f32>, flags: Vec<bool>, strings: Vec<String>, colors: Vec<i32>, }, TooltipDisplay { hide_tooltip: bool, hidden_components: Vec<VarInt>, }, RepairCost(VarInt), CreativeSlotLock, EnchantmentGlintOverride(bool), IntangibleProjectile(Compound), Food { nutrition: VarInt, saturation_modifier: f32, can_always_eat: bool, }, Consumable { consume_seconds: f32, animation: ConsumableAnimation, sound: IdOr<SoundEventDefinition>, has_consume_particles: bool, effects: Vec<ConsumeEffect>, }, UseRemainder(Box<ItemStack>), UseCooldown { seconds: f32, cooldown_group: Option<String>, }, DamageResistant(String), Tool { rules: Vec<ToolRule>, default_mining_speed: f32, damage_per_block: VarInt, can_destroy_blocks_in_creative: bool, }, Weapon { damage_per_attack: VarInt, disable_blocking_for_seconds: f32, }, Enchantable(VarInt), Equippable { slot: EquipSlot, equip_sound: IdOr<SoundEventDefinition>, model: Option<Ident<String>>, camera_overlay: Option<Ident<String>>, allowed_entities: Option<IDSet>, dispensable: bool, swappable: bool, damage_on_hurt: bool, shearing_sound: Option<IdOr<SoundEventDefinition>>, }, Repairable(IDSet), Glider, TooltipStyle(String), DeathProtection(Vec<ConsumeEffect>), BlocksAttacks { block_delay_seconds: f32, disable_cooldown_scale: f32, damage_reductions: Vec<DamageReduction>, item_damage_threshold: f32, item_damage_base: f32, item_damage_factor: f32, bypassed_by: Option<String>, block_sound: Option<IdOr<SoundEventDefinition>>, disable_sound: Option<IdOr<SoundEventDefinition>>, }, StoredEnchantments { enchantments: Vec<(RegistryId, VarInt)>, show_in_tooltip: bool, }, DyedColor { color: i32, }, MapColor(i32), MapId(VarInt), MapDecorations(Compound), MapPostProcessing(MapPostProcessingType), ChargedProjectiles(Vec<ItemStack>), BundleContents(Vec<ItemStack>), PotionContents { potion_id: Option<RegistryId>, custom_color: Option<i32>, custom_effects: Vec<PotionEffect>, custom_name: Option<String>, }, PotionDurationScale(f32), SuspiciousStewEffects(Vec<(RegistryId, VarInt)>), WritableBookContent { pages: Vec<WritablePage>, }, WrittenBookContent { raw_title: String, filtered_title: Option<String>, author: String, generation: VarInt, pages: Vec<WrittenPage>, resolved: bool, }, Trim { material: IdOr<TrimMaterial>, pattern: IdOr<TrimPattern>, show_in_tooltip: bool, }, DebugStickState(Compound), EntityData { id: RegistryId, data: Compound, }, BucketEntityData(Compound), BlockEntityData { id: RegistryId, data: Compound, }, Instrument(IdOr<InstrumentDefinition>), ProvidesTrimMaterial(ModePair<String, IdOr<TrimMaterial>>), OminousBottleAmplifier(VarInt), JukeboxPlayable { song: ModePair<String, IdOr<JukeboxSong>>, show_in_tooltip: bool, }, ProvidesBannerPatterns(String), Recipes(Compound), LodestoneTracker { target: Option<LodestoneTarget>, tracked: bool, }, FireworkExplosion(FireworkExplosionData), Fireworks { flight_duration: VarInt, explosions: Vec<FireworkExplosionData>, }, Profile(ResolvableProfile), NoteBlockSound(String), BannerPatterns(Vec<BannerLayer>), BaseColor(VarInt), PotDecorations(Vec<RegistryId>), Container(Vec<ItemStack>), BlockState(Vec<(String, String)>), Bees(Vec<BeeData>), Lock(String), ContainerLoot(Compound), BreakSound(IdOr<SoundEventDefinition>), VillagerVariant(RegistryId), WolfVariant(RegistryId), WolfSoundVariant(RegistryId), WolfCollar(DyeColor), FoxVariant(FoxType), SalmonSize(SalmonScale), ParrotVariant(ParrotType), TropicalFishPattern(TropicalFishPattern), TropicalFishBaseColor(DyeColor), TropicalFishPatternColor(DyeColor), MooshroomVariant(MooshroomType), RabbitVariant(RabbitType), PigVariant(RegistryId), CowVariant(RegistryId), ChickenVariant(ModePair<String, RegistryId>), FrogVariant(RegistryId), HorseVariant(HorseColor), PaintingVariant(IdOr<PaintingVariantDefinition>), LlamaVariant(LlamaColor), AxolotlVariant(AxolotlType), CatVariant(RegistryId), CatCollar(DyeColor), SheepColor(DyeColor), ShulkerColor(DyeColor),
}

Variants§

§

CustomData(Compound)

Arbitrary NBT data that does not fit into other structured components. Used primarily by data-driven systems and server-side plugins to store state.

§

MaxStackSize(VarInt)

Overrides the default maximum stack size of the item. Allowed values are between 1 and 99.

§

MaxDamage(VarInt)

The total durability of the item. This is the maximum value the ‘Damage’ component can reach before the item breaks.

§

Damage(VarInt)

The current wear/tear of the item. 0 represents a new item, and higher values indicate more damage.

§

Unbreakable

If present, the item will not take durability damage when used. Mechanical equivalent to the old ‘Unbreakable: 1b’ NBT tag.

§

CustomName(TextComponent)

A custom name for the item, typically set via an anvil. Usually rendered in italics by the client.

§

ItemName(TextComponent)

Overrides the base name of the item (e.g., “Stone”). Unlike CustomName, this is not italicized by default.

§

ItemModel(String)

References a specific model file in a resource pack. Allows a single Item ID to have multiple distinct visual appearances.

§

Lore(Vec<TextComponent>)

Additional lines of text displayed below the item’s name in the tooltip.

§

Rarity(Rarity)

Determines the color of the item’s name (Common/Uncommon/Rare/Epic). Also affects the default glint behavior in some contexts.

§

Enchantments(Vec<(RegistryId, VarInt)>)

A list of enchantments applied to the item and their corresponding levels.

§

CanPlaceOn(Vec<BlockPredicate>)

In Adventure mode, this restricts which blocks a player can place this specific block on.

§

CanBreak(Vec<BlockPredicate>)

In Adventure mode, this restricts which blocks the player can break while holding this item.

§

AttributeModifiers

Modifies the player’s base attributes (like Attack Damage, Movement Speed, or Max Health) when this item is held or equipped.

Fields

§

CustomModelData

Advanced visual overrides for resource packs.

Fields

§floats: Vec<f32>

Generic floating point values used by shaders or model predicates.

§flags: Vec<bool>

Boolean flags for toggling model parts.

§strings: Vec<String>

String identifiers for selecting textures or sub-models.

§colors: Vec<i32>

RGB integer colors for tinting specific model layers.

§

TooltipDisplay

Controls the visibility of the item’s details.

Fields

§hide_tooltip: bool

If true, the entire tooltip (including name) is hidden.

§hidden_components: Vec<VarInt>

A list of Component IDs that should not show their info in the tooltip.

§

RepairCost(VarInt)

The cumulative cost (in levels) added to anvil operations involving this item. Increases every time the item is repaired or modified.

§

CreativeSlotLock

Internal flag used for creative mode. If present, the item cannot be picked up or moved within specific creative tabs.

§

EnchantmentGlintOverride(bool)

Forces the “enchantment purple glow” to be either always on or always off, regardless of whether the item is actually enchanted.

§

IntangibleProjectile(Compound)

Used for projectiles (like arrows or tridents) to mark them as “ghost” items that cannot be picked back up by the player.

§

Food

Defines the nutritional value of the item when eaten.

Fields

§nutrition: VarInt

How many hunger points (half-shanks) are restored.

§saturation_modifier: f32

The multiplier applied to the nutrition to determine saturation.

§can_always_eat: bool

If true, the player can eat this even if their hunger bar is full.

§

Consumable

Defines how the item is used/consumed (e.g., eating, drinking, or using a bow).

Fields

§consume_seconds: f32

The time in seconds required to finish using the item.

§animation: ConsumableAnimation

The visual pose the player takes (Eat, Drink, Block, etc.).

§sound: IdOr<SoundEventDefinition>

The sound played during and after consumption.

§has_consume_particles: bool

Whether to spawn particle effects (like food crumbs) while using.

§effects: Vec<ConsumeEffect>

Status effects (like Poison or Speed) applied when consumption finishes.

§

UseRemainder(Box<ItemStack>)

Defines an item that is returned to the inventory after this one is used. Example: Eating Mushroom Stew returns an empty Bowl.

§

UseCooldown

Prevents the item from being used again for a set duration.

Fields

§seconds: f32

Duration of the cooldown in seconds.

§cooldown_group: Option<String>

Optional group ID. All items with the same group will share the cooldown.

§

DamageResistant(String)

Prevents the item from being destroyed by certain damage types (e.g., fire-resistant Netherite).

§

Tool

Configures how this item mines blocks.

Fields

§rules: Vec<ToolRule>

Specific rules for block sets (e.g., “Pickaxes mine stones fast”).

§default_mining_speed: f32

The mining speed used if no specific rule matches.

§damage_per_block: VarInt

Durability lost per block broken.

§can_destroy_blocks_in_creative: bool

If false, this tool cannot break blocks in Creative mode.

§

Weapon

Statistics for attacking.

Fields

§damage_per_attack: VarInt

Base damage added to the player’s attack.

§disable_blocking_for_seconds: f32

The duration (in seconds) that blocking is disabled after an attack is landed.

§

Enchantable(VarInt)

Determines how many experience points the item “absorbs” in an enchanting table.

§

Equippable

Logic for equipping the item.

Fields

§slot: EquipSlot

Which body slot this item fits into (Head, Chest, etc.).

§equip_sound: IdOr<SoundEventDefinition>

Sound played when the item is equipped.

§model: Option<Ident<String>>

Reference to an equipment-specific model (like 3D armor).

§camera_overlay: Option<Ident<String>>

Texture used when the player’s camera is “inside” the item (like a Pumpkin).

§allowed_entities: Option<IDSet>

Which entity types are allowed to wear this item.

§dispensable: bool

Whether a Dispenser can equip this onto an entity.

§swappable: bool

Whether right-clicking allows swapping this with currently equipped armor.

§damage_on_hurt: bool

If true, the item takes durability damage when the wearer is hurt.

§shearing_sound: Option<IdOr<SoundEventDefinition>>

Some If the item can be sheared off (like a pumpkin from a snow golem) + The sound to play when the item is sheared.

§

Repairable(IDSet)

Items that can be used in an anvil to repair this item.

§

Glider

Enables Elytra-style flight physics when equipped.

§

TooltipStyle(String)

References a custom sprite used as the background of the item’s tooltip.

§

DeathProtection(Vec<ConsumeEffect>)

Replicates the “Totem of Undying” behavior.

§

BlocksAttacks

Shield-specific combat logic.

Fields

§block_delay_seconds: f32

Delay in seconds before blocking becomes active.

§disable_cooldown_scale: f32

Scale factor for cooldowns when blocking.

§damage_reductions: Vec<DamageReduction>

How much damage is absorbed from specific sources.

§item_damage_threshold: f32

Minimum damage required for the shield to take durability loss.

§item_damage_base: f32

Flat durability loss per block.

§item_damage_factor: f32

Multiplier for durability loss based on damage blocked.

§bypassed_by: Option<String>

Damage type tag that pierces this shield’s blocking logic.

§block_sound: Option<IdOr<SoundEventDefinition>>

Sound played when a hit is successfully blocked.

§disable_sound: Option<IdOr<SoundEventDefinition>>

Sound played when the shield is disabled (e.g., by an Axe).

§

StoredEnchantments

Enchantments contained within an Enchanted Book.

Fields

§enchantments: Vec<(RegistryId, VarInt)>
§show_in_tooltip: bool
§

DyedColor

RGB color for leather armor or other dyeable items.

Fields

§color: i32

The packed RGB integer.

§

MapColor(i32)

The color used for markings on a Map item.

§

MapId(VarInt)

The numerical ID associated with a filled Map.

§

MapDecorations(Compound)

NBT data defining markers, banners, and icons shown on a map.

§

MapPostProcessing(MapPostProcessingType)

Tracking state for map expansion or locking.

§

ChargedProjectiles(Vec<ItemStack>)

Items currently loaded into a Crossbow.

§

BundleContents(Vec<ItemStack>)

Items stored inside a Bundle.

§

PotionContents

Data for Potion items, including their base type and custom effects.

Fields

§potion_id: Option<RegistryId>

The base potion type (e.g., “Invisibility”).

§custom_color: Option<i32>

Custom color for the liquid, overrides the potion’s default.

§custom_effects: Vec<PotionEffect>

Additional status effects not included in the base potion type.

§custom_name: Option<String>

An optional name for the specific potion mixture.

§

PotionDurationScale(f32)

Multiplier for the duration of effects applied by this potion.

§

SuspiciousStewEffects(Vec<(RegistryId, VarInt)>)

Effects granted by eating Suspicious Stew.

§

WritableBookContent

Pages and filtering information for a Book and Quill.

Fields

§

WrittenBookContent

Finalized content for a Written Book.

Fields

§raw_title: String

The displayed title.

§filtered_title: Option<String>

The title after passing through server-side chat filters.

§author: String

The username of the player who signed the book.

§generation: VarInt

How many times the book has been copied (Original, Copy of Original, etc.).

§pages: Vec<WrittenPage>

Page contents (Rich Text).

§resolved: bool

Whether entity selectors (like @p) have been resolved.

§

Trim

Visual armor customization (Pattern and Material).

Fields

§material: IdOr<TrimMaterial>
§pattern: IdOr<TrimPattern>
§show_in_tooltip: bool

Whether the “Armor Trim” lines show in the tooltip.

§

DebugStickState(Compound)

Internal state for the Debug Stick, tracking property toggles.

§

EntityData

NBT data used to modify an entity when it is spawned from an item (Spawn Eggs).

Fields

§id: RegistryId
§

BucketEntityData(Compound)

NBT data for entities inside a Bucket (like Fish or Axolotls).

§

BlockEntityData

NBT data for the Block Entity created when this item is placed (Chests, Signs).

Fields

§id: RegistryId
§

Instrument(IdOr<InstrumentDefinition>)

The specific sound and duration associated with a Goat Horn.

§

ProvidesTrimMaterial(ModePair<String, IdOr<TrimMaterial>>)

Marks an item as a valid material for the Armor Trim system.

§

OminousBottleAmplifier(VarInt)

The level of Bad Omen granted by an Ominous Bottle (0-4).

§

JukeboxPlayable

Configuration for items that can be played in a Jukebox.

Fields

§song: ModePair<String, IdOr<JukeboxSong>>

Reference to a Jukebox Song.

§show_in_tooltip: bool
§

ProvidesBannerPatterns(String)

Marks an item as a valid pattern for the Loom (Banner Patterns).

§

Recipes(Compound)

A list of recipe IDs that a Knowledge Book will teach the player.

§

LodestoneTracker

Tracking data for a Compass pointing to a specific Lodestone.

Fields

§target: Option<LodestoneTarget>

The dimension and coordinate of the target. None if the compass is spinning.

§tracked: bool

If true, the compass becomes a normal compass if the lodestone is destroyed.

§

FireworkExplosion(FireworkExplosionData)

Individual explosion properties for a Firework Star.

§

Fireworks

Flight and explosion data for a Firework Rocket.

Fields

§flight_duration: VarInt
§

Profile(ResolvableProfile)

Data for a Player Head, including the skin texture and UUID.

§

NoteBlockSound(String)

The sound played by a Note Block if this player head is placed on top of it.

§

BannerPatterns(Vec<BannerLayer>)

Visual layers for a Banner or Shield.

§

BaseColor(VarInt)

The base dye color for a Banner.

§

PotDecorations(Vec<RegistryId>)

The four item IDs used as patterns on a Decorated Pot.

§

Container(Vec<ItemStack>)

The inventory contents of a block (like a Chest or Shulker Box).

§

BlockState(Vec<(String, String)>)

Block state property overrides (e.g., “lit: true”).

§

Bees(Vec<BeeData>)

Data for bees currently inside a Beehive item.

§

Lock(String)

The “Key” name required to open a container if it has a Lock component.

§

ContainerLoot(Compound)

Reference to a Loot Table for an unopened chest.

§

BreakSound(IdOr<SoundEventDefinition>)

Overrides the default sound played when this specific item breaks.

§

VillagerVariant(RegistryId)

Biome-specific variant of a Villager (e.g., Desert, Plains).

§

WolfVariant(RegistryId)

Skin variant for a Wolf.

§

WolfSoundVariant(RegistryId)

Determines the bark/growl sounds for a Wolf.

§

WolfCollar(DyeColor)

Dye color of a Wolf’s collar.

§

FoxVariant(FoxType)

Type of Fox (Red or Snow).

§

SalmonSize(SalmonScale)

Size of a Salmon (Small, Medium, Large).

§

ParrotVariant(ParrotType)

Color of a Parrot.

§

TropicalFishPattern(TropicalFishPattern)

Pattern type for a Tropical Fish.

§

TropicalFishBaseColor(DyeColor)

Primary color of a Tropical Fish.

§

TropicalFishPatternColor(DyeColor)

Secondary color of a Tropical Fish.

§

MooshroomVariant(MooshroomType)

Type of Mooshroom (Red or Brown).

§

RabbitVariant(RabbitType)

Breed of a Rabbit.

§

PigVariant(RegistryId)

Skin variant for a Pig.

§

CowVariant(RegistryId)

Skin variant for a Cow.

§

ChickenVariant(ModePair<String, RegistryId>)

Skin variant for a Chicken.

§

FrogVariant(RegistryId)

Biome variant for a Frog.

§

HorseVariant(HorseColor)

Color and marking variant for a Horse.

§

PaintingVariant(IdOr<PaintingVariantDefinition>)

The specific painting texture and dimensions.

§

LlamaVariant(LlamaColor)

Color variant for a Llama.

§

AxolotlVariant(AxolotlType)

Color variant for an Axolotl.

§

CatVariant(RegistryId)

Breed variant for a Cat.

§

CatCollar(DyeColor)

Dye color of a Cat’s collar.

§

SheepColor(DyeColor)

Natural wool color of a Sheep.

§

ShulkerColor(DyeColor)

Shell color of a Shulker.

Implementations§

Source§

impl ItemComponent

Source

pub fn id(&self) -> u32

Source

pub fn hash(&self) -> i32

Trait Implementations§

Source§

impl Clone for ItemComponent

Source§

fn clone(&self) -> ItemComponent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ItemComponent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Encode for ItemComponent

Source§

fn encode(&self, w: impl Write) -> Result<()>

Writes this object to the provided writer. Read more
§

fn encode_slice(slice: &[Self], w: impl Write) -> Result<(), Error>
where Self: Sized,

Like [Encode::encode], except that a whole slice of values is encoded. Read more
Source§

impl PartialEq for ItemComponent

Source§

fn eq(&self, other: &ItemComponent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ItemComponent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.