Skip to content

Entity API

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

Static Methods

js
Entity.get(uuid)                // Promise<Entity | null>
Entity.getSync(uuid)            // 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

Default is async (Promise), synchronous version adds Sync suffix.

js
entity.remove()                       // Promise
entity.removeSync()
entity.teleport(loc)                  // Promise
entity.teleportSync(loc)

Async Property Access

Sync GetterAsync MethodReturn
entity.typeentity.getType()Promise<string> (minecraft registration key, e.g., minecraft:zombie)
entity.nameentity.getName()Promise<string>
entity.customNameentity.getCustomName()Promise<string | null>
entity.worldentity.getWorld()Promise<string | null>
entity.locationentity.getLocation()Promise<Location | null>
entity.isGlowingentity.isGlowingAsync()Promise<boolean>
entity.isInvulnerableentity.isInvulnerableAsync()Promise<boolean>
entity.isSilententity.isSilentAsync()Promise<boolean>
entity.hasGravityentity.hasGravityAsync()Promise<boolean>
entity.passengersentity.getPassengers()Promise<string[]>
entity.vehicleentity.getVehicle()Promise<string | null>
entity.boundingBoxentity.getBoundingBox()Promise<BoundingBox> ({ minX, minY, minZ, maxX, maxY, maxZ })

Async setter (sync setter is property assignment):

js
entity.setCustomName(name)            // Promise
entity.setGlowing(flag)               // Promise
entity.setInvulnerable(flag)          // Promise
entity.setSilent(flag)                // Promise
entity.setGravity(flag)               // Promise
entity.setCustomNameVisible(flag)     // Promise

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
    });
}