Package com.viaversion.viaversion.util
Class EntityTypeUtil
java.lang.Object
com.viaversion.viaversion.util.EntityTypeUtil
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
EntityTypeUtil.EntityIdSetter<T extends EntityType>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic EntityType[]
createSizedArray
(EntityType[] values) static EntityType
getTypeFromId
(EntityType[] values, int typeId, EntityType fallback) Returns the entity type from id, or the given fallback if out of bounds.static <T extends EntityType>
voidinitialize
(T[] values, EntityType[] typesToFill, Protocol<?, ?, ?, ?> protocol, EntityTypeUtil.EntityIdSetter<T> idSetter) Sets entity type ids based on the protocol's mapping data and fills the given typesToFill array with the index corresponding to the id.static EntityType[]
toOrderedArray
(EntityType[] values) Returns an ordered array with each index representing the actual entity id.
-
Constructor Details
-
EntityTypeUtil
public EntityTypeUtil()
-
-
Method Details
-
toOrderedArray
Returns an ordered array with each index representing the actual entity id.- Parameters:
values
- entity types- Returns:
- ordered array with each index representing the actual entity id
-
initialize
public static <T extends EntityType> void initialize(T[] values, EntityType[] typesToFill, Protocol<?, ?, ?, ?> protocol, EntityTypeUtil.EntityIdSetter<T> idSetter) Sets entity type ids based on the protocol's mapping data and fills the given typesToFill array with the index corresponding to the id.- Type Parameters:
T
- entity type- Parameters:
values
- full enum valuestypesToFill
- yet unfilled array to be filled with types ordered by idprotocol
- protocol to get entity types fromidSetter
- function to set the internal entity id
-
createSizedArray
-
getTypeFromId
Returns the entity type from id, or the given fallback if out of bounds.- Parameters:
values
- sorted entity type arraytypeId
- entity type idfallback
- fallback/base entity type- Returns:
- entity type from id
-