Class Holder<ECS_TYPE>

java.lang.Object
com.hypixel.hytale.component.Holder<ECS_TYPE>

public class Holder<ECS_TYPE> extends Object
Used to hold AoS style data for when moving an entity around or serializing it. Components are packed into SoA style in data chunks.
  • Method Details

    • emptyArray

      public static <T> Holder<T>[] emptyArray()
    • ensureComponentsSize

      @Nonnull public Component<ECS_TYPE>[] ensureComponentsSize(int size)
      Called to ensure that the array of components within this holder abides to the given size.
      Parameters:
      size - The given size that the components array should abide to.
      Returns:
      the array of component instances associated with this holder.
    • init

      public void init(@Nonnull Archetype<ECS_TYPE> archetype, @Nonnull Component<ECS_TYPE>[] components)
      Called to initialize this holder.
      Parameters:
      archetype - The archetype associated with this holder.
      components - The array of components to associated with this holder.
    • _internal_init

      public void _internal_init(@Nonnull Archetype<ECS_TYPE> archetype, @Nonnull Component<ECS_TYPE>[] components, @Nonnull ComponentType<ECS_TYPE, UnknownComponents<ECS_TYPE>> unknownComponentType)
    • getArchetype

      public Archetype<ECS_TYPE> getArchetype()
      Returns:
      the archetype associated with this holder, if any.
    • ensureComponent

      public <T extends Component<ECS_TYPE>> void ensureComponent(@Nonnull ComponentType<ECS_TYPE,T> componentType)
      Called to ensure that this holder has the given component type, adding the component instance if it doesn't.
      Type Parameters:
      T - The component type class of the component.
      Parameters:
      componentType - The component type that we are ensuring this holder has.
    • ensureAndGetComponent

      @Nonnull public <T extends Component<ECS_TYPE>> T ensureAndGetComponent(@Nonnull ComponentType<ECS_TYPE,T> componentType)
      Called to ensure and get the component instance of a specific type from this holder.
      Type Parameters:
      T - The component type class of the component.
      Parameters:
      componentType - The component type that we are ensuring and getting from this holder.
      Returns:
      the component instance that we are ensuring and getting.
    • addComponent

      public <T extends Component<ECS_TYPE>> void addComponent(@Nonnull ComponentType<ECS_TYPE,T> componentType, @Nonnull T component)
      Called to add the given component of the given component type to this holder.
      Type Parameters:
      T - The component type class of the component.
      Parameters:
      componentType - The component type of the component that we are adding.
      component - The instance of the component that we are adding.
    • replaceComponent

      public <T extends Component<ECS_TYPE>> void replaceComponent(@Nonnull ComponentType<ECS_TYPE,T> componentType, @Nonnull T component)
      Called to replace a component instance with the given instance of the given component type for this holder.
      Type Parameters:
      T - The component type class of the component.
      Parameters:
      componentType - The component type of the component that we are replacing.
      component - The instance of the component that we are replacing the existing instance with.
    • putComponent

      public <T extends Component<ECS_TYPE>> void putComponent(@Nonnull ComponentType<ECS_TYPE,T> componentType, @Nonnull T component)
      Called to put the given component instance of the given component type into this holder.
      Type Parameters:
      T - The component type class of the component.
      Parameters:
      componentType - The component type of the component that we are putting.
      component - The instance of the component that we are putting
    • getComponent

      @Nullable public <T extends Component<ECS_TYPE>> T getComponent(@Nonnull ComponentType<ECS_TYPE,T> componentType)
      Called to get the component instance of the given component type from this holder.
      Type Parameters:
      T - The component type class of the component.
      Parameters:
      componentType - The component type of the component that we are getting.
      Returns:
      the component instance of the given component type, or null if the component doesn't exist.
    • removeComponent

      public <T extends Component<ECS_TYPE>> void removeComponent(@Nonnull ComponentType<ECS_TYPE,T> componentType)
      Called to remove the component instance of the given component type from this holder.
      Type Parameters:
      T - The component type class of the component.
      Parameters:
      componentType - The component type of the component that we are removing.
    • tryRemoveComponent

      public <T extends Component<ECS_TYPE>> boolean tryRemoveComponent(@Nonnull ComponentType<ECS_TYPE,T> componentType)
      Called to try and remove the component instance of the given component type from this holder.
      Type Parameters:
      T - The component type class of the component.
      Parameters:
      componentType - The component type of the component to remove.
      Returns:
      true if the component exists, false otherwise.
    • hasSerializableComponents

      public boolean hasSerializableComponents(@Nonnull ComponentRegistry.Data<ECS_TYPE> data)
      Determines whether this holder contains serializable components.
      Parameters:
      data - The registry data of the component registry.
      Returns:
      true if serializable components exist, false otherwise.
    • updateData

      public void updateData(@Nonnull ComponentRegistry.Data<ECS_TYPE> oldData, @Nonnull ComponentRegistry.Data<ECS_TYPE> newData)
    • clone

      @Nonnull public Holder<ECS_TYPE> clone()
    • cloneSerializable

      public Holder<ECS_TYPE> cloneSerializable(@Nonnull ComponentRegistry.Data<ECS_TYPE> data)
    • cloneSerializable

      public Holder<ECS_TYPE> cloneSerializable(@Nonnull ComponentRegistry.Data<ECS_TYPE> data, @Nullable Predicate<ComponentType<ECS_TYPE,?>> filter)
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      @Nonnull public String toString()
      Overrides:
      toString in class Object