Skip to content

Entity

Package: com.hypixel.hytale.server.core.entity

public abstract class Entity implements Component<EntityStore>

The abstract base class for all entities in the Hytale server. Entity is itself an ECS component — it implements Component<EntityStore>, which means every entity instance is stored as a component on an EntityStore ref. This design allows entity identity, world membership, and lifecycle to be managed uniformly through the ECS.

Subclasses include LivingEntity (entities with health, inventory, and movement) and ultimately Player.

public static final int UNASSIGNED_ID = -1

Sentinel value indicating an entity that has not been assigned a network ID. Entities receive a network ID when loaded into a world and revert to UNASSIGNED_ID when removed.

FieldTypeDescription
networkIdintNetwork-visible identifier assigned when loaded into a world
legacyUuidUUIDLegacy UUID retained for backwards compatibility. Deprecated.
worldWorldThe world this entity currently belongs to, or null if unloaded
referenceRef<EntityStore>The ECS ref handle for this entity within its store
wasRemovedbooleanWhether this entity has been removed from its world
public static final BuilderCodec<Entity> CODEC

A BuilderCodec for serializing and deserializing entity data. Subclasses (e.g., LivingEntity.CODEC, Player.CODEC) extend this codec with their additional fields.

public boolean remove()

Removes this entity from its world. Returns true if the entity was successfully removed, false if it was already removed or not loaded into a world. After removal, wasRemoved() returns true and the entity’s Ref is invalidated.

public void loadIntoWorld(@Nonnull World world)

Loads this entity into the given world. Assigns the entity a network ID and establishes its world reference. Called by the world loading system — plugin code should not call this directly.

public void unloadFromWorld()

Unloads this entity from its current world. Clears the world reference and resets the network ID to UNASSIGNED_ID. Called during world unloading or entity transfer.

public boolean wasRemoved()

Returns true if this entity has been removed from its world via remove().

@Deprecated(forRemoval = true)
public int getNetworkId()

Returns the entity’s network ID. Deprecated — network identity is being replaced by ref-based addressing.

@Nullable
@Deprecated(forRemoval = true)
public UUID getUuid()

Returns the entity’s legacy UUID. Deprecated — use ref-based identity instead.

@Nullable
public World getWorld()

Returns the world this entity is loaded into, or null if the entity is not currently in a world.

public void setReference(@Nonnull Ref<EntityStore> reference)

Sets the ECS ref handle for this entity. Called by the store when the entity is added. Plugin code should not call this directly.

@Nullable
public Ref<EntityStore> getReference()

Returns the ECS ref handle for this entity, or null if the entity has not been added to a store.

public Holder<EntityStore> toHolder()

Creates a Holder snapshot of this entity’s component data. Used for entity transfer between stores or for serialization.

@Deprecated
public void moveTo(@Nonnull Ref<EntityStore> ref, double locX, double locY, double locZ, @Nonnull ComponentAccessor<EntityStore> componentAccessor)

Moves this entity to the specified coordinates. Deprecated — movement is now handled through dedicated movement components and systems.

public boolean isCollidable()

Returns whether this entity participates in collision detection. Subclasses override this to control collision behavior.

public boolean isHiddenFromLivingEntity(@Nonnull Ref<EntityStore> ref, @Nonnull Ref<EntityStore> targetRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor)

Returns whether this entity is hidden from the given living entity. Used by visibility systems to filter entities from a target’s perception (e.g., spectator mode, invisibility effects).

Static inner class containing animation ID helper constants for default entity animations. Provides standardized animation identifiers used across the animation system.

  • LivingEntity — extends Entity with health, inventory, and stat modifiers
  • Player — concrete player entity extending LivingEntity
  • Store — the EntityStore that holds entity components
  • Ref — entity reference handle used with getReference() / setReference()
  • ComponentType — type key for accessing Entity as a component
  • Component — the ECS component interface that Entity implements
  • World — the world container that entities are loaded into
  • BuilderCodec — serialization codec for entity data
  • Holder — snapshot container created by toHolder()