Interface ItemStack
- All Superinterfaces:
- ComponentLike,- CopyableDataHolder,- DataHolder,- DataHolder.Mutable,- DataSerializable,- HoverEventSource<HoverEvent.ShowItem>,- SerializableDataHolder,- SerializableDataHolder.Mutable,- ValueContainer
public interface ItemStack
extends SerializableDataHolder.Mutable, ComponentLike, HoverEventSource<HoverEvent.ShowItem>
Represents a stack of a specific 
ItemType. Supports serialization and
 can be compared using the comparators listed in ItemStackComparators.
 ItemStacks have a variety of properties and data. It is advised to
 use ValueContainer.get(Key) in order to retrieve information regarding
 this item stack.
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interfaceNested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolderDataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.MutableNested classes/interfaces inherited from interface org.spongepowered.api.data.SerializableDataHolderSerializableDataHolder.Immutable<I extends SerializableDataHolder.Immutable<I>>, SerializableDataHolder.Mutable
- 
Method SummaryModifier and TypeMethodDescriptiondefault voidaddAttributeModifier(Supplier<? extends AttributeType> attributeType, AttributeModifier modifier, EquipmentType equipmentType) Adds anAttributeModifierto this item stack.default voidaddAttributeModifier(Supplier<? extends AttributeType> attributeType, AttributeModifier modifier, DefaultedRegistryReference<? extends EquipmentType> equipmentType) Adds anAttributeModifierto this item stack.voidaddAttributeModifier(AttributeType attributeType, AttributeModifier modifier, EquipmentType equipmentType) Adds anAttributeModifierto this item stack.default voidaddAttributeModifier(AttributeType attributeType, AttributeModifier modifier, DefaultedRegistryReference<? extends EquipmentType> equipmentType) Adds anAttributeModifierto this item stack.default Collection<AttributeModifier> attributeModifiers(Supplier<? extends AttributeType> attributeType, EquipmentType equipmentType) Gets allAttributeModifiers on this item stack.default Collection<AttributeModifier> attributeModifiers(Supplier<? extends AttributeType> attributeType, DefaultedRegistryReference<? extends EquipmentType> equipmentType) Gets allAttributeModifiers on this item stack.attributeModifiers(AttributeType attributeType, EquipmentType equipmentType) Gets allAttributeModifiers on this item stack.default Collection<AttributeModifier> attributeModifiers(AttributeType attributeType, DefaultedRegistryReference<? extends EquipmentType> equipmentType) Gets allAttributeModifiers on this item stack.static ItemStack.Builderbuilder()Creates a newItemStack.Builderto build anItemStack.copy()Creates a clone copy of thisCopyableDataHolderas a newCopyableDataHoldersuch that all theValues are safely duplicated to the new instance.Gets theItemStackSnapshotof thisItemStack.static ItemStackempty()Returns an emptyItemStack.booleanbooleanisEmpty()Returns true ifquantity()is zero and therefore this ItemStack is empty.intGets the maximum quantity per stack.static ItemStackstatic ItemStackstatic ItemStackstatic ItemStackintquantity()Gets the quantity of items in this stack.voidsetQuantity(int quantity) Sets the quantity in this stack.type()Methods inherited from interface net.kyori.adventure.text.ComponentLikeasComponentMethods inherited from interface org.spongepowered.api.data.DataHolder.MutablecopyFrom, copyFrom, offer, offer, offer, offer, offerAll, offerAll, offerAll, offerAll, offerAll, offerAll, offerSingle, offerSingle, offerSingle, offerSingle, remove, remove, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeAll, removeKey, removeKey, removeSingle, removeSingle, transform, transform, tryOffer, tryOffer, tryOffer, undoMethods inherited from interface org.spongepowered.api.data.persistence.DataSerializablecontentVersion, toContainerMethods inherited from interface net.kyori.adventure.text.event.HoverEventSourceasHoverEvent, asHoverEventMethods inherited from interface org.spongepowered.api.data.SerializableDataHoldervalidateRawDataMethods inherited from interface org.spongepowered.api.data.SerializableDataHolder.MutablesetRawData
- 
Method Details- 
emptyReturns an emptyItemStack.- Returns:
- The empty ItemStack
 
- 
builderCreates a newItemStack.Builderto build anItemStack.- Returns:
- The new builder
 
- 
of- Parameters:
- itemType- The item type
- quantity- The quantity
- Returns:
- The new item stack
 
- 
of- Parameters:
- itemType- The item type
- quantity- The quantity
- Returns:
- The new item stack
 
- 
of- Parameters:
- itemType- The item type
- Returns:
- The new item stack
 
- 
of- Parameters:
- itemType- The item type
- Returns:
- The new item stack
 
- 
typeItemType type()- Returns:
- The item type
 
- 
quantityint quantity()Gets the quantity of items in this stack. This may exceed the max stack size of the item, and if added to an inventory will then be divided by the max stack.- Returns:
- Quantity of items
 
