Package dev.kosmx.playerAnim.api
Class PartKey
java.lang.Object
dev.kosmx.playerAnim.api.PartKey
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final @NotNull PartKeystatic final @NotNull PartKeystatic final @NotNull PartKeystatic final @NotNull PartKeystatic final @NotNull PartKeystatic final @NotNull PartKeystatic final @NotNull PartKeystatic final @NotNull PartKeystatic final @NotNull PartKeystatic final @NotNull PartKeystatic final @NotNull PartKey -
Method Summary
Modifier and TypeMethodDescriptionprotected Objectclone()Clone is not supported by PartKey.booleanThe current implementation states that two PartKeys are equal if the two identity objects are the same.inthashCode()static @NotNull PartKeyGet the appropriate partKey object, or creates a new identity if needed.
-
Field Details
-
HEAD
-
BODY
-
TORSO
-
RIGHT_ARM
-
LEFT_ARM
-
RIGHT_LEG
-
LEFT_LEG
-
RIGHT_ITEM
-
LEFT_ITEM
-
CAPE
-
ELYTRA
-
-
Method Details
-
equals
The current implementation states that two PartKeys are equal if the two identity objects are the same. This may change after the Valhalla update. -
hashCode
public int hashCode() -
clone
Clone is not supported by PartKey. copying a list of PartKeys should use the same PartKey objects.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException- always, as cloning would break instance equals and instance hashCode methods.
-
keyForId
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.
-