Class VanillaStackingRule

java.lang.Object
net.minestom.server.item.rule.VanillaStackingRule
All Implemented Interfaces:
StackingRule

public final class VanillaStackingRule extends Object implements StackingRule
  • Constructor Details

    • VanillaStackingRule

      public VanillaStackingRule()
  • Method Details

    • canBeStacked

      public boolean canBeStacked(@NotNull @NotNull ItemStack item1, @NotNull @NotNull ItemStack item2)
      Description copied from interface: StackingRule
      Used to know if two ItemStack can be stacked together.
      Specified by:
      canBeStacked in interface StackingRule
      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

      public boolean canApply(@NotNull @NotNull ItemStack item, int newAmount)
      Description copied from interface: StackingRule
      Used to know if an ItemStack can have the size newAmount applied.
      Specified by:
      canApply in interface StackingRule
      Parameters:
      item - the ItemStack to check
      newAmount - the desired new amount
      Returns:
      true if item can have its stack size set to newAmount
    • apply

      @NotNull public @NotNull ItemStack apply(@NotNull @NotNull ItemStack item, int amount)
      Description copied from interface: StackingRule
      Changes the size of the ItemStack to newAmount. At this point we know that the item can have this stack size applied.
      Specified by:
      apply in interface StackingRule
      Parameters:
      item - the ItemStack to applies the size to
      amount - the new item size
      Returns:
      a new item with the specified amount
    • getAmount

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

      public int getMaxSize(@NotNull @NotNull ItemStack itemStack)
      Description copied from interface: StackingRule
      Gets the max size of a stack.
      Specified by:
      getMaxSize in interface StackingRule
      Parameters:
      itemStack - the item to get the max size from
      Returns:
      the max size of a stack
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object