Class EntityTypeUtil

java.lang.Object
com.viaversion.viaversion.util.EntityTypeUtil

public final class EntityTypeUtil extends Object
  • Constructor Details

    • EntityTypeUtil

      public EntityTypeUtil()
  • Method Details

    • toOrderedArray

      public static EntityType[] toOrderedArray(EntityType[] values)
      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 values
      typesToFill - yet unfilled array to be filled with types ordered by id
      protocol - protocol to get entity types from
      idSetter - function to set the internal entity id
    • createSizedArray

      public static EntityType[] createSizedArray(EntityType[] values)
    • getTypeFromId

      public static EntityType getTypeFromId(EntityType[] values, int typeId, EntityType fallback)
      Returns the entity type from id, or the given fallback if out of bounds.
      Parameters:
      values - sorted entity type array
      typeId - entity type id
      fallback - fallback/base entity type
      Returns:
      entity type from id