Skip to content
BasaltSoftware
Bedrock 1.26.60

Site colour

Discord
Esc

    ↑↓ moveEnter openEsc close

    Keyboard shortcuts
    Ctrl K
    Search the whole site, from any page
    /
    Jump to the sidebar search, or search the whole site where there isn't one
    Enter
    Open the top search result
    Esc
    Clear the search, or close this panel
    ?
    Show these shortcuts

    Class in @minecraft/server

    Extended by ItemEntity, Player

    A mob, item, orb, arrow, cloud or minecart in the world, or a player.

    import { Entity } from '@minecraft/server';
    import { world, type Entity } from '@minecraft/server';
    const overworld = world.getDimension('overworld');
    const [player] = world.getAllPlayers();
    // Name every zombie within 16 blocks of the first player.
    if (player) {
    const zombies: Entity[] = overworld.getEntities({
    type: 'minecraft:zombie',
    location: player.location,
    maxDistance: 16,
    });
    for (const zombie of zombies) zombie.nameTag = 'Walker';
    }
    import { world } from '@minecraft/server';
    const overworld = world.getDimension('overworld');
    const [player] = world.getAllPlayers();
    // Name every zombie within 16 blocks of the first player.
    if (player) {
    const zombies = overworld.getEntities({
    type: 'minecraft:zombie',
    location: player.location,
    maxDistance: 16,
    });
    for (const zombie of zombies)
    zombie.nameTag = 'Walker';
    }
    protected constructor();

    read-only

    readonly id: string;

    Its unique id for this session.

    read-only

    readonly typeId: string;

    As minecraft:zombie.

    read-only

    readonly isValid: boolean;

    False once it’s gone.

    read-only

    readonly dimension: Dimension;

    The dimension it is in. Basalt has only the overworld.

    read-only

    readonly location: Vector3;

    Where it is: a player’s feet, a mob’s feet, an item’s centre.

    Types
    nameTag: string;

    The name over its head, "" for none.

    read-only

    readonly localizationKey: string;

    Its name key in the language files, as entity.zombie.name.

    read-only

    readonly isOnGround: boolean;

    Whether it stands on something.

    read-only

    readonly isInWater: boolean;

    Whether it’s in water. Always false for items, orbs, arrows and clouds.

    read-only

    readonly isFalling: boolean;

    Whether it’s in the air and has fallen some way.

    read-only

    readonly fallDistance: number;

    Blocks fallen since it was last on the ground.

    read-only

    readonly isClimbing: boolean;

    Whether it’s on a ladder or vine. Only players climb in Basalt.

    read-only

    readonly isSwimming: boolean;

    Whether it’s swimming. Only players swim in Basalt.

    read-only

    readonly isSneaking: boolean;

    Whether it’s sneaking. Only players sneak in Basalt.

    read-only

    readonly isSprinting: boolean;

    Whether it’s sprinting. Only players sprint in Basalt.

    read-only

    readonly scoreboardIdentity: ScoreboardIdentity | undefined;

    Its identity on the scoreboard, once it has a score.

    read-only

    readonly isSleeping: boolean;

    Whether it’s asleep.

    nameplateDepthTested: boolean;

    Whether its nameplate is hidden behind blocks.

    nameplateRenderDistance: number;

    How far its nameplate shows, in blocks.

    getHeadLocation(): Vector3;

    Where its eyes are.

    Returns
    Vector3
    Types
    getComponent<T extends keyof EntityComponentTypeMap>(componentId: T): EntityComponentTypeMap[T] | undefined;
    getComponent(componentId: string): unknown;

    One of its components: minecraft:health for mobs and players, minecraft:inventory for players, minecraft:equippable for players and mobs, minecraft:item for items. undefined if it has none such.

    getComponents(): unknown[];

    Every component it has.

    Returns
    unknown[]
    hasComponent(componentId: string): boolean;

    Whether it has the component, as minecraft:health.

    Parameters
    componentId
    string
    Returns
    boolean
    matches(options: EntityQueryOptions & EntityFilterOptions): boolean;

    Whether it passes these filters, as Dimension.getEntities would pick it.

    Parameters
    options
    EntityQueryOptions & EntityFilterOptions
    Returns
    boolean
    getVelocity(): Vector3;

    How fast it moves, in blocks a tick.

    Returns
    Vector3
    Types
    getRotation(): Vector2;

    Where it looks: x is the pitch (down positive) and y the yaw, in degrees.

    Returns
    Vector2
    Types
    getViewDirection(): Vector3;

    A unit vector along where it looks, as getViewDirection in BDS.

    Returns
    Vector3
    Types
    applyImpulse(vector: Vector3): void;

    Adds to its motion.

    Parameters
    vector
    Vector3
    Types
    clearVelocity(): void;

    Stops it moving.

    setVelocity(velocity: Vector3): void;

    Sets its motion outright.

    Parameters
    velocity
    Vector3
    Types
    applyKnockback(horizontalForce: VectorXZ, verticalStrength: number): void;

    Pushes it: horizontalForce across and verticalStrength up, as a hit’s knockback does. Its motion is set to the push, not added to it.

    Parameters
    horizontalForce
    VectorXZ
    verticalStrength
    number
    teleport(location: Vector3, teleportOptions?: TeleportOptions): void;

    Moves it at once, optionally turning it. A player’s client is held until it arrives, so nothing desyncs.

    Parameters
    location
    Vector3
    teleportOptionsoptional
    TeleportOptions
    getTags(): string[];

    Its tags, in the order they were added, saved with it. A cloud’s last only as long as it does, since clouds aren’t saved.

    Returns
    string[]
    hasTag(tag: string): boolean;

    Whether it has the tag.

    Parameters
    tag
    string
    Returns
    boolean
    addTag(tag: string): boolean;
    Parameters
    tag
    string
    Returns
    booleanFalse if it had the tag already.
    removeTag(tag: string): boolean;
    Parameters
    tag
    string
    Returns
    booleanFalse if it didn’t have the tag.
    getDynamicProperty(identifier: string): DynamicPropertyValue | undefined;

    A dynamic property this plugin set, kept apart from other plugins’ by the manifest’s uuid and saved with the entity. undefined if it isn’t set.

    Parameters
    identifier
    string
    Returns
    DynamicPropertyValue | undefined
    setDynamicProperty(identifier: string, value?: DynamicPropertyValue): void;

    Sets a dynamic property, or takes it away with undefined.

    Parameters
    identifier
    string
    valueoptional
    DynamicPropertyValue
    Throws
    • If the value isn’t a boolean, finite number, string of at most 32767 bytes or Vector3.
    setDynamicProperties(values: Record<string, DynamicPropertyValue>): void;

    Sets several of this plugin’s properties at once; undefined values take them away.

    Parameters
    values
    Record<string, DynamicPropertyValue>
    getDynamicPropertyIds(): string[];

    The identifiers of every property this plugin set on it.

    Returns
    string[]
    getDynamicPropertyTotalByteCount(): number;

    The bytes this plugin’s properties take, their identifiers and values.

    Returns
    number
    clearDynamicProperties(): void;

    Takes away every property this plugin set on it.

    runCommand(commandString: string): CommandResult;

    Runs a command with the server’s permission, ~ counting from where the entity is.

    Parameters
    commandString
    string
    Returns
    CommandResult
    Throws
    • If the command fails or the server hasn’t started.
    kill(): boolean;

    Kills a mob with its death and drops, or takes anything else away.

    Returns
    boolean
    remove(): void;

    Takes it out of the world with no death and no drops.

    addEffect(effectType: EffectType | string, duration: number, options?: EntityEffectOptions): Effect | undefined;

    Gives or refreshes an effect for duration ticks.

    Parameters
    effectType
    EffectType | string
    duration
    number
    optionsoptional
    EntityEffectOptions
    Returns
    Effect | undefined
    getEffect(effectType: EffectType | string): Effect | undefined;

    One of its effects, or undefined if it doesn’t have it.

    Parameters
    effectType
    EffectType | string
    Returns
    Effect | undefined
    getEffects(): Effect[];

    Every effect on it.

    Returns
    Effect[]
    Types
    removeEffect(effectType: EffectType | string): boolean;
    Parameters
    effectType
    EffectType | string
    Returns
    booleanWhether it had the effect.
    addItem(itemStack: ItemStack): ItemStack | undefined;

    Drops the item at its feet; returns what didn’t fit.

    Parameters
    itemStack
    ItemStack
    Returns
    ItemStack | undefined
    applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean;

    Hurts it, optionally crediting a source.

    Parameters
    amount
    number
    optionsoptional
    EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions
    Returns
    boolean
    setOnFire(seconds: number, useEffects?: boolean): boolean;

    Sets it on fire for seconds.

    Parameters
    seconds
    number
    useEffectsoptional
    boolean
    Returns
    booleanWhether it took.
    extinguishFire(useEffects?: boolean): boolean;

    Puts its fire out.

    Parameters
    useEffectsoptional
    boolean
    Returns
    booleanWhether it was burning.
    lookAt(targetLocation: Vector3): void;

    Turns it to face a point.

    Parameters
    targetLocation
    Vector3
    Types
    setRotation(rotation: Vector2): void;

    Sets where it looks: x the pitch, y the yaw, in degrees.

    Parameters
    rotation
    Vector2
    Types
    playAnimation(animationName: string, options?: PlayAnimationOptions): void;

    Plays one of its animations.

    Parameters
    animationName
    string
    optionsoptional
    PlayAnimationOptions
    triggerEvent(eventName: string): void;

    Fires a data-driven entity event on it, as /event entity.

    Parameters
    eventName
    string
    tryTeleport(location: Vector3, teleportOptions?: TeleportOptions): boolean;

    Like teleport, but returns false instead of throwing when it can’t.

    Parameters
    location
    Vector3
    teleportOptionsoptional
    TeleportOptions
    Returns
    boolean
    getProperty(identifier: string): boolean | number | string | undefined;

    An entity property from its definition; undefined if it has none such.

    Parameters
    identifier
    string
    Returns
    boolean | number | string | undefined
    setProperty(identifier: string, value: boolean | number | string): void;

    Sets an entity property defined on its type.

    Parameters
    identifier
    string
    value
    boolean | number | string
    resetProperty(identifier: string): boolean | number | string;

    Puts an entity property back to its default.

    Parameters
    identifier
    string
    Returns
    boolean | number | stringThe default.
    getBlockFromViewDirection(options?: BlockRaycastOptions): BlockRaycastHit | undefined;

    The first block its view line hits, as a raycast from its eyes.

    Parameters
    optionsoptional
    BlockRaycastOptions
    Returns
    BlockRaycastHit | undefined
    getEntitiesFromViewDirection(options?: EntityRaycastOptions): EntityRaycastHit[];

    The entities its view line crosses, nearest first.

    Parameters
    optionsoptional
    EntityRaycastOptions
    Returns
    EntityRaycastHit[]
    getBlockStandingOn(options?: GetBlocksStandingOnOptions): Block | undefined;

    The block it stands on, or undefined if none.

    Parameters
    optionsoptional
    GetBlocksStandingOnOptions
    Returns
    Block | undefined
    getAllBlocksStandingOn(options?: GetBlocksStandingOnOptions): Block[];

    Every block it stands on.

    Parameters
    optionsoptional
    GetBlocksStandingOnOptions
    Returns
    Block[]
    getAABB(): AABB;

    Its bounding box in world space.

    Returns
    AABB
    Types

    EntityDamageSource.damagingEntity, EntityHealthComponent.entity, EntityEquippableComponent.entity, EntityRideableComponent.entity, EntityRideableComponent.addRider, EntityRideableComponent.ejectRider, EntityRideableComponent.getRiders, EntityRidingComponent.entity, EntityRidingComponent.entityRidingOn, Player.setPropertyOverrideForEntity, Player.removePropertyOverrideForEntity, Player.clearPropertyOverridesForEntity, ExplosionOptions.source, Dimension.getEntities, Dimension.spawnEntity, Dimension.getEntitiesAtBlockLocation, ScoreboardIdentity.getEntity, EntityHurtAfterEvent.hurtEntity, EntityHurtBeforeEvent.hurtEntity, EntityDieAfterEvent.deadEntity, EntitySpawnAfterEvent.entity, PlayerInteractWithEntityAfterEvent.target, BlockExplodeAfterEvent.source, EntityDieBeforeEvent.deadEntity and 69 more