Class PartKey

java.lang.Object
dev.kosmx.playerAnim.api.PartKey

@Immutable public class PartKey extends Object
PartKey object for faster model part ID comparison. A part will be represented by partKeys, including in formats and render. Finding the correct value for a key, if the key is a unique integer, is faster than doing the same with string hashing compare.

Usage: Instead of comparing for a string key, store a static final PartKey for the given part in your class, and compare (key) for that.
Common part static keys are also available in this class, but you can request your own.

API note
If two PartKey objects are different, their key must be different: instance comparison is safe for part key equality check. partKeyA == partKeyB is completely safe and okay to do.

Implementation note
Please be aware that with Project Valhalla, the implementation of this class may change, but the behaviour and public functions must not.

  • Field Details

    • BODY

      @NotNull public static final @NotNull PartKey BODY
    • TORSO

      @NotNull public static final @NotNull PartKey TORSO
    • RIGHT_ARM

      @NotNull public static final @NotNull PartKey RIGHT_ARM
    • LEFT_ARM

      @NotNull public static final @NotNull PartKey LEFT_ARM
    • RIGHT_LEG

      @NotNull public static final @NotNull PartKey RIGHT_LEG
    • LEFT_LEG

      @NotNull public static final @NotNull PartKey LEFT_LEG
    • RIGHT_ITEM

      @NotNull public static final @NotNull PartKey RIGHT_ITEM
    • LEFT_ITEM

      @NotNull public static final @NotNull PartKey LEFT_ITEM
    • CAPE

      @NotNull public static final @NotNull PartKey CAPE
    • ELYTRA

      @NotNull public static final @NotNull PartKey ELYTRA
  • Method Details

    • equals

      public boolean equals(Object o)
      The current implementation states that two PartKeys are equal if the two identity objects are the same. This may change after the Valhalla update.
      Overrides:
      equals in class Object
      Parameters:
      o - other object
      Returns:
      true if and only if the two keys are equal.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      protected Object clone() throws CloneNotSupportedException
      Clone is not supported by PartKey. copying a list of PartKeys should use the same PartKey objects.
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException - always, as cloning would break instance equals and instance hashCode methods.
    • keyForId

      @NotNull public static @NotNull PartKey keyForId(@NotNull @NotNull String id)
      Get the appropriate partKey object, or creates a new identity if needed. It is safe to invoke this concurrently, or with the same id multiple times. However, doing so defeats the purpose of fast mapping.
      Parameters:
      id - the model part string ID. (should be normalized to camelCase)
      Returns:
      PartKey for the given ID. For the same ID the same object must be returned.