Class WeakComponentReference<ECS_TYPE, T extends Component<ECS_TYPE>>

java.lang.Object
com.hypixel.hytale.component.WeakComponentReference<ECS_TYPE,T>
Type Parameters:
ECS_TYPE - The type of ECS this component is part of.
T - The type of the component

public class WeakComponentReference<ECS_TYPE, T extends Component<ECS_TYPE>> extends Object
A weak reference to a component. Similar to WeakReference however it understands how to get the component from the store.

The WeakComponentReference will be invalidated when the component is removed.

  • Method Details

    • get

      @Nullable public T get()
      Returns the components data either from the weak reference or fetches the data from the component store.
      Returns:
      the components data
    • getStore

      @Nonnull public Store<ECS_TYPE> getStore()
      Returns:
      the associated component store.
    • getType

      @Nonnull public ComponentType<ECS_TYPE,T> getType()
      Returns:
      the component type of the referenced component.
    • getEntityReference

      @Nullable public Ref<ECS_TYPE> getEntityReference()
      Returns:
      the entity reference of the entity that holds the component.
    • 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