Script API - v1.20.0
    Preparing search index...

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

    Hierarchy (View Summary)

    Index

    Properties

    dimension: Dimension

    Dimension that the entity is currently within.

    This property can throw when used.

    id: string

    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.

    This property can throw when used.

    location: Vector3

    Current location of the entity.

    This property can throw when used.

    nameTag: string

    Given name of the entity.

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

    typeId: string

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

    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.

      Adds a specified tag to an entity.

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

      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.

      Applies a set of damage to an entity.

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

      This function can throw errors.

    • Parameters

      Returns void

      Applies impulse vector to the current velocity of the entity.

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

      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

      Applies impulse vector to the current velocity of the entity.

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

      This function can throw errors.

    • Returns void

      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.

      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.

      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.

      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.

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

      This function can throw errors.

    • Returns string[]

      Returns the current rotation component of this entity.

      Returns all tags associated with an entity.

      This function can throw errors.

    • Returns Vector3

      Returns the current velocity vector of the entity.

      Returns the current velocity vector of the entity.

      This function can throw errors.

    • Returns Vector3

      Returns the current view direction of the entity.

      Returns the current view direction of the entity.

      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.

      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.

      Returns whether an entity has a particular tag.

      This function can throw errors.

    • Returns boolean

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

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

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

      This function can throw errors.

    • Parameters

      • tag: string

        Content of the tag to remove.

      Returns boolean

      Returns whether the tag existed on the entity.

      Removes a specified tag from an entity.

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

      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.

      Runs a synchronous command on the entity.

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

      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.

      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.

      This function can throw errors.