Skip to content

@minecraft/server


@minecraft/server / EntityLeashableComponent

Class: EntityLeashableComponent ​

Defined in: @minecraft/server/index.d.ts:11310

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

Extends ​

Properties ​

canBeStolen ​

readonly canBeStolen: boolean

Defined in: @minecraft/server/index.d.ts:11319

Remarks ​

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

Defined in: @minecraft/server/index.d.ts:9981

Remarks ​

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

Defined in: @minecraft/server/index.d.ts:11327

Remarks ​

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

Throws ​

This property can throw when used.


isLeashed ​

readonly isLeashed: boolean

Defined in: @minecraft/server/index.d.ts:11334

Remarks ​

Returns true if the entity is leashed.

Throws ​

This property can throw when used.


isValid ​

readonly isValid: boolean

Defined in: @minecraft/server/index.d.ts:6234

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

Defined in: @minecraft/server/index.d.ts:11341

Remarks ​

Entity that is holding the leash.

Throws ​

This property can throw when used.


leashHolderEntityId? ​

readonly optional leashHolderEntityId?: string

Defined in: @minecraft/server/index.d.ts:11348

Remarks ​

Identifier of entity that is holding the leash.

Throws ​

This property can throw when used.


maxDistance ​

readonly maxDistance: number

Defined in: @minecraft/server/index.d.ts:11355

Remarks ​

Distance in blocks at which the leash breaks.

Throws ​

This property can throw when used.


softDistance ​

readonly softDistance: number

Defined in: @minecraft/server/index.d.ts:11364

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

Defined in: @minecraft/server/index.d.ts:6240

Remarks ​

Identifier of the component.

Inherited from ​

EntityComponent.typeId


componentId ​

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

Defined in: @minecraft/server/index.d.ts:11365

Methods ​

leashTo() ​

leashTo(leashHolder): void

Defined in: @minecraft/server/index.d.ts:11378

Parameters ​

leashHolder ​

Entity

The entity to leash this entity to.

Returns ​

void

Remarks ​

Leashes this entity to another entity.

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

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

Defined in: @minecraft/server/index.d.ts:11387

Returns ​

void

Remarks ​

Unleashes this entity if it is leashed to another entity.

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

Throws ​

This function can throw errors.