public final class EntityTypeUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
EntityTypeUtil.EntityIdSetter<T extends EntityType> |
Constructor and Description |
---|
EntityTypeUtil() |
Modifier and Type | Method and Description |
---|---|
static 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> |
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.
|
static EntityType[] |
toOrderedArray(EntityType[] values)
Returns an ordered array with each index representing the actual entity id.
|
public static EntityType[] toOrderedArray(EntityType[] values)
values
- entity typespublic static <T extends EntityType> void initialize(T[] values, EntityType[] typesToFill, Protocol<?,?,?,?> protocol, EntityTypeUtil.EntityIdSetter<T> idSetter)
T
- entity typevalues
- 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 idpublic static EntityType[] createSizedArray(EntityType[] values)
public static EntityType getTypeFromId(EntityType[] values, int typeId, EntityType fallback)
values
- sorted entity type arraytypeId
- entity type idfallback
- fallback/base entity type