java.lang.Object
de.placeblock.betterinventories.util.Util

public class Util extends Object
Utility Functions
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Vector2d
    Can be used to calculate the size of an Inventory based on the amount of Items this Inventory should contain.
    static Vector2d
    calculateGUISize(Collection<?> items, int width)
    Can be used to calculate the size of an Inventory based on the amount of Items this Inventory should contain.
    static <T> Vector2d
    calculateGUISize(T[] items)
    Can be used to calculate the size of an Inventory based on the amount of Items this Inventory should contain.
    static <T> Vector2d
    calculateGUISize(T[] items, int width)
    Can be used to calculate the size of an Inventory based on the amount of Items this Inventory should contain.
    static int
    modulo(int dividend, int divisor)
    Modulo that also works for negative numbers
    static Vector2d
    slotToVector(int slot, int width)
    Calculates the Vector given a slot and a width
    static int
    vectorToSlot(Vector2d vector, int width)
    Calculates the slot given a Vector and a width

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Util

      public Util()
  • Method Details

    • calculateGUISize

      public static <T> Vector2d calculateGUISize(T[] items)
      Can be used to calculate the size of an Inventory based on the amount of Items this Inventory should contain.
      Type Parameters:
      T - The type of the Items
      Parameters:
      items - The Items Array
      Returns:
      The Inventory size
    • calculateGUISize

      public static <T> Vector2d calculateGUISize(T[] items, int width)
      Can be used to calculate the size of an Inventory based on the amount of Items this Inventory should contain.
      Type Parameters:
      T - The type of the Items
      Parameters:
      items - The Items Array
      width - The width of the GUI
      Returns:
      The Inventory size
    • calculateGUISize

      public static Vector2d calculateGUISize(Collection<?> items)
      Can be used to calculate the size of an Inventory based on the amount of Items this Inventory should contain.
      Parameters:
      items - The Items Collection
      Returns:
      The Inventory size
    • calculateGUISize

      public static Vector2d calculateGUISize(Collection<?> items, int width)
      Can be used to calculate the size of an Inventory based on the amount of Items this Inventory should contain.
      Parameters:
      items - The Items Collection
      width - The width of the GUI
      Returns:
      The Inventory size
    • slotToVector

      public static Vector2d slotToVector(int slot, int width)
      Calculates the Vector given a slot and a width
      Parameters:
      slot - The slot
      width - The width
      Returns:
      The according Vector
    • vectorToSlot

      public static int vectorToSlot(Vector2d vector, int width)
      Calculates the slot given a Vector and a width
      Parameters:
      vector - The Vector
      width - The width
      Returns:
      The according slot
    • modulo

      public static int modulo(int dividend, int divisor)
      Modulo that also works for negative numbers
      Parameters:
      dividend - The dividend
      divisor - The divisor
      Returns:
      The modulo