Skip to content

WeakComponentReference

Package: com.hypixel.hytale.component

public class WeakComponentReference<ECS_TYPE, T extends Component<ECS_TYPE>>

A weak reference to a specific component on a specific entity. Caches the component instance via a WeakReference for fast access, falling back to a full store lookup if the cached reference has been garbage collected. Automatically invalidated when the owning entity is removed.

@Nullable
public T get()

Returns the component, or null if the entity has been removed.

@Nonnull
public Store<ECS_TYPE> getStore()
@Nonnull
public ComponentType<ECS_TYPE, T> getType()
@Nullable
public Ref<ECS_TYPE> getEntityReference()
  • Ref — the entity reference this wraps
  • ComponentType — the component type being referenced
Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.