Package net.minestom.server.item
Class StackingRule
java.lang.Object
net.minestom.server.item.StackingRule
- Direct Known Subclasses:
VanillaStackingRule
public abstract class StackingRule
extends java.lang.Object
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...-
Constructor Summary
Constructors Constructor Description StackingRule(int maxSize)
-
Method Summary
Modifier and Type Method Description abstract ItemStack
apply(ItemStack item, int newAmount)
Changes the size of theItemStack
tonewAmount
.abstract boolean
canApply(ItemStack item, int newAmount)
Used to know if anItemStack
can have the sizenewAmount
applied.abstract boolean
canBeStacked(ItemStack item1, ItemStack item2)
Used to know if twoItemStack
can be stacked together.abstract int
getAmount(ItemStack itemStack)
Used to determine the current stack size of anItemStack
.int
getMaxSize()
Gets the max size of a stack.
-
Constructor Details
-
StackingRule
public StackingRule(int maxSize)
-
-
Method Details
-
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 checknewAmount
- the desired new amount- Returns:
- true if
item
can have its stack size set to newAmount
-
apply
Changes the size of theItemStack
tonewAmount
. At this point we know that the item can have this stack size applied. -
getAmount
-
getMaxSize
public int getMaxSize()Gets the max size of a stack.- Returns:
- the max size of a stack
-