Package net.minestom.server.item
Interface StackingRule
- All Known Implementing Classes:
VanillaStackingRule
public interface StackingRule
Represents the stacking rule of an
ItemStack
.
This can be used to mimic the vanilla one (using the displayed item quantity)
or a complete new one which can be stored in lore, name, etc...-
Method Summary
Modifier and TypeMethodDescription@NotNull ItemStack
Changes the size of theItemStack
tonewAmount
.default @NotNull ItemStack
apply
(@NotNull ItemStack item, @NotNull IntUnaryOperator amountOperator) boolean
Used to know if anItemStack
can have the sizenewAmount
applied.boolean
canBeStacked
(@NotNull ItemStack item1, @NotNull ItemStack item2) Used to know if twoItemStack
can be stacked together.static @NotNull StackingRule
get()
int
Used to determine the current stack size of anItemStack
.int
getMaxSize
(@NotNull ItemStack itemStack) Gets the max size of a stack.
-
Method Details
-
get
-
canBeStacked
Used to know if twoItemStack
can be stacked together. -
canApply
Used to know if anItemStack
can have the sizenewAmount
applied.- Parameters:
item
- theItemStack
to checkamount
- the desired new amount- Returns:
- true if
item
can have its stack size set to newAmount
-
apply
@Contract("_, _ -> new") @NotNull @NotNull ItemStack apply(@NotNull @NotNull ItemStack item, int newAmount) Changes the size of theItemStack
tonewAmount
. At this point we know that the item can have this stack size applied. -
apply
@Contract("_, _ -> new") @NotNull default @NotNull ItemStack apply(@NotNull @NotNull ItemStack item, @NotNull @NotNull IntUnaryOperator amountOperator) -
getAmount
Used to determine the current stack size of anItemStack
. It is possible to have it stored in its nbt. -
getMaxSize
Gets the max size of a stack.- Parameters:
itemStack
- the item to get the max size from- Returns:
- the max size of a stack
-