Package net.minestom.server.item
Interface ItemStack
- All Superinterfaces:
HoverEventSource<HoverEvent.ShowItem>,TagReadable
Represents an immutable item to be placed inside
PlayerInventory,
Inventory or even on the ground ItemEntity.
An item stack cannot be null, AIR should be used instead.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionintamount()default @NotNull HoverEvent<HoverEvent.ShowItem> asHoverEvent(@NotNull UnaryOperator<HoverEvent.ShowItem> op) static @NotNull ItemStack.Builder@NotNull ItemStackconsume(int amount) static @NotNull ItemStackfromItemNBT(@NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound nbtCompound) Converts this item to an NBT tag containing the id (material), count (amount), and tag (meta).static @NotNull ItemStackfromNBT(@NotNull Material material, @Nullable org.jglrxavpok.hephaistos.nbt.NBTCompound nbtCompound) static @NotNull ItemStackfromNBT(@NotNull Material material, @Nullable org.jglrxavpok.hephaistos.nbt.NBTCompound nbtCompound, int amount) default @Nullable ComponentgetLore()default <T> @UnknownNullability TReads the specified tag.default booleanisAir()boolean@NotNull Materialmaterial()@NotNull ItemMetameta()<T extends ItemMetaView<?>>
Tstatic @NotNull ItemStackstatic @NotNull ItemStack@NotNull org.jglrxavpok.hephaistos.nbt.NBTCompoundConverts this item to an NBT tag containing the id (material), count (amount), and tag (meta)@NotNull ItemStackwith(@NotNull Consumer<@NotNull ItemStack.Builder> consumer) @NotNull ItemStackwithAmount(int amount) default @NotNull ItemStackwithAmount(@NotNull IntUnaryOperator intUnaryOperator) default @NotNull ItemStackwithDisplayName(@NotNull UnaryOperator<@Nullable Component> componentUnaryOperator) default @NotNull ItemStackwithDisplayName(@Nullable Component displayName) default @NotNull ItemStackdefault @NotNull ItemStackwithLore(@NotNull UnaryOperator<@NotNull List<@NotNull Component>> loreUnaryOperator) @NotNull ItemStackwithMaterial(@NotNull Material material) <V extends ItemMetaView.Builder,T extends ItemMetaView<V>>
@NotNull ItemStack@NotNull ItemStackwithMeta(@NotNull Consumer<@NotNull ItemMeta.Builder> consumer) @NotNull ItemStackdefault <T> @NotNull ItemStackMethods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEventMethods inherited from interface net.minestom.server.tag.TagReadable
hasTag
-
Field Details
-
AIR
Constant AIR item. Should be used instead of 'null'.
-
-
Method Details
-
builder
@Contract(value="_ -> new", pure=true) @NotNull static @NotNull ItemStack.Builder builder(@NotNull @NotNull Material material) -
of
-
of
-
fromNBT
-
fromNBT
-
fromItemNBT
@Experimental @NotNull static @NotNull ItemStack fromItemNBT(@NotNull @NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound nbtCompound) Converts this item to an NBT tag containing the id (material), count (amount), and tag (meta).- Parameters:
nbtCompound- The nbt representation of the item
-
material
-
amount
@Contract(pure=true) int amount() -
meta
-
meta
@Contract(pure=true) @Experimental @NotNull <T extends ItemMetaView<?>> T meta(@NotNull @NotNull Class<T> metaClass) -
with
@Contract(value="_, -> new", pure=true) @NotNull @NotNull ItemStack with(@NotNull @NotNull Consumer<@NotNull ItemStack.Builder> consumer) -
withMeta
@Contract(value="_, _ -> new", pure=true) @Experimental @NotNull <V extends ItemMetaView.Builder,T extends ItemMetaView<V>> @NotNull ItemStack withMeta(@NotNull @NotNull Class<T> metaType, @NotNull @NotNull Consumer<V> consumer) -
withMeta
@Contract(value="_ -> new", pure=true) @NotNull @NotNull ItemStack withMeta(@NotNull @NotNull Consumer<@NotNull ItemMeta.Builder> consumer) -
withMaterial
-
withAmount
-
withAmount
@Contract(value="_, -> new", pure=true) @NotNull default @NotNull ItemStack withAmount(@NotNull @NotNull IntUnaryOperator intUnaryOperator) -
consume
@Experimental @Contract(value="_, -> new", pure=true) @NotNull @NotNull ItemStack consume(int amount) -
getDisplayName
-
getLore
-
withMeta
-
withDisplayName
-
withDisplayName
@Contract(value="_, -> new", pure=true) @NotNull default @NotNull ItemStack withDisplayName(@NotNull @NotNull UnaryOperator<@Nullable Component> componentUnaryOperator) -
withLore
-
withLore
@Contract(value="_, -> new", pure=true) @NotNull default @NotNull ItemStack withLore(@NotNull @NotNull UnaryOperator<@NotNull List<@NotNull Component>> loreUnaryOperator) -
isAir
@Contract(pure=true) default boolean isAir() -
isSimilar
-
withTag
-
getTag
Description copied from interface:TagReadableReads the specified tag.- Specified by:
getTagin interfaceTagReadable- Type Parameters:
T- the tag type- Parameters:
tag- the tag to read- Returns:
- the read tag, null if not present
-
asHoverEvent
@NotNull default @NotNull HoverEvent<HoverEvent.ShowItem> asHoverEvent(@NotNull @NotNull UnaryOperator<HoverEvent.ShowItem> op) - Specified by:
asHoverEventin interfaceHoverEventSource<HoverEvent.ShowItem>
-
toItemNBT
@Experimental @NotNull @NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound toItemNBT()Converts this item to an NBT tag containing the id (material), count (amount), and tag (meta)- Returns:
- The nbt representation of the item
-