类 EntityLeashableComponent实验性

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

层级 (查看层级一览)

属性

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.

entity: Entity

拥有此组件的实体。若该实体已被移除,则为 undefined。

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

使用时可能会抛出异常。

This property can throw when used.

InvalidEntityError

hardDistance: number

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

This property can throw when used.

isLeashed: boolean

Returns true if the entity is leashed.

This property can throw when used.

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.

leashHolder?: Entity

Entity that is holding the leash.

This property can throw when used.

leashHolderEntityId?: string

Identifier of entity that is holding the leash.

This property can throw when used.

maxDistance: number

Distance in blocks at which the leash breaks.

This property can throw when used.

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.

typeId: string

组件的标识符。 Identifier of the component.

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

方法

  • 实验性

    参数

    • leashHolder: Entity

      The entity to leash this entity to.

    返回 void

    Leashes this entity to another entity.

    无法在只读模式下调用此函数,详见 WorldBeforeEvents

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

  • 实验性

    返回 void

    Unleashes this entity if it is leashed to another entity.

    无法在只读模式下调用此函数,详见 WorldBeforeEvents

    This function can throw errors.