Interface ItemStack
- All Superinterfaces:
ComponentLike,CopyableDataHolder,DataHolder,DataHolder.Mutable,DataSerializable,HoverEventSource<HoverEvent.ShowItem>,ItemStackLike,SerializableDataHolder,SerializableDataHolder.Mutable,ValueContainer
Represents mutable
ItemStackLike. Can be compared
using the comparators listed in ItemStackComparators.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interfaceNested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.MutableNested classes/interfaces inherited from interface org.spongepowered.api.data.SerializableDataHolder
SerializableDataHolder.Immutable<I extends SerializableDataHolder.Immutable<I>>, SerializableDataHolder.Mutable -
Method Summary
Modifier 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.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.default ItemStackSnapshotDeprecated, for removal: This API element is subject to removal in a future version.static ItemStackempty()Returns an emptyItemStack.booleanstatic ItemStackstatic ItemStackstatic ItemStackstatic ItemStackvoidsetQuantity(int quantity) Sets the quantity in this stack.Methods inherited from interface net.kyori.adventure.text.ComponentLike
asComponentMethods inherited from interface org.spongepowered.api.data.DataHolder.Mutable
copyFrom, 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.DataSerializable
contentVersion, toContainerMethods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEvent, asHoverEventMethods inherited from interface org.spongepowered.api.item.inventory.ItemStackLike
asImmutable, asMutable, asMutableCopy, attributeModifiers, attributeModifiers, attributeModifiers, attributeModifiers, isEmpty, maxStackQuantity, quantity, typeMethods inherited from interface org.spongepowered.api.data.SerializableDataHolder
validateRawDataMethods inherited from interface org.spongepowered.api.data.SerializableDataHolder.Mutable
setRawData
-
Method Details
-
empty
Returns an emptyItemStack.- Returns:
- The empty ItemStack
-
builder
Creates a newItemStack.Builderto build anItemStack.- Returns:
- The new builder
-
of
- Parameters:
itemType- The item typequantity- The quantity- Returns:
- The new item stack
-
of
- Parameters:
itemType- The item typequantity- 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
-
setQuantity
Sets the quantity in this stack.- Parameters:
quantity- Quantity- Throws:
IllegalArgumentException- If quantity set exceeds theItemStackLike.maxStackQuantity()
-
createSnapshot
Deprecated, for removal: This API element is subject to removal in a future version.UseItemStackLike.asImmutable()instead. -
equalTo
Returns 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
-
addAttributeModifier
default 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.
-
addAttributeModifier
default 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.
-
addAttributeModifier
default 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.
-
addAttributeModifier
void 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.
-
copy
ItemStack 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 interfaceCopyableDataHolder- Specified by:
copyin interfaceItemStackLike- Specified by:
copyin interfaceSerializableDataHolder- Specified by:
copyin interfaceSerializableDataHolder.Mutable- Returns:
- The new copy
-
ItemStackLike.asImmutable()instead.