Contents
- Description
- Nested Class Summary
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- getItemId()
- getQuantity()
- getMetadata()
- isUnbreakable()
- isBroken()
- getMaxDurability()
- getDurability()
- getQualityIndex()
- isEmpty()
- getOverrideDroppedItemAnimation()
- setOverrideDroppedItemAnimation(boolean)
- getBlockKey()
- getItem()
- isValid()
- withDurability(double)
- withMaxDurability(double)
- withQuality(int)
- withIncreasedDurability(double)
- withRestoredDurability(double)
- withState(String)
- withQuantity(int)
- cleanCopy()
- withMetadata(BsonDocument)
- withMetadata(KeyedCodec, T)
- withMetadata(String, Codec, T)
- withMetadata(String, BsonValue)
- toPacket()
- isStackableWith(ItemStack)
- isEquivalentType(ItemStack)
- getFromMetadataOrNull(KeyedCodec)
- getFromMetadataOrNull(String, Codec)
- getFromMetadataOrDefault(String, BuilderCodec)
- getDisplayName()
- getDisplayDescription()
- equals(Object)
- hashCode()
- toString()
- isEmpty(ItemStack)
- isStackableWith(ItemStack, ItemStack)
- isEquivalentType(ItemStack, ItemStack)
- isSameItemType(ItemStack, ItemStack)
Class ItemStack
java.lang.Object
com.hypixel.hytale.server.core.inventory.ItemStack
- All Implemented Interfaces:
NetworkSerializable<ItemWithAllMetadata>
Represents a quantified collection of an item. Useful for representing an item with a specific quantity or data.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for anItemStackinstance.Constructor for anItemStackinstance.ItemStack(String itemId, int quantity, double durability, double maxDurability, int qualityIndexOverride, org.bson.BsonDocument metadata) Constructor for anItemStackinstance.ItemStack(String itemId, int quantity, double durability, double maxDurability, org.bson.BsonDocument metadata) Constructor for anItemStackinstance.Constructor for anItemStackinstance. -
Method Summary
Modifier and TypeMethodDescriptionCalled to fetch a copy of this item stack without transient runtime flags.booleanCalled to fetch the block key of the item associated with this item stack.double<T> TgetFromMetadataOrDefault(String key, BuilderCodec<T> codec) <T> TgetFromMetadataOrNull(KeyedCodec<T> keyedCodec) <T> TgetFromMetadataOrNull(String key, Codec<T> codec) getItem()doubleorg.bson.BsonDocumentDeprecated.booleanDetermines whether to override the dropped item animation for this item stack.intintinthashCode()booleanisBroken()Determines whether this item stack is broken.booleanisEmpty()Determines whether this item stack is considered empty.static booleanbooleanisEquivalentType(ItemStack itemStack) Compares if the two ItemStack's are of the same 'type'static booleanstatic booleanisSameItemType(ItemStack a, ItemStack b) booleanisStackableWith(ItemStack itemStack) Compares if the two ItemStack's are allowed to be stacked together.static booleanbooleanDetermines whether this item stack is unbreakable.booleanisValid()Determines whether this item stack is considered valid.voidsetOverrideDroppedItemAnimation(boolean b) Called to set whether to override the dropped item animation for this item stack.toPacket()toString()withDurability(double durability) Called to fetch a copy of this item stack, reconfigured with the provided durability.withIncreasedDurability(double inc) Called to fetch a copy of this item stack, increasing its durability with the provided amount.withMaxDurability(double maxDurability) Called to fetch a copy of this item stack, reconfigured with the provided max durability.<T> ItemStackwithMetadata(KeyedCodec<T> keyedCodec, T data) <T> ItemStackwithMetadata(String key, Codec<T> codec, T data) withMetadata(String key, org.bson.BsonValue bsonValue) withMetadata(org.bson.BsonDocument metadata) Called to fetch a copy of this item stack, reconfigured with the given metadata.withQuality(int quality) Called to fetch a copy of this item stack, reconfigured with the provided quality index.withQuantity(int quantity) Called to fetch a copy of this item stack, reconfigured with the new quantity.withRestoredDurability(double maxDurability) Called to fetch a copy of this item stack, increasing its max durability with the provided amount.Called to fetch a copy of this item stack, reconfigured with the new item from the provided state.
-
Field Details
-
EMPTY_ARRAY
-
CODEC
The codec used to parseItemStackinstances. -
EMPTY
Represents an empty item stack that can be used where needed.
-
-
Constructor Details
-
ItemStack
-
ItemStack
public ItemStack(@Nonnull String itemId, int quantity, double durability, double maxDurability, @Nullable org.bson.BsonDocument metadata) Constructor for anItemStackinstance.- Parameters:
itemId- The block type key of the associated item.quantity- The quantity of the item stack.durability- The current durability of this item stack.maxDurability- The maximum durability of this item stack.metadata- The additional metadata of this item stack.
-
ItemStack
public ItemStack(@Nonnull String itemId, int quantity, double durability, double maxDurability, int qualityIndexOverride, @Nullable org.bson.BsonDocument metadata) Constructor for anItemStackinstance.- Parameters:
itemId- The block type key of the associated item.quantity- The quantity of the item stack.durability- The current durability of this item stack.maxDurability- The maximum durability of this item stack.qualityIndexOverride- The quality index of this item stack, overriding the item's configured quality.metadata- The additional metadata of this item stack.
-
ItemStack
-
ItemStack
-
-
Method Details
-
getItemId
- Returns:
- the block type key of the item associate with this item stack.
-
getQuantity
public int getQuantity()- Returns:
- the quantity of this item stack.
-
getMetadata
Deprecated.- Returns:
- the metadata of this item stack.
-
isUnbreakable
public boolean isUnbreakable()Determines whether this item stack is unbreakable.- Returns:
trueif the item stack is unbreakable,falseotherwise.
-
isBroken
public boolean isBroken()Determines whether this item stack is broken.- Returns:
trueif the item stack is broken,falseotherwise.
-
getMaxDurability
public double getMaxDurability()- Returns:
- the maximum durability of this item stack.
-
getDurability
public double getDurability()- Returns:
- the durability of this item stack.
-
getQualityIndex
public int getQualityIndex()- Returns:
- the quality index of this item stack.
-
isEmpty
public boolean isEmpty()Determines whether this item stack is considered empty.- Returns:
trueif the item stack is empty,falseotherwise.
-
getOverrideDroppedItemAnimation
public boolean getOverrideDroppedItemAnimation()Determines whether to override the dropped item animation for this item stack.- Returns:
trueif it should override,falseotherwise.
-
setOverrideDroppedItemAnimation
public void setOverrideDroppedItemAnimation(boolean b) Called to set whether to override the dropped item animation for this item stack.- Parameters:
b- Whether to override it.
-
getBlockKey
Called to fetch the block key of the item associated with this item stack.- Returns:
- the block key, or
nullif the item does not have a block ID.
-
getItem
-
isValid
public boolean isValid()Determines whether this item stack is considered valid.- Returns:
trueif the item stack is valid,falseotherwise.
-
withDurability
Called to fetch a copy of this item stack, reconfigured with the provided durability.- Parameters:
durability- The durability to assign to the copy of the items stack.- Returns:
- the copy of the item stack with the configured durability.
-
withMaxDurability
Called to fetch a copy of this item stack, reconfigured with the provided max durability.- Parameters:
maxDurability- The max durability to assign to the copy of the items stack.- Returns:
- the copy of the item stack with the configured max durability.
-
withQuality
Called to fetch a copy of this item stack, reconfigured with the provided quality index.- Parameters:
quality- The quality index to assign to the copy of the item stack.- Returns:
- the copy of the item stack with the configured quality.
-
withIncreasedDurability
Called to fetch a copy of this item stack, increasing its durability with the provided amount.- Parameters:
inc- The provided amount to increase the durability by.- Returns:
- the copy of the item stack with the increased durability.
-
withRestoredDurability
Called to fetch a copy of this item stack, increasing its max durability with the provided amount.- Parameters:
maxDurability- The provided amount to increase the max durability by.- Returns:
- the copy of the item stack with the increased max durability.
-
withState
Called to fetch a copy of this item stack, reconfigured with the new item from the provided state.- Parameters:
state- The provided state to read the new item from.- Returns:
- the copy of the item stack with the reconfigured item from the state.
-
withQuantity
Called to fetch a copy of this item stack, reconfigured with the new quantity.- Parameters:
quantity- The provided quantity to set on the item stack copy.- Returns:
- the copy of the item stack with the reconfigured quantity.
-
cleanCopy
Called to fetch a copy of this item stack without transient runtime flags.- Returns:
- the clean copy of this item stack.
-
withMetadata
Called to fetch a copy of this item stack, reconfigured with the given metadata.- Parameters:
metadata- The given metadata to set on the new item stack copy.- Returns:
- the copy of the item stack with the reconfigured metadata.
-
withMetadata
-
withMetadata
-
withMetadata
-
toPacket
- Specified by:
toPacketin interfaceNetworkSerializable<ItemWithAllMetadata>
-
isStackableWith
Compares if the two ItemStack's are allowed to be stacked together. Note: Does not check if the item quantity can be combined.- Parameters:
itemStack- The item stack to compare to- Returns:
- If the two types are allowed to be stacked
-
isEquivalentType
Compares if the two ItemStack's are of the same 'type'- Parameters:
itemStack- The item stack to compare to- Returns:
- If the two types are of equivalent type
-
getFromMetadataOrNull
-
getFromMetadataOrNull
-
getFromMetadataOrDefault
-
getDisplayName
- Returns:
- the
ItemDisplayMetadataname override if set, otherwise the item asset's translation message.
-
getDisplayDescription
- Returns:
- the
ItemDisplayMetadatadescription override if set, otherwise the item asset's description translation message.
-
equals
-
hashCode
-
toString
-
isEmpty
-
isStackableWith
-
isEquivalentType
-
isSameItemType
-