namespace Minecraft.Server.FourKit.Entity; /// /// Represents a base entity in the world /// public abstract class Entity { private Location _location = new(); private Guid _uniqueId = Guid.NewGuid(); private float _fallDistance; private int _dimensionId; private int _entityId; private EntityType _entityType = EntityType.UNKNOWN; /// /// Gets the entity's current position. /// /// a new copy of containing the position of this entity public Location getLocation() => _location; /// /// Returns a unique id for this entity /// /// Entity id public virtual int getEntityId() => _entityId; /// /// Get the type of the entity. /// /// The of this entity. public new virtual EntityType getType() => _entityType; public new virtual EntityType GetType() => _entityType; /// /// Returns a unique and persistent id for this entity. Note that this is not the standard UUID for players. /// /// A unique to this entity. public Guid getUniqueId() => _uniqueId; /// /// Teleports this entity to the given location. /// This calls into the native server to perform the actual teleport. /// /// The destination location. /// true if the teleport was successful. public virtual bool teleport(Location location) { NativeBridge.TeleportEntity?.Invoke(getEntityId(), _dimensionId, location.getX(), location.getY(), location.getZ()); SetLocation(location); return true; } /// /// Sets the fall distance for this entity. /// /// The fall distance value. public void setFallDistance(float distance) { _fallDistance = distance; NativeBridge.SetFallDistance?.Invoke(getEntityId(), distance); } /// /// Returns the distance this entity has fallen. /// /// The current fall distance. public float getFallDistance() => _fallDistance; /// /// Gets the current world this entity resides in. /// /// World containing this entity. public World getWorld() => FourKit.getWorld(_dimensionId); // INTERNAL internal void SetLocation(Location location) { _location = location; } internal void SetFallDistanceInternal(float distance) => _fallDistance = distance; internal void SetUniqueId(Guid id) { _uniqueId = id; } internal void SetDimensionInternal(int dimensionId) => _dimensionId = dimensionId; internal void SetEntityIdInternal(int entityId) => _entityId = entityId; internal void SetEntityTypeInternal(EntityType entityType) => _entityType = entityType; }