public interface ItemStack extends DataHolder, Translatable
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 CompositeValueStore.get(Class) in order to retrieve information regarding
this item stack.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
ItemStack.Builder |
| Modifier and Type | Method and Description |
|---|---|
static ItemStack.Builder |
builder()
Creates a new
ItemStack.Builder to build an ItemStack. |
ItemStack |
copy()
Creates a clone copy of this
ValueContainer as a new
ValueContainer such that all the BaseValues are
safely duplicated to the new instance. |
ItemStackSnapshot |
createSnapshot()
Gets the
ItemStackSnapshot of this ItemStack. |
static ItemStack |
empty()
Returns an empty
ItemStack. |
boolean |
equalTo(ItemStack that)
|
default ItemType |
getItem()
Deprecated.
Use
getType() |
int |
getMaxStackQuantity()
Gets the maximum quantity per stack.
|
int |
getQuantity()
Gets the quantity of items in this stack.
|
ItemType |
getType()
|
boolean |
isEmpty()
Returns true if
getQuantity() is zero and therefore this
ItemStack is empty. |
static ItemStack |
of(ItemType itemType)
|
static ItemStack |
of(ItemType itemType,
int quantity)
|
void |
setQuantity(int quantity)
Sets the quantity in this stack.
|
setRawData, validateRawDatagetContentVersion, toContainergetApplicableProperties, getPropertycopyFrom, copyFrom, get, getContainers, getOrCreate, offer, offer, offer, offer, offer, offer, remove, remove, remove, require, supports, transform, tryOffer, tryOffer, tryOffer, tryOffer, undoget, getKeys, getOrElse, getOrNull, getValue, getValues, require, supports, supportsgetTranslationstatic ItemStack.Builder builder()
ItemStack.Builder to build an ItemStack.static ItemStack of(ItemType itemType, int quantity)
itemType - The item typequantity - The quantitystatic ItemStack of(ItemType itemType)
itemType - The item type@Deprecated default ItemType getItem()
getType()ItemType getType()
int getQuantity()
void setQuantity(int quantity)
throws IllegalArgumentException
quantity - QuantityIllegalArgumentException - If quantity set exceeds the
getMaxStackQuantity()int getMaxStackQuantity()
ItemType.getMaxStackQuantity(), unless a
different value has been set for this specific stack.ItemStackSnapshot createSnapshot()
ItemStackSnapshot of this ItemStack. All known
DataManipulators existing on this ItemStack are added
as copies to the ItemStackSnapshot.boolean equalTo(ItemStack that)
ItemStack has the same stack
size, ItemType, and data. Note that this method is not an
overrider of Object.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 as
Maps or Sets.that - ItemStack to compareboolean isEmpty()
getQuantity() is zero and therefore this
ItemStack is empty.
In Vanilla empty ItemStacks are not rendered by the client.
ItemStack copy()
ValueContainerValueContainer as a new
ValueContainer such that all the BaseValues are
safely duplicated to the new instance.copy in interface ValueContainer<DataHolder>