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
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
amount()
default @NotNull HoverEvent<HoverEvent.ShowItem>
asHoverEvent
(@NotNull UnaryOperator<HoverEvent.ShowItem> op) static @NotNull ItemStack.Builder
@NotNull ItemStack
consume
(int amount) static @NotNull ItemStack
fromItemNBT
(@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 ItemStack
fromNBT
(@NotNull Material material, @Nullable org.jglrxavpok.hephaistos.nbt.NBTCompound nbtCompound) static @NotNull ItemStack
fromNBT
(@NotNull Material material, @Nullable org.jglrxavpok.hephaistos.nbt.NBTCompound nbtCompound, int amount) default int
Deprecated.default @Nullable Component
getLore()
default @NotNull Material
Deprecated.default @NotNull ItemMeta
getMeta()
Deprecated.default <T> @UnknownNullability T
Reads the specified tag.default boolean
isAir()
boolean
@NotNull Material
material()
@NotNull ItemMeta
meta()
<T extends ItemMetaView<?>>
Tstatic @NotNull ItemStack
static @NotNull ItemStack
@NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound
Converts this item to an NBT tag containing the id (material), count (amount), and tag (meta)@NotNull ItemStack
with
(@NotNull Consumer<@NotNull ItemStack.Builder> consumer) @NotNull ItemStack
withAmount
(int amount) default @NotNull ItemStack
withAmount
(@NotNull IntUnaryOperator intUnaryOperator) default @NotNull ItemStack
withDisplayName
(@NotNull UnaryOperator<@Nullable Component> componentUnaryOperator) default @NotNull ItemStack
withDisplayName
(@Nullable Component displayName) default @NotNull ItemStack
withLore
(@NotNull UnaryOperator<@NotNull List<@NotNull Component>> loreUnaryOperator) default @NotNull ItemStack
@NotNull ItemStack
withMaterial
(@NotNull Material material) <V extends ItemMetaView.Builder,
T extends ItemMetaView<V>>
@NotNull ItemStack@NotNull ItemStack
withMeta
(@NotNull Consumer<@NotNull ItemMeta.Builder> consumer) @NotNull ItemStack
default <T> @NotNull ItemStack
Methods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEvent
Methods 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:TagReadable
Reads the specified tag.- Specified by:
getTag
in 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:
asHoverEvent
in 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
-
getMaterial
Deprecated. -
getAmount
Deprecated. -
getMeta
Deprecated.
-