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 Details

    • get

      @NotNull static @NotNull StackingRule get()
    • canBeStacked

      boolean canBeStacked(@NotNull @NotNull ItemStack item1, @NotNull @NotNull ItemStack item2)
      Used to know if two ItemStack can be stacked together.
      Parameters:
      item1 - the first ItemStack
      item2 - the second ItemStack
      Returns:
      true if both ItemStack can be stacked together (without taking their amount in consideration)
    • canApply

      boolean canApply(@NotNull @NotNull ItemStack item, int amount)
      Used to know if an ItemStack can have the size newAmount applied.
      Parameters:
      item - the ItemStack to check
      amount - 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 the ItemStack to newAmount. At this point we know that the item can have this stack size applied.
      Parameters:
      item - the ItemStack to applies the size to
      newAmount - the new item size
      Returns:
      a new item with the specified amount
    • apply

      @Contract("_, _ -> new") @NotNull default @NotNull ItemStack apply(@NotNull @NotNull ItemStack item, @NotNull @NotNull IntUnaryOperator amountOperator)
    • getAmount

      int getAmount(@NotNull @NotNull ItemStack itemStack)
      Used to determine the current stack size of an ItemStack. It is possible to have it stored in its nbt.
      Parameters:
      itemStack - the ItemStack to check the size
      Returns:
      the correct size of ItemStack
    • getMaxSize

      int getMaxSize(@NotNull @NotNull ItemStack itemStack)
      Gets the max size of a stack.
      Parameters:
      itemStack - the item to get the max size from
      Returns:
      the max size of a stack