Represents the state of an entity (a mob, the player, or other moving objects like minecarts) in the world.

Hierarchy

Constructors

  • Returns Entity

Properties

dimension: Dimension

Remarks

Dimension that the entity is currently within.

Throws

This property can throw when used.

id: string

Remarks

Unique identifier of the entity. This identifier is intended to be consistent across loads of a world instance. No meaning should be inferred from the value and structure of this unique identifier - do not parse or interpret it.

Throws

This property can throw when used.

location: Vector3

Remarks

Current location of the entity.

Throws

This property can throw when used.

nameTag: string

Remarks

Given name of the entity.

This property can't be edited in read-only mode.

typeId: string

Remarks

Unique identifier of the type of the entity - for example, 'minecraft:skeleton'.

Throws

This property can throw when used.

Methods

  • Parameters

    • tag: string

      Content of the tag to add.

    Returns boolean

    Returns true if the tag was added successfully. This can fail if the tag already exists on the entity.

    Remarks

    Adds a specified tag to an entity.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.

  • Parameters

    Returns boolean

    Whether the entity takes any damage. This can return false if the entity is invulnerable or if the damage applied is less than or equal to 0.

    Remarks

    Applies a set of damage to an entity.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.

  • Parameters

    Returns void

    Remarks

    Applies impulse vector to the current velocity of the entity.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.

  • Parameters

    • directionX: number

      X direction in horizontal plane.

    • directionZ: number

      Z direction in horizontal plane.

    • horizontalStrength: number

      Knockback strength for the horizontal vector.

    • verticalStrength: number

      Knockback strength for the vertical vector.

    Returns void

    Remarks

    Applies impulse vector to the current velocity of the entity.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.

  • Returns void

    Remarks

    Sets the current velocity of the Entity to zero. Note that this method may not have an impact on Players.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.

  • Parameters

    • componentId: string

      The identifier of the component (e.g., 'minecraft:rideable') to retrieve. If no namespace prefix is specified, 'minecraft:' is assumed. If the component is not present on the entity, undefined is returned.

    Returns undefined | EntityComponent

    Returns the component if it exists on the entity, otherwise undefined.

    Remarks

    Gets a component (that represents additional capabilities) for an entity.

  • Returns EntityComponent[]

    Returns all components that are both present on this entity and supported by the API.

    Remarks

    Returns all components that are both present on this entity and supported by the API.

  • Returns Vector3

    Returns the current location of the head component of this entity.

    Remarks

    Returns the current location of the head component of this entity.

    Throws

    This function can throw errors.

  • Returns string[]

    Returns the current rotation component of this entity.

    Remarks

    Returns all tags associated with an entity.

    Throws

    This function can throw errors.

  • Returns Vector3

    Returns the current velocity vector of the entity.

    Remarks

    Returns the current velocity vector of the entity.

    Throws

    This function can throw errors.

  • Returns Vector3

    Returns the current view direction of the entity.

    Remarks

    Returns the current view direction of the entity.

    Throws

    This function can throw errors.

  • Parameters

    • componentId: string

      The identifier of the component (e.g., 'minecraft:rideable') to retrieve. If no namespace prefix is specified, 'minecraft:' is assumed.

    Returns boolean

    Returns true if the specified component is present on this entity.

    Remarks

    Returns true if the specified component is present on this entity.

  • Parameters

    • tag: string

      Identifier of the tag to test for.

    Returns boolean

    Returns whether an entity has a particular tag.

    Remarks

    Returns whether an entity has a particular tag.

    Throws

    This function can throw errors.

  • Returns boolean

    Returns true if entity can be killed (even if it is already dead), otherwise it returns false.

    Remarks

    Kills this entity. The entity will drop loot as normal.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.

  • Parameters

    • tag: string

      Content of the tag to remove.

    Returns boolean

    Returns whether the tag existed on the entity.

    Remarks

    Removes a specified tag from an entity.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.

  • Parameters

    • commandString: string

      The command string. Note: This should not include a leading forward slash.

    Returns CommandResult

    A command result containing whether the command was successful.

    Remarks

    Runs a synchronous command on the entity.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.

  • Parameters

    • commandString: string

      Command to run. Note that command strings should not start with slash.

    Returns Promise<CommandResult>

    For commands that return data, returns a JSON structure with command response values.

    Remarks

    Runs a particular command asynchronously from the context of this entity. Note that there is a maximum queue of 128 asynchronous commands that can be run in a given tick.

    Throws

    This function can throw errors.