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

    Class EntityLeashableComponent

    Allows the entity to be leashed. Defines the conditions and events for when an entity is leashed.

    import { world } from "@minecraft/server";

    const entity = world.getEntity("-10000000000");
    const leashHolderEntity = world.getEntity("-10000000000");
    const leashable = entity.getComponent("leashable");
    leashable.softDistance;
    leashable.leashTo(leashHolderEntity); // Assuming you have an 'leashHolderEntity' instance
    leashable.unleash();
    leashable.isValid;

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    canBeStolen: boolean

    Returns true if another entity can 'steal' the leashed entity by attaching their own leash to it.

    This property can throw when used.

    This property can't be read in early-execution mode.

    entity: Entity

    The entity that owns this component. The entity will be undefined if it has been removed.

    This property can throw when used.

    InvalidEntityError

    This property can't be read in early-execution mode.

    hardDistance: number

    Distance in blocks at which the leash stiffens, restricting movement.

    This property can throw when used.

    This property can't be read in early-execution mode.

    isLeashed: boolean

    Returns true if the entity is leashed.

    This property can throw when used.

    This property can't be read in early-execution mode.

    isValid: boolean

    Returns whether the component is valid. A component is considered valid if its owner is valid, in addition to any addition to any additional validation required by the component.

    This property can't be read in early-execution mode.

    leashHolder?: Entity

    Entity that is holding the leash.

    This property can throw when used.

    This property can't be read in early-execution mode.

    leashHolderEntityId?: string

    Identifier of entity that is holding the leash.

    This property can throw when used.

    This property can't be read in early-execution mode.

    maxDistance: number

    Distance in blocks at which the leash breaks.

    This property can throw when used.

    This property can't be read in early-execution mode.

    softDistance: number

    Distance in blocks at which the 'spring' effect starts acting to keep this entity close to the entity that leashed it.

    This property can throw when used.

    This property can't be read in early-execution mode.

    typeId: string

    Identifier of the component.

    This property can't be read in early-execution mode.

    componentId: "minecraft:leashable" = 'minecraft:leashable'

    Methods

    • Parameters

      • leashHolder: Entity

        The entity to leash this entity to.

      Returns void

      Leashes this entity to another entity.

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

      Throws if the entity to leash to is over the max distance, and if the player is dead or in spectator mode.

      This function can't be called in early-execution mode.

    • Returns void

      Unleashes this entity if it is leashed to another entity.

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

      This function can throw errors.

      This function can't be called in early-execution mode.