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 ItemStackChanges the size of theItemStacktonewAmount.default @NotNull ItemStackapply(@NotNull ItemStack item, @NotNull IntUnaryOperator amountOperator) booleanUsed to know if anItemStackcan have the sizenewAmountapplied.booleancanBeStacked(@NotNull ItemStack item1, @NotNull ItemStack item2) Used to know if twoItemStackcan be stacked together.static @NotNull StackingRuleget()intUsed to determine the current stack size of anItemStack.intgetMaxSize(@NotNull ItemStack itemStack) Gets the max size of a stack.
-
Method Details
-
get
-
canBeStacked
Used to know if twoItemStackcan be stacked together. -
canApply
Used to know if anItemStackcan have the sizenewAmountapplied.- Parameters:
item- theItemStackto checkamount- the desired new amount- Returns:
- true if
itemcan have its stack size set to newAmount
-
apply
@Contract("_, _ -> new") @NotNull @NotNull ItemStack apply(@NotNull @NotNull ItemStack item, int newAmount) Changes the size of theItemStacktonewAmount. 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
-