Class ItemStack
- All Implemented Interfaces:
ComponentHolder
Item. Instances can be created using one of
the constructors and are usually stored in an Inventory.
Item stacks should never be compared using == operator or equals
method. This also means they cannot be used as a map key. To check if an item stack
is of a certain item, use isOf(Item). To compare two item stacks, use areItemsEqual(net.minecraft.item.ItemStack, net.minecraft.item.ItemStack) to check the item only, or areEqual(net.minecraft.item.ItemStack, net.minecraft.item.ItemStack) to also check the item
count and the components. Use isEmpty() to check if an item stack is empty instead
of doing stack == ItemStack.EMPTY.
When storing an item stack in an inventory or other places, make sure that an instance is never stored in multiple places. When two inventories hold the same instance, it will duplicate the item stack (and become two instances) when one is saved and reloaded.
Components
Components can be used to store data specific to the item stack.
Use ComponentHolder.get(net.minecraft.component.ComponentType<? extends T>) or ComponentHolder.getOrDefault(net.minecraft.component.ComponentType<? extends T>, T) to
get the component values. Use set(net.minecraft.component.ComponentType<? super T>, T) or remove(net.minecraft.component.ComponentType<? extends T>) to set the components.
NBT serialization
An Item Stack can be serialized with encode(RegistryWrapper.WrapperLookup), and deserialized with fromNbt(RegistryWrapper.WrapperLookup, NbtCompound).
| Key | Type | Purpose |
|---|---|---|
id | NbtString | The identifier of the item. |
count | NbtInt | The count of items in the stack. |
components | ComponentChanges | The item stack's components. |
- Mappings:
Namespace Name named net/minecraft/item/ItemStackintermediary net/minecraft/class_1799official cuq
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intstatic final com.mojang.serialization.Codec<ItemStack> (package private) final ComponentMapImplprivate intprivate static final Textstatic final ItemStackThe empty item stack that holds no item.Deprecated.static final com.mojang.serialization.Codec<RegistryEntry<Item>> static final PacketCodec<RegistryByteBuf, List<ItemStack>> private static final Loggerstatic final com.mojang.serialization.Codec<ItemStack> static final PacketCodec<RegistryByteBuf, List<ItemStack>> static final PacketCodec<RegistryByteBuf, ItemStack> static final PacketCodec<RegistryByteBuf, ItemStack> static final com.mojang.serialization.Codec<ItemStack> static final com.mojang.serialization.Codec<ItemStack> static final com.mojang.serialization.Codec<ItemStack> static final com.mojang.serialization.Codec<ItemStack> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateItemStack(ItemConvertible item) ItemStack(ItemConvertible item, int count) privateItemStack(ItemConvertible item, int count, ComponentMapImpl components) ItemStack(RegistryEntry<Item> entry) ItemStack(RegistryEntry<Item> itemEntry, int count) ItemStack(RegistryEntry<Item> item, int count, ComponentChanges changes) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEnchantment(RegistryEntry<Enchantment> enchantment, int level) Enchants this item with the given enchantment and level.private voidappendAttributeModifiersTooltip(Consumer<Text> textConsumer, @Nullable PlayerEntity player) private voidappendAttributeModifierTooltip(Consumer<Text> textConsumer, @Nullable PlayerEntity player, RegistryEntry<EntityAttribute> attribute, EntityAttributeModifier modifier) private <T extends TooltipAppender>
voidappendTooltip(ComponentType<T> componentType, Item.TooltipContext context, Consumer<Text> textConsumer, TooltipType type) <T> Tapply(ComponentType<T> type, T defaultValue, UnaryOperator<T> applier) Sets the componenttypeby passing the current value (ordefaultValueif the component is missing) toapplierand then setting its return value as the value.<T,U> T apply(ComponentType<T> type, T defaultValue, U change, BiFunction<T, U, T> applier) Sets the componenttypeby passing the current value andchangetoapplier, then setting its return value as the value.voidapplyAttributeModifier(AttributeModifierSlot slot, BiConsumer<RegistryEntry<EntityAttribute>, EntityAttributeModifier> attributeModifierConsumer) voidapplyAttributeModifiers(EquipmentSlot slot, BiConsumer<RegistryEntry<EntityAttribute>, EntityAttributeModifier> attributeModifierConsumer) voidapplyChanges(ComponentChanges changes) voidapplyComponentsFrom(ComponentMap components) voidapplyUnvalidatedChanges(ComponentChanges changes) static booleanReturns whether the given item stacks are equal, including the item count and components.static booleanareItemsAndComponentsEqual(ItemStack stack, ItemStack otherStack) Returns whether the given item stacks' items and components are equal.static booleanareItemsEqual(ItemStack left, ItemStack right) Returns whether the given item stacks contain the same item, regardless of item count or components.booleanbooleanvoidcapCount(int maxCount) Sets the count of items in this item stack to not exceedmaxCount.copy()Returns a copy of this item stack, including the item count, components, and bobbing animation time.copyComponentsToNewStack(ItemConvertible item, int count) Returns a new item stack with the components copied from this item stack.private ItemStackcopyComponentsToNewStackIgnoreEmpty(ItemConvertible item, int count) Returns a new item stack with the components copied from this item stack, even if this stack is empty.copyWithCount(int count) Returns a copy of this item stack, including the components, and bobbing animation time.static PacketCodec<RegistryByteBuf, ItemStack> createExtraValidatingPacketCodec(PacketCodec<RegistryByteBuf, ItemStack> basePacketCodec) Returns a packet codec that ensures the validity of the decoded stack by checking if it can be re-encoded.static com.mojang.serialization.MapCodec<ItemStack> createOptionalCodec(String fieldName) voiddamage(int amount, LivingEntity entity, EquipmentSlot slot) Damages this item stack.damage(int amount, ItemConvertible itemAfterBreaking, LivingEntity entity, EquipmentSlot slot) voiddamage(int amount, ServerWorld world, @Nullable ServerPlayerEntity player, Consumer<Item> breakCallback) Damages this item stack.voiddecrement(int amount) Decrements the count of items in this item stack.voiddecrementUnlessCreative(int amount, @Nullable LivingEntity entity) Decrements the count of items in this item stack, unlessentityis a creative mode player.encode(RegistryWrapper.WrapperLookup registries) encode(RegistryWrapper.WrapperLookup registries, NbtElement prefix) encodeAllowEmpty(RegistryWrapper.WrapperLookup registries) finishUsing(World world, LivingEntity user) fromNbt(RegistryWrapper.WrapperLookup registries, NbtElement nbt) static ItemStackfromNbtOrEmpty(RegistryWrapper.WrapperLookup registries, NbtCompound nbt) intintgetCount()Returns the count of items in this item stack.intReturns the damage (lost durability) of the item stack.getFrame()Returns the item frame that holds the stack, ornullif inapplicable.Returns the entity that holds the stack, ornullif inapplicable.getItem()Returns the item of this stack.intReturns the color of the filled section of the durability bar.intReturns the length of the filled section of the durability bar in pixels (out of 13).intintintgetMaxUseTime(LivingEntity user) floatgetName()Returns the custom name of the stack if it exists, or the item's name.getTooltip(Item.TooltipContext context, @Nullable PlayerEntity player, TooltipType type) booleanReturns whether the item stack has any enchantments.booleanhasGlint()static intvoidincrement(int amount) Increments the count of items in this item stack.voidinventoryTick(World world, Entity entity, int slot, boolean selected) booleanReturns whether the item can be damaged (lose durability).booleanReturns whether the item stack is damageable and has damage.booleanisEmpty()Returns whether this item stack is empty.booleanReturns whether this item stack can be enchanted with an enchanting table.booleanisIn(RegistryEntryList<Item> registryEntryList) booleanReturns whether the item is intag.booleanReturns whether the item stack is in an item frame.booleanbooleanisItemEnabled(FeatureSet enabledFeatures) booleanReturns whether the item isitem.booleanReturns whether the item stack can have item count above1.booleanisSuitableFor(BlockState state) Determines whether this item can be used as a suitable tool for mining the specified block.booleanbooleanitemMatches(Predicate<RegistryEntry<Item>> predicate) Returns whether the item's registry entry passes thepredicate.booleanitemMatches(RegistryEntry<Item> itemEntry) Returns whether the item's registry entry matchesitemEntry.static intlistHashCode(List<ItemStack> stacks) Deprecated.booleanonClicked(ItemStack stack, Slot slot, ClickType clickType, PlayerEntity player, StackReference cursorStackReference) voidonCraftByCrafter(World world) voidonCraftByPlayer(World world, PlayerEntity player, int amount) voidonItemEntityDestroyed(ItemEntity entity) booleanonStackClicked(Slot slot, ClickType clickType, PlayerEntity player) voidonStoppedUsing(World world, LivingEntity user, int remainingUseTicks) voidpostDamageEntity(LivingEntity target, PlayerEntity player) booleanpostHit(LivingEntity target, PlayerEntity player) voidpostMine(World world, BlockState state, BlockPos pos, PlayerEntity miner) <T> Tremove(ComponentType<? extends T> type) Removes the componenttype.<T> Tset(ComponentType<? super T> type, T value) Sets the componenttypefor this item stack tovalue.voidsetBobbingAnimationTime(int bobbingAnimationTime) voidsetCount(int count) Sets the count of items in this item stack.voidsetDamage(int damage) Sets the stack's damage todamage.voidSets the stack's holder toholder.split(int amount) Returns the copy of the stack "split" from the current stack with item count being at mostamount.splitUnlessCreative(int amount, @Nullable LivingEntity entity) static booleanstacksEqual(List<ItemStack> left, List<ItemStack> right) Deprecated.Returns a stream of all tags the item is in.booleantakesDamageFrom(DamageSource source) Returns a text consisting of the bracketed stack name that can be hovered to show the item stack's tooltip.toString()voidusageTick(World world, LivingEntity user, int remainingUseTicks) use(World world, PlayerEntity user, Hand hand) useOnBlock(ItemUsageContext context) useOnEntity(PlayerEntity user, LivingEntity entity, Hand hand) private static com.mojang.serialization.DataResult<ItemStack> static com.mojang.serialization.DataResult<Unit> validateComponents(ComponentMap components) withItem(ItemConvertible item) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.component.ComponentHolder
contains, get, getOrDefault
-
Field Details
-
ITEM_CODEC
- Mappings:
Namespace Name Mixin selector named ITEM_CODECLnet/minecraft/item/ItemStack;ITEM_CODEC:Lcom/mojang/serialization/Codec;intermediary field_47312Lnet/minecraft/class_1799;field_47312:Lcom/mojang/serialization/Codec;official aLcuq;a:Lcom/mojang/serialization/Codec;
-
CODEC
- Mappings:
Namespace Name Mixin selector named CODECLnet/minecraft/item/ItemStack;CODEC:Lcom/mojang/serialization/Codec;intermediary field_24671Lnet/minecraft/class_1799;field_24671:Lcom/mojang/serialization/Codec;official bLcuq;b:Lcom/mojang/serialization/Codec;
-
UNCOUNTED_CODEC
- Mappings:
Namespace Name Mixin selector named UNCOUNTED_CODECLnet/minecraft/item/ItemStack;UNCOUNTED_CODEC:Lcom/mojang/serialization/Codec;intermediary field_49747Lnet/minecraft/class_1799;field_49747:Lcom/mojang/serialization/Codec;official cLcuq;c:Lcom/mojang/serialization/Codec;
-
VALIDATED_CODEC
- Mappings:
Namespace Name Mixin selector named VALIDATED_CODECLnet/minecraft/item/ItemStack;VALIDATED_CODEC:Lcom/mojang/serialization/Codec;intermediary field_51397Lnet/minecraft/class_1799;field_51397:Lcom/mojang/serialization/Codec;official dLcuq;d:Lcom/mojang/serialization/Codec;
-
VALIDATED_UNCOUNTED_CODEC
- Mappings:
Namespace Name Mixin selector named VALIDATED_UNCOUNTED_CODECLnet/minecraft/item/ItemStack;VALIDATED_UNCOUNTED_CODEC:Lcom/mojang/serialization/Codec;intermediary field_51398Lnet/minecraft/class_1799;field_51398:Lcom/mojang/serialization/Codec;official eLcuq;e:Lcom/mojang/serialization/Codec;
-
OPTIONAL_CODEC
- Mappings:
Namespace Name Mixin selector named OPTIONAL_CODECLnet/minecraft/item/ItemStack;OPTIONAL_CODEC:Lcom/mojang/serialization/Codec;intermediary field_49266Lnet/minecraft/class_1799;field_49266:Lcom/mojang/serialization/Codec;official fLcuq;f:Lcom/mojang/serialization/Codec;
-
REGISTRY_ENTRY_CODEC
- Mappings:
Namespace Name Mixin selector named REGISTRY_ENTRY_CODECLnet/minecraft/item/ItemStack;REGISTRY_ENTRY_CODEC:Lcom/mojang/serialization/Codec;intermediary field_49267Lnet/minecraft/class_1799;field_49267:Lcom/mojang/serialization/Codec;official gLcuq;g:Lcom/mojang/serialization/Codec;
-
OPTIONAL_PACKET_CODEC
- Mappings:
Namespace Name Mixin selector named OPTIONAL_PACKET_CODECLnet/minecraft/item/ItemStack;OPTIONAL_PACKET_CODEC:Lnet/minecraft/network/codec/PacketCodec;intermediary field_49268Lnet/minecraft/class_1799;field_49268:Lnet/minecraft/class_9139;official hLcuq;h:Lyx;
-
PACKET_CODEC
- Mappings:
Namespace Name Mixin selector named PACKET_CODECLnet/minecraft/item/ItemStack;PACKET_CODEC:Lnet/minecraft/network/codec/PacketCodec;intermediary field_48349Lnet/minecraft/class_1799;field_48349:Lnet/minecraft/class_9139;official iLcuq;i:Lyx;
-
OPTIONAL_LIST_PACKET_CODEC
- Mappings:
Namespace Name Mixin selector named OPTIONAL_LIST_PACKET_CODECLnet/minecraft/item/ItemStack;OPTIONAL_LIST_PACKET_CODEC:Lnet/minecraft/network/codec/PacketCodec;intermediary field_49269Lnet/minecraft/class_1799;field_49269:Lnet/minecraft/class_9139;official jLcuq;j:Lyx;
-
LIST_PACKET_CODEC
- Mappings:
Namespace Name Mixin selector named LIST_PACKET_CODECLnet/minecraft/item/ItemStack;LIST_PACKET_CODEC:Lnet/minecraft/network/codec/PacketCodec;intermediary field_48350Lnet/minecraft/class_1799;field_48350:Lnet/minecraft/class_9139;official kLcuq;k:Lyx;
-
LOGGER
- Mappings:
Namespace Name Mixin selector named LOGGERLnet/minecraft/item/ItemStack;LOGGER:Lorg/slf4j/Logger;intermediary field_8033Lnet/minecraft/class_1799;field_8033:Lorg/slf4j/Logger;official mLcuq;m:Lorg/slf4j/Logger;
-
EMPTY
The empty item stack that holds no item.This should never be mutated.
- See Also:
- Mappings:
Namespace Name Mixin selector named EMPTYLnet/minecraft/item/ItemStack;EMPTY:Lnet/minecraft/item/ItemStack;intermediary field_8037Lnet/minecraft/class_1799;field_8037:Lnet/minecraft/class_1799;official lLcuq;l:Lcuq;
-
DISABLED_TEXT
- Mappings:
Namespace Name Mixin selector named DISABLED_TEXTLnet/minecraft/item/ItemStack;DISABLED_TEXT:Lnet/minecraft/text/Text;intermediary field_40211Lnet/minecraft/class_1799;field_40211:Lnet/minecraft/class_2561;official nLcuq;n:Lwz;
-
count
private int count- Mappings:
Namespace Name Mixin selector named countLnet/minecraft/item/ItemStack;count:Iintermediary field_8031Lnet/minecraft/class_1799;field_8031:Iofficial oLcuq;o:I
-
bobbingAnimationTime
private int bobbingAnimationTime- Mappings:
Namespace Name Mixin selector named bobbingAnimationTimeLnet/minecraft/item/ItemStack;bobbingAnimationTime:Iintermediary field_8030Lnet/minecraft/class_1799;field_8030:Iofficial pLcuq;p:I
-
item
Deprecated.- Mappings:
Namespace Name Mixin selector named itemLnet/minecraft/item/ItemStack;item:Lnet/minecraft/item/Item;intermediary field_8038Lnet/minecraft/class_1799;field_8038:Lnet/minecraft/class_1792;official qLcuq;q:Lcul;
-
components
- Mappings:
Namespace Name Mixin selector named componentsLnet/minecraft/item/ItemStack;components:Lnet/minecraft/component/ComponentMapImpl;intermediary field_49270Lnet/minecraft/class_1799;field_49270:Lnet/minecraft/class_9335;official rLcuq;r:Lkr;
-
holder
- Mappings:
Namespace Name Mixin selector named holderLnet/minecraft/item/ItemStack;holder:Lnet/minecraft/entity/Entity;intermediary field_24093Lnet/minecraft/class_1799;field_24093:Lnet/minecraft/class_1297;official sLcuq;s:Lbsr;
-
-
Constructor Details
-
ItemStack
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/item/ItemStack;<init>(Lnet/minecraft/item/ItemConvertible;)Vintermediary <init>Lnet/minecraft/class_1799;<init>(Lnet/minecraft/class_1935;)Vofficial <init>Lcuq;<init>(Ldcv;)V
-
ItemStack
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/item/ItemStack;<init>(Lnet/minecraft/registry/entry/RegistryEntry;)Vintermediary <init>Lnet/minecraft/class_1799;<init>(Lnet/minecraft/class_6880;)Vofficial <init>Lcuq;<init>(Ljm;)V
-
ItemStack
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/item/ItemStack;<init>(Lnet/minecraft/registry/entry/RegistryEntry;ILnet/minecraft/component/ComponentChanges;)Vintermediary <init>Lnet/minecraft/class_1799;<init>(Lnet/minecraft/class_6880;ILnet/minecraft/class_9326;)Vofficial <init>Lcuq;<init>(Ljm;ILkn;)V
-
ItemStack
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/item/ItemStack;<init>(Lnet/minecraft/registry/entry/RegistryEntry;I)Vintermediary <init>Lnet/minecraft/class_1799;<init>(Lnet/minecraft/class_6880;I)Vofficial <init>Lcuq;<init>(Ljm;I)V
-
ItemStack
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/item/ItemStack;<init>(Lnet/minecraft/item/ItemConvertible;I)Vintermediary <init>Lnet/minecraft/class_1799;<init>(Lnet/minecraft/class_1935;I)Vofficial <init>Lcuq;<init>(Ldcv;I)V
-
ItemStack
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/item/ItemStack;<init>(Lnet/minecraft/item/ItemConvertible;ILnet/minecraft/component/ComponentMapImpl;)Vintermediary <init>Lnet/minecraft/class_1799;<init>(Lnet/minecraft/class_1935;ILnet/minecraft/class_9335;)Vofficial <init>Lcuq;<init>(Ldcv;ILkr;)V
-
ItemStack
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/item/ItemStack;<init>(Ljava/lang/Void;)Vintermediary <init>Lnet/minecraft/class_1799;<init>(Ljava/lang/Void;)Vofficial <init>Lcuq;<init>(Ljava/lang/Void;)V
-
-
Method Details
-
validate
- Mappings:
Namespace Name Mixin selector named validateLnet/minecraft/item/ItemStack;validate(Lnet/minecraft/item/ItemStack;)Lcom/mojang/serialization/DataResult;intermediary method_57372Lnet/minecraft/class_1799;method_57372(Lnet/minecraft/class_1799;)Lcom/mojang/serialization/DataResult;official bLcuq;b(Lcuq;)Lcom/mojang/serialization/DataResult;
-
createExtraValidatingPacketCodec
public static PacketCodec<RegistryByteBuf,ItemStack> createExtraValidatingPacketCodec(PacketCodec<RegistryByteBuf, ItemStack> basePacketCodec) Returns a packet codec that ensures the validity of the decoded stack by checking if it can be re-encoded.This should be used when serializing
ItemStackin C2S packets. Encoding is unaffected.- Returns:
- a packet codec that ensures the validity of the decoded stack by checking if it can be re-encoded
- Mappings:
Namespace Name Mixin selector named createExtraValidatingPacketCodecLnet/minecraft/item/ItemStack;createExtraValidatingPacketCodec(Lnet/minecraft/network/codec/PacketCodec;)Lnet/minecraft/network/codec/PacketCodec;intermediary method_59693Lnet/minecraft/class_1799;method_59693(Lnet/minecraft/class_9139;)Lnet/minecraft/class_9139;official aLcuq;a(Lyx;)Lyx;
-
getTooltipData
- Mappings:
Namespace Name Mixin selector named getTooltipDataLnet/minecraft/item/ItemStack;getTooltipData()Ljava/util/Optional;intermediary method_32347Lnet/minecraft/class_1799;method_32347()Ljava/util/Optional;official bLcuq;b()Ljava/util/Optional;
-
getComponents
- Specified by:
getComponentsin interfaceComponentHolder- Mappings:
Namespace Name Mixin selector named getComponentsLnet/minecraft/component/ComponentHolder;getComponents()Lnet/minecraft/component/ComponentMap;intermediary method_57353Lnet/minecraft/class_9322;method_57353()Lnet/minecraft/class_9323;official aLkl;a()Lkm;
-
getDefaultComponents
- Mappings:
Namespace Name Mixin selector named getDefaultComponentsLnet/minecraft/item/ItemStack;getDefaultComponents()Lnet/minecraft/component/ComponentMap;intermediary method_58658Lnet/minecraft/class_1799;method_58658()Lnet/minecraft/class_9323;official cLcuq;c()Lkm;
-
getComponentChanges
- Mappings:
Namespace Name Mixin selector named getComponentChangesLnet/minecraft/item/ItemStack;getComponentChanges()Lnet/minecraft/component/ComponentChanges;intermediary method_57380Lnet/minecraft/class_1799;method_57380()Lnet/minecraft/class_9326;official dLcuq;d()Lkn;
-
validateComponents
- Mappings:
Namespace Name Mixin selector named validateComponentsLnet/minecraft/item/ItemStack;validateComponents(Lnet/minecraft/component/ComponentMap;)Lcom/mojang/serialization/DataResult;intermediary method_59691Lnet/minecraft/class_1799;method_59691(Lnet/minecraft/class_9323;)Lcom/mojang/serialization/DataResult;official aLcuq;a(Lkm;)Lcom/mojang/serialization/DataResult;
-
fromNbt
- Mappings:
Namespace Name Mixin selector named fromNbtLnet/minecraft/item/ItemStack;fromNbt(Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;Lnet/minecraft/nbt/NbtElement;)Ljava/util/Optional;intermediary method_57360Lnet/minecraft/class_1799;method_57360(Lnet/minecraft/class_7225$class_7874;Lnet/minecraft/class_2520;)Ljava/util/Optional;official aLcuq;a(Ljo$a;Luy;)Ljava/util/Optional;
-
fromNbtOrEmpty
- Mappings:
Namespace Name Mixin selector named fromNbtOrEmptyLnet/minecraft/item/ItemStack;fromNbtOrEmpty(Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/item/ItemStack;intermediary method_57359Lnet/minecraft/class_1799;method_57359(Lnet/minecraft/class_7225$class_7874;Lnet/minecraft/class_2487;)Lnet/minecraft/class_1799;official aLcuq;a(Ljo$a;Lub;)Lcuq;
-
isEmpty
public boolean isEmpty()Returns whether this item stack is empty.- Returns:
- whether this item stack is empty
- Mappings:
Namespace Name Mixin selector named isEmptyLnet/minecraft/item/ItemStack;isEmpty()Zintermediary method_7960Lnet/minecraft/class_1799;method_7960()Zofficial eLcuq;e()Z
-
isItemEnabled
- Mappings:
Namespace Name Mixin selector named isItemEnabledLnet/minecraft/item/ItemStack;isItemEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Zintermediary method_45435Lnet/minecraft/class_1799;method_45435(Lnet/minecraft/class_7699;)Zofficial aLcuq;a(Lcpl;)Z
-
split
Returns the copy of the stack "split" from the current stack with item count being at mostamount.Splitting an item stack mutates this stack so that the sum of the stacks' item counts does not change. See the example below:
ItemStack stack = new ItemStack(Items.APPLE, 64); ItemStack newStack = stack.split(10); // stack has 54 apples // newStack has 10 apples ItemStack smallStack = new ItemStack(Items.APPLE, 4); ItemStack newSmallStack = smallStack.split(10); // smallStack is now empty // newSmallStack has 4 apples- Returns:
- the copy of the stack "split" from the current stack with item count
being at most
amount - Mappings:
Namespace Name Mixin selector named splitLnet/minecraft/item/ItemStack;split(I)Lnet/minecraft/item/ItemStack;intermediary method_7971Lnet/minecraft/class_1799;method_7971(I)Lnet/minecraft/class_1799;official aLcuq;a(I)Lcuq;
-
copyAndEmpty
- Mappings:
Namespace Name Mixin selector named copyAndEmptyLnet/minecraft/item/ItemStack;copyAndEmpty()Lnet/minecraft/item/ItemStack;intermediary method_51164Lnet/minecraft/class_1799;method_51164()Lnet/minecraft/class_1799;official fLcuq;f()Lcuq;
-
getItem
Returns the item of this stack.- Returns:
- the item of this stack
- See Also:
- Mappings:
Namespace Name Mixin selector named getItemLnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;intermediary method_7909Lnet/minecraft/class_1799;method_7909()Lnet/minecraft/class_1792;official gLcuq;g()Lcul;
-
getRegistryEntry
- Mappings:
Namespace Name Mixin selector named getRegistryEntryLnet/minecraft/item/ItemStack;getRegistryEntry()Lnet/minecraft/registry/entry/RegistryEntry;intermediary method_41409Lnet/minecraft/class_1799;method_41409()Lnet/minecraft/class_6880;official hLcuq;h()Ljm;
-
isIn
Returns whether the item is intag.- Returns:
- whether the item is in
tag - Mappings:
Namespace Name Mixin selector named isInLnet/minecraft/item/ItemStack;isIn(Lnet/minecraft/registry/tag/TagKey;)Zintermediary method_31573Lnet/minecraft/class_1799;method_31573(Lnet/minecraft/class_6862;)Zofficial aLcuq;a(Lawu;)Z
-
isOf
Returns whether the item isitem.- Returns:
- whether the item is
item - Mappings:
Namespace Name Mixin selector named isOfLnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Zintermediary method_31574Lnet/minecraft/class_1799;method_31574(Lnet/minecraft/class_1792;)Zofficial aLcuq;a(Lcul;)Z
-
itemMatches
Returns whether the item's registry entry passes thepredicate.- Returns:
- whether the item's registry entry passes the
predicate - See Also:
- Mappings:
Namespace Name Mixin selector named itemMatchesLnet/minecraft/item/ItemStack;itemMatches(Ljava/util/function/Predicate;)Zintermediary method_41407Lnet/minecraft/class_1799;method_41407(Ljava/util/function/Predicate;)Zofficial aLcuq;a(Ljava/util/function/Predicate;)Z
-
itemMatches
Returns whether the item's registry entry matchesitemEntry.- Returns:
- whether the item's registry entry matches
itemEntry - See Also:
- Mappings:
Namespace Name Mixin selector named itemMatchesLnet/minecraft/item/ItemStack;itemMatches(Lnet/minecraft/registry/entry/RegistryEntry;)Zintermediary method_41406Lnet/minecraft/class_1799;method_41406(Lnet/minecraft/class_6880;)Zofficial aLcuq;a(Ljm;)Z
-
isIn
- Mappings:
Namespace Name Mixin selector named isInLnet/minecraft/item/ItemStack;isIn(Lnet/minecraft/registry/entry/RegistryEntryList;)Zintermediary method_53187Lnet/minecraft/class_1799;method_53187(Lnet/minecraft/class_6885;)Zofficial aLcuq;a(Ljq;)Z
-
streamTags
Returns a stream of all tags the item is in.- Returns:
- a stream of all tags the item is in
- See Also:
- Mappings:
Namespace Name Mixin selector named streamTagsLnet/minecraft/item/ItemStack;streamTags()Ljava/util/stream/Stream;intermediary method_40133Lnet/minecraft/class_1799;method_40133()Ljava/util/stream/Stream;official iLcuq;i()Ljava/util/stream/Stream;
-
useOnBlock
- Mappings:
Namespace Name Mixin selector named useOnBlockLnet/minecraft/item/ItemStack;useOnBlock(Lnet/minecraft/item/ItemUsageContext;)Lnet/minecraft/util/ActionResult;intermediary method_7981Lnet/minecraft/class_1799;method_7981(Lnet/minecraft/class_1838;)Lnet/minecraft/class_1269;official aLcuq;a(Lcyf;)Lbqr;
-
getMiningSpeedMultiplier
- Mappings:
Namespace Name Mixin selector named getMiningSpeedMultiplierLnet/minecraft/item/ItemStack;getMiningSpeedMultiplier(Lnet/minecraft/block/BlockState;)Fintermediary method_7924Lnet/minecraft/class_1799;method_7924(Lnet/minecraft/class_2680;)Fofficial aLcuq;a(Ldtc;)F
-
use
- Mappings:
Namespace Name Mixin selector named useLnet/minecraft/item/ItemStack;use(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/TypedActionResult;intermediary method_7913Lnet/minecraft/class_1799;method_7913(Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_1268;)Lnet/minecraft/class_1271;official aLcuq;a(Ldcw;Lcmx;Lbqq;)Lbqs;
-
finishUsing
- Mappings:
Namespace Name Mixin selector named finishUsingLnet/minecraft/item/ItemStack;finishUsing(Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;)Lnet/minecraft/item/ItemStack;intermediary method_7910Lnet/minecraft/class_1799;method_7910(Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;)Lnet/minecraft/class_1799;official aLcuq;a(Ldcw;Lbtn;)Lcuq;
-
encode
- Mappings:
Namespace Name Mixin selector named encodeLnet/minecraft/item/ItemStack;encode(Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;Lnet/minecraft/nbt/NbtElement;)Lnet/minecraft/nbt/NbtElement;intermediary method_57376Lnet/minecraft/class_1799;method_57376(Lnet/minecraft/class_7225$class_7874;Lnet/minecraft/class_2520;)Lnet/minecraft/class_2520;official bLcuq;b(Ljo$a;Luy;)Luy;
-
encode
- Mappings:
Namespace Name Mixin selector named encodeLnet/minecraft/item/ItemStack;encode(Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Lnet/minecraft/nbt/NbtElement;intermediary method_57358Lnet/minecraft/class_1799;method_57358(Lnet/minecraft/class_7225$class_7874;)Lnet/minecraft/class_2520;official aLcuq;a(Ljo$a;)Luy;
-
encodeAllowEmpty
- Mappings:
Namespace Name Mixin selector named encodeAllowEmptyLnet/minecraft/item/ItemStack;encodeAllowEmpty(Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Lnet/minecraft/nbt/NbtElement;intermediary method_57375Lnet/minecraft/class_1799;method_57375(Lnet/minecraft/class_7225$class_7874;)Lnet/minecraft/class_2520;official bLcuq;b(Ljo$a;)Luy;
-
getMaxCount
public int getMaxCount()- Mappings:
Namespace Name Mixin selector named getMaxCountLnet/minecraft/item/ItemStack;getMaxCount()Iintermediary method_7914Lnet/minecraft/class_1799;method_7914()Iofficial jLcuq;j()I
-
isStackable
public boolean isStackable()Returns whether the item stack can have item count above1.Stackable items must have the maximum count that is more than
1and cannot be damaged.- Returns:
- whether the item stack can have item count above
1 - Mappings:
Namespace Name Mixin selector named isStackableLnet/minecraft/item/ItemStack;isStackable()Zintermediary method_7946Lnet/minecraft/class_1799;method_7946()Zofficial kLcuq;k()Z
-
isDamageable
public boolean isDamageable()Returns whether the item can be damaged (lose durability).Items with 0 max damage or item stacks with
DataComponentTypes.UNBREAKABLEcomponent cannot be damaged.- Returns:
- whether the item can be damaged (lose durability)
- See Also:
- Mappings:
Namespace Name Mixin selector named isDamageableLnet/minecraft/item/ItemStack;isDamageable()Zintermediary method_7963Lnet/minecraft/class_1799;method_7963()Zofficial lLcuq;l()Z
-
isDamaged
public boolean isDamaged()Returns whether the item stack is damageable and has damage.- Returns:
- whether the item stack is damageable and has damage
- See Also:
- Mappings:
Namespace Name Mixin selector named isDamagedLnet/minecraft/item/ItemStack;isDamaged()Zintermediary method_7986Lnet/minecraft/class_1799;method_7986()Zofficial mLcuq;m()Z
-
getDamage
public int getDamage()Returns the damage (lost durability) of the item stack.Note that this method does not check if the item is damageable, unlike
isDamaged().- Returns:
- the damage (lost durability) of the item stack
- See Also:
- Mappings:
Namespace Name Mixin selector named getDamageLnet/minecraft/item/ItemStack;getDamage()Iintermediary method_7919Lnet/minecraft/class_1799;method_7919()Iofficial nLcuq;n()I
-
setDamage
public void setDamage(int damage) Sets the stack's damage todamage.This does not break the item if the damage reaches the maximum, unlike
damage(int, LivingEntity, EquipmentSlot).- See Also:
- Mappings:
Namespace Name Mixin selector named setDamageLnet/minecraft/item/ItemStack;setDamage(I)Vintermediary method_7974Lnet/minecraft/class_1799;method_7974(I)Vofficial bLcuq;b(I)V
-
getMaxDamage
public int getMaxDamage()- Mappings:
Namespace Name Mixin selector named getMaxDamageLnet/minecraft/item/ItemStack;getMaxDamage()Iintermediary method_7936Lnet/minecraft/class_1799;method_7936()Iofficial oLcuq;o()I
-
damage
public void damage(int amount, ServerWorld world, @Nullable @Nullable ServerPlayerEntity player, Consumer<Item> breakCallback) Damages this item stack. This method should be used when a non-entity, such as a dispenser, damages the stack. This does not damage non-damageable stacks, and the enchantments are applied toamountbefore damaging.If
playeris notnull, this triggersCriteria.ITEM_DURABILITY_CHANGED.When the item "breaks", that is, the stack's damage is equal to or above the maximum damage,
breakCallbackis run. Note that this method automatically decrements the stack size.- Parameters:
player- the player that damaged the stack, ornullif no player is involved- Mappings:
Namespace Name Mixin selector named damageLnet/minecraft/item/ItemStack;damage(ILnet/minecraft/server/world/ServerWorld;Lnet/minecraft/server/network/ServerPlayerEntity;Ljava/util/function/Consumer;)Vintermediary method_7956Lnet/minecraft/class_1799;method_7956(ILnet/minecraft/class_3218;Lnet/minecraft/class_3222;Ljava/util/function/Consumer;)Vofficial aLcuq;a(ILaqu;Laqv;Ljava/util/function/Consumer;)V
-
damage
Damages this item stack. This method should be used when an entity, including a player, damages the stack. This does not damage non-damageable stacks, and the enchantments are applied toamountbefore damaging. Additionally, ifentityis a player in creative mode, the stack will not be damaged.If
entityis a player, this triggersCriteria.ITEM_DURABILITY_CHANGED.If the stack's damage is equal to or above the maximum damage (i.e. the item is "broken"), this will send the equipment break status, decrement the stack, and increment
Stats.BROKENif the stack is held by a player.- Parameters:
slot- the slot in which the stack is held- Mappings:
Namespace Name Mixin selector named damageLnet/minecraft/item/ItemStack;damage(ILnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/EquipmentSlot;)Vintermediary method_7970Lnet/minecraft/class_1799;method_7970(ILnet/minecraft/class_1309;Lnet/minecraft/class_1304;)Vofficial aLcuq;a(ILbtn;Lbsy;)V
-
damage
public ItemStack damage(int amount, ItemConvertible itemAfterBreaking, LivingEntity entity, EquipmentSlot slot) - Mappings:
Namespace Name Mixin selector named damageLnet/minecraft/item/ItemStack;damage(ILnet/minecraft/item/ItemConvertible;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/EquipmentSlot;)Lnet/minecraft/item/ItemStack;intermediary method_60986Lnet/minecraft/class_1799;method_60986(ILnet/minecraft/class_1935;Lnet/minecraft/class_1309;Lnet/minecraft/class_1304;)Lnet/minecraft/class_1799;official aLcuq;a(ILdcv;Lbtn;Lbsy;)Lcuq;
-
isItemBarVisible
public boolean isItemBarVisible()- Mappings:
Namespace Name Mixin selector named isItemBarVisibleLnet/minecraft/item/ItemStack;isItemBarVisible()Zintermediary method_31578Lnet/minecraft/class_1799;method_31578()Zofficial pLcuq;p()Z
-
getItemBarStep
public int getItemBarStep()Returns the length of the filled section of the durability bar in pixels (out of 13).- Returns:
- the length of the filled section of the durability bar in pixels (out of 13)
- Mappings:
Namespace Name Mixin selector named getItemBarStepLnet/minecraft/item/ItemStack;getItemBarStep()Iintermediary method_31579Lnet/minecraft/class_1799;method_31579()Iofficial qLcuq;q()I
-
getItemBarColor
public int getItemBarColor()Returns the color of the filled section of the durability bar.- Returns:
- the color of the filled section of the durability bar
- Mappings:
Namespace Name Mixin selector named getItemBarColorLnet/minecraft/item/ItemStack;getItemBarColor()Iintermediary method_31580Lnet/minecraft/class_1799;method_31580()Iofficial rLcuq;r()I
-
onStackClicked
- Mappings:
Namespace Name Mixin selector named onStackClickedLnet/minecraft/item/ItemStack;onStackClicked(Lnet/minecraft/screen/slot/Slot;Lnet/minecraft/util/ClickType;Lnet/minecraft/entity/player/PlayerEntity;)Zintermediary method_31575Lnet/minecraft/class_1799;method_31575(Lnet/minecraft/class_1735;Lnet/minecraft/class_5536;Lnet/minecraft/class_1657;)Zofficial aLcuq;a(Lcrq;Lcqd;Lcmx;)Z
-
onClicked
public boolean onClicked(ItemStack stack, Slot slot, ClickType clickType, PlayerEntity player, StackReference cursorStackReference) - Mappings:
Namespace Name Mixin selector named onClickedLnet/minecraft/item/ItemStack;onClicked(Lnet/minecraft/item/ItemStack;Lnet/minecraft/screen/slot/Slot;Lnet/minecraft/util/ClickType;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/inventory/StackReference;)Zintermediary method_31576Lnet/minecraft/class_1799;method_31576(Lnet/minecraft/class_1799;Lnet/minecraft/class_1735;Lnet/minecraft/class_5536;Lnet/minecraft/class_1657;Lnet/minecraft/class_5630;)Zofficial aLcuq;a(Lcuq;Lcrq;Lcqd;Lcmx;Lbug;)Z
-
postHit
- Mappings:
Namespace Name Mixin selector named postHitLnet/minecraft/item/ItemStack;postHit(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/player/PlayerEntity;)Zintermediary method_7979Lnet/minecraft/class_1799;method_7979(Lnet/minecraft/class_1309;Lnet/minecraft/class_1657;)Zofficial aLcuq;a(Lbtn;Lcmx;)Z
-
postDamageEntity
- Mappings:
Namespace Name Mixin selector named postDamageEntityLnet/minecraft/item/ItemStack;postDamageEntity(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/player/PlayerEntity;)Vintermediary method_59979Lnet/minecraft/class_1799;method_59979(Lnet/minecraft/class_1309;Lnet/minecraft/class_1657;)Vofficial bLcuq;b(Lbtn;Lcmx;)V
-
postMine
- Mappings:
Namespace Name Mixin selector named postMineLnet/minecraft/item/ItemStack;postMine(Lnet/minecraft/world/World;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;)Vintermediary method_7952Lnet/minecraft/class_1799;method_7952(Lnet/minecraft/class_1937;Lnet/minecraft/class_2680;Lnet/minecraft/class_2338;Lnet/minecraft/class_1657;)Vofficial aLcuq;a(Ldcw;Ldtc;Ljd;Lcmx;)V
-
isSuitableFor
Determines whether this item can be used as a suitable tool for mining the specified block.Depending on block implementation, when combined together, the correct item and block may achieve a better mining speed and yield drops that would not be obtained when mining otherwise.
- Returns:
- values consistent with calls to
Item.isCorrectForDrops(net.minecraft.item.ItemStack, net.minecraft.block.BlockState) - See Also:
- Mappings:
Namespace Name Mixin selector named isSuitableForLnet/minecraft/item/ItemStack;isSuitableFor(Lnet/minecraft/block/BlockState;)Zintermediary method_7951Lnet/minecraft/class_1799;method_7951(Lnet/minecraft/class_2680;)Zofficial bLcuq;b(Ldtc;)Z
-
useOnEntity
- Mappings:
Namespace Name Mixin selector named useOnEntityLnet/minecraft/item/ItemStack;useOnEntity(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;intermediary method_7920Lnet/minecraft/class_1799;method_7920(Lnet/minecraft/class_1657;Lnet/minecraft/class_1309;Lnet/minecraft/class_1268;)Lnet/minecraft/class_1269;official aLcuq;a(Lcmx;Lbtn;Lbqq;)Lbqr;
-
copy
Returns a copy of this item stack, including the item count, components, and bobbing animation time.- Returns:
- a copy of this item stack, including the item count, components, and bobbing animation time
- See Also:
- Mappings:
Namespace Name Mixin selector named copyLnet/minecraft/item/ItemStack;copy()Lnet/minecraft/item/ItemStack;intermediary method_7972Lnet/minecraft/class_1799;method_7972()Lnet/minecraft/class_1799;official sLcuq;s()Lcuq;
-
copyWithCount
Returns a copy of this item stack, including the components, and bobbing animation time., with the item count set tocount- Parameters:
count- the item count of the resultant stack- Returns:
- a copy of this item stack, including the components, and bobbing animation time
- See Also:
- Mappings:
Namespace Name Mixin selector named copyWithCountLnet/minecraft/item/ItemStack;copyWithCount(I)Lnet/minecraft/item/ItemStack;intermediary method_46651Lnet/minecraft/class_1799;method_46651(I)Lnet/minecraft/class_1799;official cLcuq;c(I)Lcuq;
-
withItem
- Mappings:
Namespace Name Mixin selector named withItemLnet/minecraft/item/ItemStack;withItem(Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/item/ItemStack;intermediary method_60503Lnet/minecraft/class_1799;method_60503(Lnet/minecraft/class_1935;)Lnet/minecraft/class_1799;official aLcuq;a(Ldcv;)Lcuq;
-
copyComponentsToNewStack
Returns a new item stack with the components copied from this item stack.- Parameters:
item- the item of the resultant stackcount- the item count of the resultant stack- Returns:
- a new item stack with the components copied from this item stack
- See Also:
- Mappings:
Namespace Name Mixin selector named copyComponentsToNewStackLnet/minecraft/item/ItemStack;copyComponentsToNewStack(Lnet/minecraft/item/ItemConvertible;I)Lnet/minecraft/item/ItemStack;intermediary method_56701Lnet/minecraft/class_1799;method_56701(Lnet/minecraft/class_1935;I)Lnet/minecraft/class_1799;official aLcuq;a(Ldcv;I)Lcuq;
-
copyComponentsToNewStackIgnoreEmpty
Returns a new item stack with the components copied from this item stack, even if this stack is empty.- Parameters:
item- the item of the resultant stackcount- the item count of the resultant stack- Returns:
- a new item stack with the components copied from this item stack, even if this stack is empty
- See Also:
- Mappings:
Namespace Name Mixin selector named copyComponentsToNewStackIgnoreEmptyLnet/minecraft/item/ItemStack;copyComponentsToNewStackIgnoreEmpty(Lnet/minecraft/item/ItemConvertible;I)Lnet/minecraft/item/ItemStack;intermediary method_56704Lnet/minecraft/class_1799;method_56704(Lnet/minecraft/class_1935;I)Lnet/minecraft/class_1799;official bLcuq;b(Ldcv;I)Lcuq;
-
areEqual
Returns whether the given item stacks are equal, including the item count and components.- Returns:
- whether the given item stacks are equal, including the item count and components
- See Also:
- Mappings:
Namespace Name Mixin selector named areEqualLnet/minecraft/item/ItemStack;areEqual(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Zintermediary method_7973Lnet/minecraft/class_1799;method_7973(Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Zofficial aLcuq;a(Lcuq;Lcuq;)Z
-
stacksEqual
Deprecated.- Mappings:
Namespace Name Mixin selector named stacksEqualLnet/minecraft/item/ItemStack;stacksEqual(Ljava/util/List;Ljava/util/List;)Zintermediary method_57362Lnet/minecraft/class_1799;method_57362(Ljava/util/List;Ljava/util/List;)Zofficial aLcuq;a(Ljava/util/List;Ljava/util/List;)Z
-
areItemsEqual
Returns whether the given item stacks contain the same item, regardless of item count or components.- Returns:
- whether the given item stacks contain the same item, regardless of item count or components
- See Also:
- Mappings:
Namespace Name Mixin selector named areItemsEqualLnet/minecraft/item/ItemStack;areItemsEqual(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Zintermediary method_7984Lnet/minecraft/class_1799;method_7984(Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Zofficial bLcuq;b(Lcuq;Lcuq;)Z
-
areItemsAndComponentsEqual
Returns whether the given item stacks' items and components are equal.If this returns
true, the two item stacks can be combined into one, as long as the resulting item count does not exceed the maximum item count- Returns:
- whether the given item stacks' items and components are equal
- See Also:
- Mappings:
Namespace Name Mixin selector named areItemsAndComponentsEqualLnet/minecraft/item/ItemStack;areItemsAndComponentsEqual(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Zintermediary method_31577Lnet/minecraft/class_1799;method_31577(Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Zofficial cLcuq;c(Lcuq;Lcuq;)Z
-
createOptionalCodec
- Mappings:
Namespace Name Mixin selector named createOptionalCodecLnet/minecraft/item/ItemStack;createOptionalCodec(Ljava/lang/String;)Lcom/mojang/serialization/MapCodec;intermediary method_56702Lnet/minecraft/class_1799;method_56702(Ljava/lang/String;)Lcom/mojang/serialization/MapCodec;official aLcuq;a(Ljava/lang/String;)Lcom/mojang/serialization/MapCodec;
-
hashCode
- Mappings:
Namespace Name Mixin selector named hashCodeLnet/minecraft/item/ItemStack;hashCode(Lnet/minecraft/item/ItemStack;)Iintermediary method_57355Lnet/minecraft/class_1799;method_57355(Lnet/minecraft/class_1799;)Iofficial aLcuq;a(Lcuq;)I
-
listHashCode
Deprecated.- Mappings:
Namespace Name Mixin selector named listHashCodeLnet/minecraft/item/ItemStack;listHashCode(Ljava/util/List;)Iintermediary method_57361Lnet/minecraft/class_1799;method_57361(Ljava/util/List;)Iofficial aLcuq;a(Ljava/util/List;)I
-
getTranslationKey
- Mappings:
Namespace Name Mixin selector named getTranslationKeyLnet/minecraft/item/ItemStack;getTranslationKey()Ljava/lang/String;intermediary method_7922Lnet/minecraft/class_1799;method_7922()Ljava/lang/String;official tLcuq;t()Ljava/lang/String;
-
toString
-
inventoryTick
- Mappings:
Namespace Name Mixin selector named inventoryTickLnet/minecraft/item/ItemStack;inventoryTick(Lnet/minecraft/world/World;Lnet/minecraft/entity/Entity;IZ)Vintermediary method_7917Lnet/minecraft/class_1799;method_7917(Lnet/minecraft/class_1937;Lnet/minecraft/class_1297;IZ)Vofficial aLcuq;a(Ldcw;Lbsr;IZ)V
-
onCraftByPlayer
- Mappings:
Namespace Name Mixin selector named onCraftByPlayerLnet/minecraft/item/ItemStack;onCraftByPlayer(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;I)Vintermediary method_7982Lnet/minecraft/class_1799;method_7982(Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;I)Vofficial aLcuq;a(Ldcw;Lcmx;I)V
-
onCraftByCrafter
- Mappings:
Namespace Name Mixin selector named onCraftByCrafterLnet/minecraft/item/ItemStack;onCraftByCrafter(Lnet/minecraft/world/World;)Vintermediary method_54466Lnet/minecraft/class_1799;method_54466(Lnet/minecraft/class_1937;)Vofficial aLcuq;a(Ldcw;)V
-
getMaxUseTime
- Mappings:
Namespace Name Mixin selector named getMaxUseTimeLnet/minecraft/item/ItemStack;getMaxUseTime(Lnet/minecraft/entity/LivingEntity;)Iintermediary method_7935Lnet/minecraft/class_1799;method_7935(Lnet/minecraft/class_1309;)Iofficial aLcuq;a(Lbtn;)I
-
getUseAction
- Mappings:
Namespace Name Mixin selector named getUseActionLnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/util/UseAction;intermediary method_7976Lnet/minecraft/class_1799;method_7976()Lnet/minecraft/class_1839;official uLcuq;u()Lcwo;
-
onStoppedUsing
- Mappings:
Namespace Name Mixin selector named onStoppedUsingLnet/minecraft/item/ItemStack;onStoppedUsing(Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;I)Vintermediary method_7930Lnet/minecraft/class_1799;method_7930(Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;I)Vofficial aLcuq;a(Ldcw;Lbtn;I)V
-
isUsedOnRelease
public boolean isUsedOnRelease()- Mappings:
Namespace Name Mixin selector named isUsedOnReleaseLnet/minecraft/item/ItemStack;isUsedOnRelease()Zintermediary method_7967Lnet/minecraft/class_1799;method_7967()Zofficial vLcuq;v()Z
-
set
Sets the componenttypefor this item stack tovalue.If
valueisnull, the component is removed and the base component is unset. To reverse the stack-specific change, instead pass the default value asvalue.- Returns:
- the previous value set
- See Also:
- Mappings:
Namespace Name Mixin selector named setLnet/minecraft/item/ItemStack;set(Lnet/minecraft/component/ComponentType;Ljava/lang/Object;)Ljava/lang/Object;intermediary method_57379Lnet/minecraft/class_1799;method_57379(Lnet/minecraft/class_9331;Ljava/lang/Object;)Ljava/lang/Object;official bLcuq;b(Lkp;Ljava/lang/Object;)Ljava/lang/Object;
-
apply
@Nullable public <T,U> T apply(ComponentType<T> type, T defaultValue, U change, BiFunction<T, U, T> applier) Sets the componenttypeby passing the current value andchangetoapplier, then setting its return value as the value. If the component is missing,defaultValueis used as the default.In practice,
applieris a reference to a method of the component class with one parameter, that returns a new instance of the component with the specific value changed tochange. For example, adding a lore can be accomplished by passing reference toLoreComponent.with(net.minecraft.text.Text)and the added lore, likestack.apply(DataComponentTypes.LORE, LoreComponent.DEFAULT, text, LoreComponent::with).- Returns:
- the previous value set
- See Also:
- Implementation Note:
- This is the same as setting
applier.apply(stack.getOrDefault(type, defaultValue), change). - Mappings:
Namespace Name Mixin selector named applyLnet/minecraft/item/ItemStack;apply(Lnet/minecraft/component/ComponentType;Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;intermediary method_57367Lnet/minecraft/class_1799;method_57367(Lnet/minecraft/class_9331;Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;official aLcuq;a(Lkp;Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;
-
apply
Sets the componenttypeby passing the current value (ordefaultValueif the component is missing) toapplierand then setting its return value as the value.- Returns:
- the previous value set
- See Also:
- Implementation Note:
- This is the same as setting
applier.apply(stack.getOrDefault(type, defaultValue)). - Mappings:
Namespace Name Mixin selector named applyLnet/minecraft/item/ItemStack;apply(Lnet/minecraft/component/ComponentType;Ljava/lang/Object;Ljava/util/function/UnaryOperator;)Ljava/lang/Object;intermediary method_57368Lnet/minecraft/class_1799;method_57368(Lnet/minecraft/class_9331;Ljava/lang/Object;Ljava/util/function/UnaryOperator;)Ljava/lang/Object;official aLcuq;a(Lkp;Ljava/lang/Object;Ljava/util/function/UnaryOperator;)Ljava/lang/Object;
-
remove
Removes the componenttype. If it is in the stack's base component, it is unset and the component becomes missing. To reverse the stack-specific change, instead pass the default value asvalue.- Returns:
- the previous value set
- Mappings:
Namespace Name Mixin selector named removeLnet/minecraft/item/ItemStack;remove(Lnet/minecraft/component/ComponentType;)Ljava/lang/Object;intermediary method_57381Lnet/minecraft/class_1799;method_57381(Lnet/minecraft/class_9331;)Ljava/lang/Object;official cLcuq;c(Lkp;)Ljava/lang/Object;
-
applyChanges
- Mappings:
Namespace Name Mixin selector named applyChangesLnet/minecraft/item/ItemStack;applyChanges(Lnet/minecraft/component/ComponentChanges;)Vintermediary method_59692Lnet/minecraft/class_1799;method_59692(Lnet/minecraft/class_9326;)Vofficial aLcuq;a(Lkn;)V
-
applyUnvalidatedChanges
- Mappings:
Namespace Name Mixin selector named applyUnvalidatedChangesLnet/minecraft/item/ItemStack;applyUnvalidatedChanges(Lnet/minecraft/component/ComponentChanges;)Vintermediary method_57366Lnet/minecraft/class_1799;method_57366(Lnet/minecraft/class_9326;)Vofficial bLcuq;b(Lkn;)V
-
applyComponentsFrom
- Mappings:
Namespace Name Mixin selector named applyComponentsFromLnet/minecraft/item/ItemStack;applyComponentsFrom(Lnet/minecraft/component/ComponentMap;)Vintermediary method_57365Lnet/minecraft/class_1799;method_57365(Lnet/minecraft/class_9323;)Vofficial bLcuq;b(Lkm;)V
-
getName
Returns the custom name of the stack if it exists, or the item's name.- Returns:
- the custom name of the stack if it exists, or the item's name
- Mappings:
Namespace Name Mixin selector named getNameLnet/minecraft/item/ItemStack;getName()Lnet/minecraft/text/Text;intermediary method_7964Lnet/minecraft/class_1799;method_7964()Lnet/minecraft/class_2561;official wLcuq;w()Lwz;
-
appendTooltip
private <T extends TooltipAppender> void appendTooltip(ComponentType<T> componentType, Item.TooltipContext context, Consumer<Text> textConsumer, TooltipType type) - Mappings:
Namespace Name Mixin selector named appendTooltipLnet/minecraft/item/ItemStack;appendTooltip(Lnet/minecraft/component/ComponentType;Lnet/minecraft/item/Item$TooltipContext;Ljava/util/function/Consumer;Lnet/minecraft/item/tooltip/TooltipType;)Vintermediary method_57369Lnet/minecraft/class_1799;method_57369(Lnet/minecraft/class_9331;Lnet/minecraft/class_1792$class_9635;Ljava/util/function/Consumer;Lnet/minecraft/class_1836;)Vofficial aLcuq;a(Lkp;Lcul$b;Ljava/util/function/Consumer;Lcwm;)V
-
getTooltip
public List<Text> getTooltip(Item.TooltipContext context, @Nullable @Nullable PlayerEntity player, TooltipType type) - Mappings:
Namespace Name Mixin selector named getTooltipLnet/minecraft/item/ItemStack;getTooltip(Lnet/minecraft/item/Item$TooltipContext;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/tooltip/TooltipType;)Ljava/util/List;intermediary method_7950Lnet/minecraft/class_1799;method_7950(Lnet/minecraft/class_1792$class_9635;Lnet/minecraft/class_1657;Lnet/minecraft/class_1836;)Ljava/util/List;official aLcuq;a(Lcul$b;Lcmx;Lcwm;)Ljava/util/List;
-
appendAttributeModifiersTooltip
private void appendAttributeModifiersTooltip(Consumer<Text> textConsumer, @Nullable @Nullable PlayerEntity player) - Mappings:
Namespace Name Mixin selector named appendAttributeModifiersTooltipLnet/minecraft/item/ItemStack;appendAttributeModifiersTooltip(Ljava/util/function/Consumer;Lnet/minecraft/entity/player/PlayerEntity;)Vintermediary method_57363Lnet/minecraft/class_1799;method_57363(Ljava/util/function/Consumer;Lnet/minecraft/class_1657;)Vofficial aLcuq;a(Ljava/util/function/Consumer;Lcmx;)V
-
appendAttributeModifierTooltip
private void appendAttributeModifierTooltip(Consumer<Text> textConsumer, @Nullable @Nullable PlayerEntity player, RegistryEntry<EntityAttribute> attribute, EntityAttributeModifier modifier) - Mappings:
Namespace Name Mixin selector named appendAttributeModifierTooltipLnet/minecraft/item/ItemStack;appendAttributeModifierTooltip(Ljava/util/function/Consumer;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/registry/entry/RegistryEntry;Lnet/minecraft/entity/attribute/EntityAttributeModifier;)Vintermediary method_57364Lnet/minecraft/class_1799;method_57364(Ljava/util/function/Consumer;Lnet/minecraft/class_1657;Lnet/minecraft/class_6880;Lnet/minecraft/class_1322;)Vofficial aLcuq;a(Ljava/util/function/Consumer;Lcmx;Ljm;Lbuu;)V
-
hasGlint
public boolean hasGlint()- Mappings:
Namespace Name Mixin selector named hasGlintLnet/minecraft/item/ItemStack;hasGlint()Zintermediary method_7958Lnet/minecraft/class_1799;method_7958()Zofficial xLcuq;x()Z
-
getRarity
- Mappings:
Namespace Name Mixin selector named getRarityLnet/minecraft/item/ItemStack;getRarity()Lnet/minecraft/util/Rarity;intermediary method_7932Lnet/minecraft/class_1799;method_7932()Lnet/minecraft/class_1814;official yLcuq;y()Lcvo;
-
isEnchantable
public boolean isEnchantable()Returns whether this item stack can be enchanted with an enchanting table.This is not used for other methods of enchanting like anvils.
- Returns:
- whether this item stack can be enchanted with an enchanting table
- Mappings:
Namespace Name Mixin selector named isEnchantableLnet/minecraft/item/ItemStack;isEnchantable()Zintermediary method_7923Lnet/minecraft/class_1799;method_7923()Zofficial zLcuq;z()Z
-
addEnchantment
Enchants this item with the given enchantment and level.This should not be used with enchanted books, as the book itself is not enchanted and therefore does not store enchantments under
DataComponentTypes.ENCHANTMENTS.- See Also:
- Mappings:
Namespace Name Mixin selector named addEnchantmentLnet/minecraft/item/ItemStack;addEnchantment(Lnet/minecraft/registry/entry/RegistryEntry;I)Vintermediary method_7978Lnet/minecraft/class_1799;method_7978(Lnet/minecraft/class_6880;I)Vofficial aLcuq;a(Ljm;I)V
-
hasEnchantments
public boolean hasEnchantments()Returns whether the item stack has any enchantments.This will return
falsefor enchanted books, as the book itself is not enchanted and therefore does not store enchantments underDataComponentTypes.ENCHANTMENTS.- Returns:
- whether the item stack has any enchantments
- See Also:
- Mappings:
Namespace Name Mixin selector named hasEnchantmentsLnet/minecraft/item/ItemStack;hasEnchantments()Zintermediary method_7942Lnet/minecraft/class_1799;method_7942()Zofficial ALcuq;A()Z
-
getEnchantments
- Mappings:
Namespace Name Mixin selector named getEnchantmentsLnet/minecraft/item/ItemStack;getEnchantments()Lnet/minecraft/component/type/ItemEnchantmentsComponent;intermediary method_58657Lnet/minecraft/class_1799;method_58657()Lnet/minecraft/class_9304;official BLcuq;B()Ldai;
-
isInFrame
public boolean isInFrame()Returns whether the item stack is in an item frame.- Returns:
- whether the item stack is in an item frame
- See Also:
- Mappings:
Namespace Name Mixin selector named isInFrameLnet/minecraft/item/ItemStack;isInFrame()Zintermediary method_7961Lnet/minecraft/class_1799;method_7961()Zofficial CLcuq;C()Z
-
setHolder
Sets the stack's holder toholder.This is used by item frames and item entities, and does not need to be called for other entities.
- See Also:
- Mappings:
Namespace Name Mixin selector named setHolderLnet/minecraft/item/ItemStack;setHolder(Lnet/minecraft/entity/Entity;)Vintermediary method_27320Lnet/minecraft/class_1799;method_27320(Lnet/minecraft/class_1297;)Vofficial aLcuq;a(Lbsr;)V
-
getFrame
Returns the item frame that holds the stack, ornullif inapplicable.- Returns:
- the item frame that holds the stack, or
nullif inapplicable - See Also:
- Mappings:
Namespace Name Mixin selector named getFrameLnet/minecraft/item/ItemStack;getFrame()Lnet/minecraft/entity/decoration/ItemFrameEntity;intermediary method_7945Lnet/minecraft/class_1799;method_7945()Lnet/minecraft/class_1533;official DLcuq;D()Lcja;
-
getHolder
Returns the entity that holds the stack, ornullif inapplicable.- Returns:
- the entity that holds the stack, or
nullif inapplicable - See Also:
- Mappings:
Namespace Name Mixin selector named getHolderLnet/minecraft/item/ItemStack;getHolder()Lnet/minecraft/entity/Entity;intermediary method_27319Lnet/minecraft/class_1799;method_27319()Lnet/minecraft/class_1297;official ELcuq;E()Lbsr;
-
applyAttributeModifier
public void applyAttributeModifier(AttributeModifierSlot slot, BiConsumer<RegistryEntry<EntityAttribute>, EntityAttributeModifier> attributeModifierConsumer) - Mappings:
Namespace Name Mixin selector named applyAttributeModifierLnet/minecraft/item/ItemStack;applyAttributeModifier(Lnet/minecraft/component/type/AttributeModifierSlot;Ljava/util/function/BiConsumer;)Vintermediary method_60617Lnet/minecraft/class_1799;method_60617(Lnet/minecraft/class_9274;Ljava/util/function/BiConsumer;)Vofficial aLcuq;a(Lbsz;Ljava/util/function/BiConsumer;)V
-
applyAttributeModifiers
public void applyAttributeModifiers(EquipmentSlot slot, BiConsumer<RegistryEntry<EntityAttribute>, EntityAttributeModifier> attributeModifierConsumer) - Mappings:
Namespace Name Mixin selector named applyAttributeModifiersLnet/minecraft/item/ItemStack;applyAttributeModifiers(Lnet/minecraft/entity/EquipmentSlot;Ljava/util/function/BiConsumer;)Vintermediary method_57354Lnet/minecraft/class_1799;method_57354(Lnet/minecraft/class_1304;Ljava/util/function/BiConsumer;)Vofficial aLcuq;a(Lbsy;Ljava/util/function/BiConsumer;)V
-
toHoverableText
Returns a text consisting of the bracketed stack name that can be hovered to show the item stack's tooltip.- Returns:
- a text consisting of the bracketed stack name that can be hovered to show the item stack's tooltip
- Mappings:
Namespace Name Mixin selector named toHoverableTextLnet/minecraft/item/ItemStack;toHoverableText()Lnet/minecraft/text/Text;intermediary method_7954Lnet/minecraft/class_1799;method_7954()Lnet/minecraft/class_2561;official FLcuq;F()Lwz;
-
canPlaceOn
- Mappings:
Namespace Name Mixin selector named canPlaceOnLnet/minecraft/item/ItemStack;canPlaceOn(Lnet/minecraft/block/pattern/CachedBlockPosition;)Zintermediary method_57357Lnet/minecraft/class_1799;method_57357(Lnet/minecraft/class_2694;)Zofficial aLcuq;a(Ldtg;)Z
-
canBreak
- Mappings:
Namespace Name Mixin selector named canBreakLnet/minecraft/item/ItemStack;canBreak(Lnet/minecraft/block/pattern/CachedBlockPosition;)Zintermediary method_57373Lnet/minecraft/class_1799;method_57373(Lnet/minecraft/class_2694;)Zofficial bLcuq;b(Ldtg;)Z
-
getBobbingAnimationTime
public int getBobbingAnimationTime()- Mappings:
Namespace Name Mixin selector named getBobbingAnimationTimeLnet/minecraft/item/ItemStack;getBobbingAnimationTime()Iintermediary method_7965Lnet/minecraft/class_1799;method_7965()Iofficial GLcuq;G()I
-
setBobbingAnimationTime
public void setBobbingAnimationTime(int bobbingAnimationTime) - Mappings:
Namespace Name Mixin selector named setBobbingAnimationTimeLnet/minecraft/item/ItemStack;setBobbingAnimationTime(I)Vintermediary method_7912Lnet/minecraft/class_1799;method_7912(I)Vofficial dLcuq;d(I)V
-
getCount
public int getCount()Returns the count of items in this item stack.- Returns:
- the count of items in this item stack
- Mappings:
Namespace Name Mixin selector named getCountLnet/minecraft/item/ItemStack;getCount()Iintermediary method_7947Lnet/minecraft/class_1799;method_7947()Iofficial HLcuq;H()I
-
setCount
public void setCount(int count) Sets the count of items in this item stack.- Parameters:
count- the count of items- Mappings:
Namespace Name Mixin selector named setCountLnet/minecraft/item/ItemStack;setCount(I)Vintermediary method_7939Lnet/minecraft/class_1799;method_7939(I)Vofficial eLcuq;e(I)V
-
capCount
public void capCount(int maxCount) Sets the count of items in this item stack to not exceedmaxCount.- Mappings:
Namespace Name Mixin selector named capCountLnet/minecraft/item/ItemStack;capCount(I)Vintermediary method_58408Lnet/minecraft/class_1799;method_58408(I)Vofficial fLcuq;f(I)V
-
increment
public void increment(int amount) Increments the count of items in this item stack.- Parameters:
amount- the amount to increment- Mappings:
Namespace Name Mixin selector named incrementLnet/minecraft/item/ItemStack;increment(I)Vintermediary method_7933Lnet/minecraft/class_1799;method_7933(I)Vofficial gLcuq;g(I)V
-
decrement
public void decrement(int amount) Decrements the count of items in this item stack.- Parameters:
amount- the amount to decrement- Mappings:
Namespace Name Mixin selector named decrementLnet/minecraft/item/ItemStack;decrement(I)Vintermediary method_7934Lnet/minecraft/class_1799;method_7934(I)Vofficial hLcuq;h(I)V
-
decrementUnlessCreative
Decrements the count of items in this item stack, unlessentityis a creative mode player.- Mappings:
Namespace Name Mixin selector named decrementUnlessCreativeLnet/minecraft/item/ItemStack;decrementUnlessCreative(ILnet/minecraft/entity/LivingEntity;)Vintermediary method_57008Lnet/minecraft/class_1799;method_57008(ILnet/minecraft/class_1309;)Vofficial aLcuq;a(ILbtn;)V
-
splitUnlessCreative
- Mappings:
Namespace Name Mixin selector named splitUnlessCreativeLnet/minecraft/item/ItemStack;splitUnlessCreative(ILnet/minecraft/entity/LivingEntity;)Lnet/minecraft/item/ItemStack;intermediary method_60504Lnet/minecraft/class_1799;method_60504(ILnet/minecraft/class_1309;)Lnet/minecraft/class_1799;official bLcuq;b(ILbtn;)Lcuq;
-
usageTick
- Mappings:
Namespace Name Mixin selector named usageTickLnet/minecraft/item/ItemStack;usageTick(Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;I)Vintermediary method_7949Lnet/minecraft/class_1799;method_7949(Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;I)Vofficial bLcuq;b(Ldcw;Lbtn;I)V
-
onItemEntityDestroyed
- Mappings:
Namespace Name Mixin selector named onItemEntityDestroyedLnet/minecraft/item/ItemStack;onItemEntityDestroyed(Lnet/minecraft/entity/ItemEntity;)Vintermediary method_33262Lnet/minecraft/class_1799;method_33262(Lnet/minecraft/class_1542;)Vofficial aLcuq;a(Lcjh;)V
-
getDrinkSound
- Mappings:
Namespace Name Mixin selector named getDrinkSoundLnet/minecraft/item/ItemStack;getDrinkSound()Lnet/minecraft/sound/SoundEvent;intermediary method_21832Lnet/minecraft/class_1799;method_21832()Lnet/minecraft/class_3414;official ILcuq;I()Lavo;
-
getEatSound
- Mappings:
Namespace Name Mixin selector named getEatSoundLnet/minecraft/item/ItemStack;getEatSound()Lnet/minecraft/sound/SoundEvent;intermediary method_21833Lnet/minecraft/class_1799;method_21833()Lnet/minecraft/class_3414;official JLcuq;J()Lavo;
-
getBreakSound
- Mappings:
Namespace Name Mixin selector named getBreakSoundLnet/minecraft/item/ItemStack;getBreakSound()Lnet/minecraft/sound/SoundEvent;intermediary method_57351Lnet/minecraft/class_1799;method_57351()Lnet/minecraft/class_3414;official KLcuq;K()Lavo;
-
takesDamageFrom
- Mappings:
Namespace Name Mixin selector named takesDamageFromLnet/minecraft/item/ItemStack;takesDamageFrom(Lnet/minecraft/entity/damage/DamageSource;)Zintermediary method_58407Lnet/minecraft/class_1799;method_58407(Lnet/minecraft/class_1282;)Zofficial aLcuq;a(Lbrk;)Z
-