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.DataComponentType<? extends T>) or ComponentHolder.getOrDefault(net.minecraft.component.DataComponentType<? extends T>, T) to
get the component values. Use set(net.minecraft.component.DataComponentType<? super T>, T) or remove(net.minecraft.component.DataComponentType<? 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 cto
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intstatic final com.mojang.serialization.Codec<ItemStack> (package private) final ComponentMapImplstatic final com.mojang.serialization.Codec<ItemStack> private intprivate static final Textstatic final ItemStackThe empty item stack that holds no item.Deprecated.private 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> -
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(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(DataComponentType<T> componentType, Consumer<Text> textConsumer, TooltipContext context) <T> Tapply(DataComponentType<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(DataComponentType<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.voidapplyAttributeModifiers(EquipmentSlot slot, BiConsumer<RegistryEntry<EntityAttribute>, EntityAttributeModifier> attributeModifierConsumer) voidapplyChanges(ComponentChanges changes) voidapplyComponentsFrom(ComponentMap components) 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.copyComponentsToNewStackIgnoreEmpty(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 com.mojang.serialization.MapCodec<ItemStack> createOptionalCodec(String fieldName) voiddamage(int amount, LivingEntity entity, EquipmentSlot slot) Damages this item stack.voiddamage(int amount, Random random, @Nullable ServerPlayerEntity player, Runnable 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).intintintfloatgetName()Returns the custom name of the stack if it exists, or the item's name.getTooltip(@Nullable PlayerEntity player, TooltipContext context) 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) voidpostHit(LivingEntity target, PlayerEntity attacker) voidpostMine(World world, BlockState state, BlockPos pos, PlayerEntity miner) <T> Tremove(DataComponentType<? extends T> type) Removes the componenttype.<T> Tset(DataComponentType<? 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.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> 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 jLcto;j: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 aLcto;a:Lcom/mojang/serialization/Codec;
-
COOKING_RECIPE_RESULT_CODEC
- Mappings:
Namespace Name Mixin selector named COOKING_RECIPE_RESULT_CODECLnet/minecraft/item/ItemStack;COOKING_RECIPE_RESULT_CODEC:Lcom/mojang/serialization/Codec;intermediary field_49747Lnet/minecraft/class_1799;field_49747:Lcom/mojang/serialization/Codec;official bLcto;b: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 cLcto;c: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 dLcto;d: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 eLcto;e:Lyv;
-
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 fLcto;f:Lyv;
-
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 gLcto;g:Lyv;
-
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 hLcto;h:Lyv;
-
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 kLcto;k: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 iLcto;i:Lcto;
-
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 lLcto;l:Lwx;
-
count
private int count- Mappings:
Namespace Name Mixin selector named countLnet/minecraft/item/ItemStack;count:Iintermediary field_8031Lnet/minecraft/class_1799;field_8031:Iofficial mLcto;m: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 nLcto;n: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 oLcto;o:Lctj;
-
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 pLcto;p:Lkc;
-
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 qLcto;q:Lbru;
-
-
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>Lcto;<init>(Ldaw;)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>Lcto;<init>(Lix;)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>Lcto;<init>(Lix;ILjy;)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>Lcto;<init>(Lix;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>Lcto;<init>(Ldaw;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>Lcto;<init>(Ldaw;ILkc;)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>Lcto;<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 bLcto;b(Lcto;)Lcom/mojang/serialization/DataResult;
-
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 bLcto;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 aLjw;a()Ljx;
-
method_58658
- Mappings:
Namespace Name Mixin selector named method_58658Lnet/minecraft/item/ItemStack;method_58658()Lnet/minecraft/component/ComponentMap;intermediary method_58658Lnet/minecraft/class_1799;method_58658()Lnet/minecraft/class_9323;official cLcto;c()Ljx;
-
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 dLcto;d()Ljy;
-
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 aLcto;a(Liz$a;Lva;)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 aLcto;a(Liz$a;Lud;)Lcto;
-
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 eLcto;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 aLcto;a(Lcoj;)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 aLcto;a(I)Lcto;
-
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 fLcto;f()Lcto;
-
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 gLcto;g()Lctj;
-
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 hLcto;h()Lix;
-
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 aLcto;a(Lawl;)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 aLcto;a(Lctj;)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 aLcto;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 aLcto;a(Lix;)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 aLcto;a(Ljb;)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 iLcto;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 aLcto;a(Lcxb;)Lbpu;
-
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 aLcto;a(Ldrb;)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 aLcto;a(Ldax;Lclw;Lbpt;)Lbpv;
-
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 aLcto;a(Ldax;Lbso;)Lcto;
-
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 bLcto;b(Liz$a;Lva;)Lva;
-
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 aLcto;a(Liz$a;)Lva;
-
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 bLcto;b(Liz$a;)Lva;
-
getMaxCount
public int getMaxCount()- Mappings:
Namespace Name Mixin selector named getMaxCountLnet/minecraft/item/ItemStack;getMaxCount()Iintermediary method_7914Lnet/minecraft/class_1799;method_7914()Iofficial jLcto;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 kLcto;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 lLcto;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 mLcto;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 nLcto;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 bLcto;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 oLcto;o()I
-
damage
public void damage(int amount, Random random, @Nullable @Nullable ServerPlayerEntity player, Runnable 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 unbreaking enchantment is 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. Callers should decrement the stack size inside the callback.- Parameters:
player- the player that damaged the stack, ornullif no player is involvedbreakCallback- a callback run when the item "breaks"- Mappings:
Namespace Name Mixin selector named damageLnet/minecraft/item/ItemStack;damage(ILnet/minecraft/util/math/random/Random;Lnet/minecraft/server/network/ServerPlayerEntity;Ljava/lang/Runnable;)Vintermediary method_7956Lnet/minecraft/class_1799;method_7956(ILnet/minecraft/class_5819;Lnet/minecraft/class_3222;Ljava/lang/Runnable;)Vofficial aLcto;a(ILayk;Laqn;Ljava/lang/Runnable;)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 unbreaking enchantment is 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 aLcto;a(ILbso;Lbsb;)V
-
isItemBarVisible
public boolean isItemBarVisible()- Mappings:
Namespace Name Mixin selector named isItemBarVisibleLnet/minecraft/item/ItemStack;isItemBarVisible()Zintermediary method_31578Lnet/minecraft/class_1799;method_31578()Zofficial pLcto;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 qLcto;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 rLcto;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 aLcto;a(Lcqo;Lcpb;Lclw;)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 aLcto;a(Lcto;Lcqo;Lcpb;Lclw;Lbtg;)Z
-
postHit
- Mappings:
Namespace Name Mixin selector named postHitLnet/minecraft/item/ItemStack;postHit(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/player/PlayerEntity;)Vintermediary method_7979Lnet/minecraft/class_1799;method_7979(Lnet/minecraft/class_1309;Lnet/minecraft/class_1657;)Vofficial aLcto;a(Lbso;Lclw;)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 aLcto;a(Ldax;Ldrb;Lio;Lclw;)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
invalid reference
Item#isSuitableFor - 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 bLcto;b(Ldrb;)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 aLcto;a(Lclw;Lbso;Lbpt;)Lbpu;
-
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 sLcto;s()Lcto;
-
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 cLcto;c(I)Lcto;
-
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 aLcto;a(Ldaw;I)Lcto;
-
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 bLcto;b(Ldaw;I)Lcto;
-
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 aLcto;a(Lcto;Lcto;)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 aLcto;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 bLcto;b(Lcto;Lcto;)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 cLcto;c(Lcto;Lcto;)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 aLcto;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 aLcto;a(Lcto;)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 aLcto;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 tLcto;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 aLcto;a(Ldax;Lbru;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 aLcto;a(Ldax;Lclw;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 aLcto;a(Ldax;)V
-
getMaxUseTime
public int getMaxUseTime()- Mappings:
Namespace Name Mixin selector named getMaxUseTimeLnet/minecraft/item/ItemStack;getMaxUseTime()Iintermediary method_7935Lnet/minecraft/class_1799;method_7935()Iofficial uLcto;u()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 vLcto;v()Lcvj;
-
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 aLcto;a(Ldax;Lbso;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 wLcto;w()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/DataComponentType;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 bLcto;b(Lka;Ljava/lang/Object;)Ljava/lang/Object;
-
apply
@Nullable public <T,U> T apply(DataComponentType<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/DataComponentType;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 aLcto;a(Lka;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/DataComponentType;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 aLcto;a(Lka;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/DataComponentType;)Ljava/lang/Object;intermediary method_57381Lnet/minecraft/class_1799;method_57381(Lnet/minecraft/class_9331;)Ljava/lang/Object;official cLcto;c(Lka;)Ljava/lang/Object;
-
applyChanges
- Mappings:
Namespace Name Mixin selector named applyChangesLnet/minecraft/item/ItemStack;applyChanges(Lnet/minecraft/component/ComponentChanges;)Vintermediary method_57366Lnet/minecraft/class_1799;method_57366(Lnet/minecraft/class_9326;)Vofficial aLcto;a(Ljy;)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 aLcto;a(Ljx;)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 xLcto;x()Lwx;
-
appendTooltip
private <T extends TooltipAppender> void appendTooltip(DataComponentType<T> componentType, Consumer<Text> textConsumer, TooltipContext context) - Mappings:
Namespace Name Mixin selector named appendTooltipLnet/minecraft/item/ItemStack;appendTooltip(Lnet/minecraft/component/DataComponentType;Ljava/util/function/Consumer;Lnet/minecraft/client/item/TooltipContext;)Vintermediary method_57369Lnet/minecraft/class_1799;method_57369(Lnet/minecraft/class_9331;Ljava/util/function/Consumer;Lnet/minecraft/class_1836;)Vofficial aLcto;a(Lka;Ljava/util/function/Consumer;Lcvh;)V
-
getTooltip
- Mappings:
Namespace Name Mixin selector named getTooltipLnet/minecraft/item/ItemStack;getTooltip(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/client/item/TooltipContext;)Ljava/util/List;intermediary method_7950Lnet/minecraft/class_1799;method_7950(Lnet/minecraft/class_1657;Lnet/minecraft/class_1836;)Ljava/util/List;official aLcto;a(Lclw;Lcvh;)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 aLcto;a(Ljava/util/function/Consumer;Lclw;)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 aLcto;a(Ljava/util/function/Consumer;Lclw;Lix;Lbtu;)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 yLcto;y()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 zLcto;z()Lcui;
-
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 ALcto;A()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/enchantment/Enchantment;I)Vintermediary method_7978Lnet/minecraft/class_1799;method_7978(Lnet/minecraft/class_1887;I)Vofficial aLcto;a(Lcyz;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 BLcto;B()Z
-
method_58657
- Mappings:
Namespace Name Mixin selector named method_58657Lnet/minecraft/item/ItemStack;method_58657()Lnet/minecraft/component/type/ItemEnchantmentsComponent;intermediary method_58657Lnet/minecraft/class_1799;method_58657()Lnet/minecraft/class_9304;official CLcto;C()Lcze;
-
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 DLcto;D()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 aLcto;a(Lbru;)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 ELcto;E()Lchz;
-
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 FLcto;F()Lbru;
-
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 aLcto;a(Lbsb;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 GLcto;G()Lwx;
-
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 aLcto;a(Ldrf;)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 bLcto;b(Ldrf;)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 HLcto;H()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 dLcto;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 ILcto;I()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 eLcto;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 fLcto;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 gLcto;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 hLcto;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 aLcto;a(ILbso;)V
-
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 bLcto;b(Ldax;Lbso;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 aLcto;a(Lcig;)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 JLcto;J()Lavg;
-
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 KLcto;K()Lavg;
-
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 LLcto;L()Lavg;
-
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 aLcto;a(Lbqn;)Z
-