Class UnknownComponents<ECS_TYPE>

java.lang.Object
com.hypixel.hytale.component.data.unknown.UnknownComponents<ECS_TYPE>
Type Parameters:
ECS_TYPE - The type of ECS the component is for.
All Implemented Interfaces:
Component<ECS_TYPE>, Cloneable

public class UnknownComponents<ECS_TYPE> extends Object implements Component<ECS_TYPE>
A component that holds unknown components for an entity.

If an entity is loaded that has components that are not recognized by the current ECS, those components are stored in an instance of this class. This allows for the data of those components to be preserved, even if they cannot be processed.

  • Field Details

  • Constructor Details

    • UnknownComponents

      public UnknownComponents()
      Empty Constructor for a UnknownComponents instance.
    • UnknownComponents

      public UnknownComponents(@Nonnull Map<String, org.bson.BsonDocument> unknownComponents)
      Default Constructor for a UnknownComponents instance.
      Parameters:
      unknownComponents - The map of unknown components.
  • Method Details

    • addComponent

      public void addComponent(@Nonnull String componentId, @Nonnull Component<ECS_TYPE> component, @Nonnull Codec<Component<ECS_TYPE>> codec)
      Called to add an unknown component to this instance.
      Parameters:
      componentId - The ID of the component.
      component - The component to add.
      codec - The codec to use to encode the component.
    • addComponent

      public void addComponent(@Nonnull String componentId, @Nonnull TempUnknownComponent<ECS_TYPE> component)
      Called to add an unknown component to this instance.
      Parameters:
      componentId - The ID of the component.
      component - The temporary unknown component to add.
    • contains

      public boolean contains(@Nonnull String componentId)
      Determines whether this instance contains a component with the given ID.
      Parameters:
      componentId - The ID of the component.
      Returns:
      true if this instance contains a component with the given ID, false otherwise.
    • removeComponent

      @Nullable public <T extends Component<ECS_TYPE>> T removeComponent(@Nonnull String componentId, @Nonnull Codec<T> codec)
      Called to remove an unknown component from this instance.
      Type Parameters:
      T - The type of the component.
      Parameters:
      componentId - The ID of the component.
      codec - The codec to use to decode the component.
      Returns:
      the removed component, or null if no component with the given ID was found.
    • getUnknownComponents

      @Nonnull public Map<String, org.bson.BsonDocument> getUnknownComponents()
      Returns:
      the map of unknown components.
    • clone

      @Nonnull public Component<ECS_TYPE> clone()
      Specified by:
      clone in interface Component<ECS_TYPE>
      Returns:
      a clone instance of the original component instance.