Skip to content

Entity API ​

js
import { Entity, LivingEntity } from 'yeow-api';

Static Methods ​

js
Entity.get(uuid)                // Promise<Entity | null>

Constructor ​

js
new Entity(uuid)                // Reference entity by UUID

Properties ​

PropertyTypeRead/WriteDescription
uuidstringRead-onlyEntity UUID
typestringRead-onlyType (minecraft registration key, e.g., minecraft:zombie)
namestringRead-onlyDisplay name
customNamestring | nullRead/WriteCustom name
worldstring | nullRead-onlyCurrent world
locationLocation | nullRead-onlyCurrent location
isGlowingbooleanRead/WriteGlowing
isInvulnerablebooleanRead/WriteInvulnerable
isSilentbooleanRead/WriteSilent
hasGravitybooleanRead/WriteHas gravity
passengersstring[]Read-onlyPassenger UUIDs
vehiclestring | nullRead-onlyVehicle UUID

Entity type keys (minecraft:zombie etc.) value domain see Value Domain Appendix · Version Change Domain.

Methods ​

All async (Promise).

Field Access ​

MethodReturnDescription
getType()Promise<string>Type (Minecraft registry key, e.g. minecraft:zombie)
getName()Promise<string>Display name
getCustomName() / setCustomName(v)Promise<string | null> / Promise<void>Custom name
getWorld()Promise<string | null>Current world
getLocation()Promise<Location | null>Current location
isGlowing() / setGlowing(v)Promise<boolean> / Promise<void>Glowing
isInvulnerable() / setInvulnerable(v)Promise<boolean> / Promise<void>Invulnerable
isSilent() / setSilent(v)Promise<boolean> / Promise<void>Silent
hasGravity() / setGravity(v)Promise<boolean> / Promise<void>Gravity
getPassengers()Promise<string[]>Passenger UUIDs
getVehicle()Promise<string | null>Vehicle UUID
getBoundingBox()Promise<BoundingBox>{ minX, minY, minZ, maxX, maxY, maxZ }
setCustomNameVisible(v)Promise<void>Whether the custom name is visible

Prefer await entity.snap() when reading several fields — see Read-only snapshot.

Other ​

js
await entity.remove()
await entity.teleport(loc)

Read-only snapshot (snap()) ​

Fetches the entity's common state in a single round trip and returns a frozen EntitySnapshot. Use it instead of N × await getXxx() when reading several fields.

ts
const s = await zombie.snap();
log.info(`${s.type} hp=${s.health}/${s.maxHealth} @${s.location.x},${s.location.y},${s.location.z}`);
FieldTypeDescription
uuid / type / namestringUUID / type (minecraft:zombie) / name
customNamestringCustom name ("" when unset)
world / locationstring / LocationWorld / position (locally built, frozen)
isGlowing / isInvulnerable / isSilentbooleanState flags
hasGravity / isOnGroundbooleanGravity / on ground
passengers / vehiclestring[] / string | nullPassenger UUIDs / vehicle UUID
boundingBox{minX,minY,minZ,maxX,maxY,maxZ}Bounding box
velocity{x,y,z}Velocity
fireTicks / ticksLivednumberFire ticks / ticks lived
health / maxHealth / isDeadnumber / number / booleanLiving entities only

Helpers (local, zero round trips): isLiving(), distanceTo({x,y,z}), isWithin({x,y,z}, radius), toObject() / toJSON().

A snapshot is a copy at one point in time; writes still go through setters.

Potion Effects ​

Potion effects API acting on LivingEntity see Potion documentation.

LivingEntity ​

Player inherits from LivingEntity, additional properties:

js
entity.health                // Read/Write
entity.maxHealth             // Read-only
entity.isDead                // Read-only

Async versions:

js
entity.getHealth()           // Promise<number>
entity.setHealth(value)      // Promise
entity.getMaxHealth()        // Promise<number>
entity.isDeadAsync()         // Promise<boolean>

Basic Operations ​

All Entity (velocity/fireTicks/ticksLived/isOnGround) and LivingEntity (damage/setTarget):

js
// Velocity vector (blocks/second)
entity.velocity = { x: 0, y: 1, z: 0 };      // Read/Write
await entity.setVelocity({ x: 0, y: 1, z: 0 });

// On fire / ticks lived / on ground
entity.fireTicks = 20;                        // Read/Write (0 = not on fire)
entity.ticksLived;                            // Read-only
entity.isOnGround;                            // Read-only

// Damage
await entity.damage(5);                       // Apply 5 damage
await entity.damage(5, 'damager-uuid');       // With damage source

// AI target (no guarantee of effectiveness — depends on entity type/pathfinding ability)
await entity.setTarget({ targetUuid: 'target-entity-uuid' });                    // Entity target
await entity.setTarget({ world: 'world', x: 100, y: 64, z: 100, speed: 1.0 });   // Position target (Pathfinder)

setTarget semantics: Requires mob entity (Mob) to take effect; non-mob/entities without pathfinding silently ignore. Position targets use Pathfinder pathfinding, with speed (default 1.0) controlling movement speed.

Example ​

js
const e = await Entity.get(uuid);
if (e) {
    console.log(e.type, e.location?.world);
    e.isGlowing = true;
    await e.teleport(new Location(0, 80, 0, 0, 0, 'world'));

    // Potion effects (LivingEntity instance method; type is minecraft registration key)
    await e.addPotionEffect({
        type: 'minecraft:speed', duration: 200, amplifier: 0
    });
}