- 
setQuantitySets the quantity in this stack.- Parameters:
- quantity- Quantity
- Throws:
- IllegalArgumentException- If quantity set exceeds the- maxStackQuantity()
 
- 
maxStackQuantityint maxStackQuantity()Gets the maximum quantity per stack. By default, returnsItemType.maxStackQuantity(), unless a different value has been set for this specific stack.- Returns:
- Max stack quantity
 
- 
createSnapshotItemStackSnapshot createSnapshot()Gets theItemStackSnapshotof thisItemStack. All knownValues existing on thisItemStackare added as copies to theItemStackSnapshot.- Returns:
- The newly created item stack snapshot
 
- 
equalToReturns true if the specifiedItemStackhas the same stack size,ItemType, and data. Note that this method is not an overrider ofObject.equals(Object)in order to maintain compatibility with the base game. Therefore, ItemStacks may not behave as expected when using them in equality based constructs such asMaps orSets.- Parameters:
- that- ItemStack to compare
- Returns:
- True if this equals the ItemStack
 
- 
isEmptyboolean isEmpty()Returns true ifquantity()is zero and therefore this ItemStack is empty.In Vanilla empty ItemStacks are not rendered by the client. - Returns:
- True if this ItemStack is empty
 
- 
attributeModifiersdefault Collection<AttributeModifier> attributeModifiers(Supplier<? extends AttributeType> attributeType, DefaultedRegistryReference<? extends EquipmentType> equipmentType) Gets allAttributeModifiers on this item stack.- Parameters:
- attributeType- The- AttributeTypeof the modifier.
- equipmentType- The- EquipmentTypethis modifier is applied to.
- Returns:
- A collection of AttributeModifiers.
 
- 
attributeModifiersdefault Collection<AttributeModifier> attributeModifiers(AttributeType attributeType, DefaultedRegistryReference<? extends EquipmentType> equipmentType) Gets allAttributeModifiers on this item stack.- Parameters:
- attributeType- The- AttributeTypeof the modifier.
- equipmentType- The- EquipmentTypethis modifier is applied to.
- Returns:
- A collection of AttributeModifiers.
 
- 
attributeModifiersdefault Collection<AttributeModifier> attributeModifiers(Supplier<? extends AttributeType> attributeType, EquipmentType equipmentType) Gets allAttributeModifiers on this item stack.- Parameters:
- attributeType- The- AttributeTypeof the modifier.
- equipmentType- The- EquipmentTypethis modifier is applied to.
- Returns:
- A collection of AttributeModifiers.
 
- 
attributeModifiersCollection<AttributeModifier> attributeModifiers(AttributeType attributeType, EquipmentType equipmentType) Gets allAttributeModifiers on this item stack.- Parameters:
- attributeType- The- AttributeTypeof the modifier.
- equipmentType- The- EquipmentTypethis modifier is applied to.
- Returns:
- A collection of AttributeModifiers.
 
- 
addAttributeModifierdefault void addAttributeModifier(Supplier<? extends AttributeType> attributeType, AttributeModifier modifier, EquipmentType equipmentType) Adds anAttributeModifierto this item stack.- Parameters:
- attributeType- The attribute type.
- modifier- The attribute modifier.
- equipmentType- The equipment type this modifier will apply under.
 
- 
addAttributeModifierdefault void addAttributeModifier(AttributeType attributeType, AttributeModifier modifier, DefaultedRegistryReference<? extends EquipmentType> equipmentType) Adds anAttributeModifierto this item stack.- Parameters:
- attributeType- The attribute type.
- modifier- The attribute modifier.
- equipmentType- The equipment type this modifier will apply under.
 
- 
addAttributeModifierdefault void addAttributeModifier(Supplier<? extends AttributeType> attributeType, AttributeModifier modifier, DefaultedRegistryReference<? extends EquipmentType> equipmentType) Adds anAttributeModifierto this item stack.- Parameters:
- attributeType- The attribute type.
- modifier- The attribute modifier.
- equipmentType- The equipment type this modifier will apply under.
 
- 
addAttributeModifiervoid addAttributeModifier(AttributeType attributeType, AttributeModifier modifier, EquipmentType equipmentType) Adds anAttributeModifierto this item stack.- Parameters:
- attributeType- The attribute type.
- modifier- The attribute modifier.
- equipmentType- The equipment type this modifier will apply under.
 
- 
copyItemStack copy()Description copied from interface:CopyableDataHolderCreates a clone copy of thisCopyableDataHolderas a newCopyableDataHoldersuch that all theValues are safely duplicated to the new instance. It is not guaranteed that the returning container is of the same type as this container.- Specified by:
- copyin interface- CopyableDataHolder
- Specified by:
- copyin interface- SerializableDataHolder
- Specified by:
- copyin interface- SerializableDataHolder.Mutable
- Returns:
- The new copy
 
 
-