For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /server/classes/EntityLeashableComponent.md.

Class: EntityLeashableComponent

entity component

Beta

允许实体被拴绳拴住。定义实体被拴绳时的条件和事件。

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

Extends

Properties

canBeStolen

readonly canBeStolen: boolean

Beta

Remarks

如果另一个实体可以通过附加自己的拴绳来"偷走"被拴的实体,则返回 true

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

Throws

This property can throw when used.


entity

readonly entity: Entity

Beta

Remarks

拥有此组件的实体。如果实体已被移除,则实体将为 undefined

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

Throws

This property can throw when used.

InvalidEntityError

Inherited from

EntityComponent.entity


hardDistance

readonly hardDistance: number

Beta

Remarks

拴绳变硬并限制移动的距离(以方块为单位)。

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

Throws

This property can throw when used.


isLeashed

readonly isLeashed: boolean

Beta

Remarks

如果实体被拴住则返回 true

Returns true if the entity is leashed.

Throws

This property can throw when used.


isValid

readonly isValid: boolean

Beta

Remarks

返回该组件是否有效。如果组件的拥有者有效,并且满足组件所需的任何额外验证,则该组件被视为有效。

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.

Inherited from

EntityComponent.isValid


leashHolder?

readonly optional leashHolder?: Entity

Beta

Remarks

牵着拴绳的实体。

Entity that is holding the leash.

Throws

This property can throw when used.


leashHolderEntityId?

readonly optional leashHolderEntityId?: string

Beta

Remarks

牵着拴绳的实体的标识符。

Identifier of entity that is holding the leash.

Throws

This property can throw when used.


maxDistance

readonly maxDistance: number

Beta

Remarks

拴绳断裂的距离(以方块为单位)。

Distance in blocks at which the leash breaks.

Throws

This property can throw when used.


softDistance

readonly softDistance: number

Beta

Remarks

"弹簧"效应开始作用以保持此实体靠近拴住它的实体的距离(以方块为单位)。

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

Throws

This property can throw when used.


typeId

readonly typeId: string

Beta

Remarks

组件的标识符。

Identifier of the component.

Inherited from

EntityComponent.typeId


componentId

readonly static componentId: "minecraft:leashable" = 'minecraft:leashable'

Beta

Methods

leashTo()

leashTo(leashHolder): void

World Mutation Beta

Parameters

leashHolder

Entity

要将此实体拴到的实体。

The entity to leash this entity to.

Returns

void

Remarks

将此实体拴到另一个实体上。

Leashes this entity to another entity.

Throws

如果要拴到的实体超过最大距离,或者玩家死亡或处于旁观模式,则抛出异常。

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


unleash()

unleash(): void

World Mutation Beta

Returns

void

Remarks

如果此实体被拴到另一个实体上,则解开拴绳。

Unleashes this entity if it is leashed to another entity.

Throws

This function can throw errors.

同领域相关