Перейти к основному содержанию

Entity

Module used to manipulate entities (mobs, drop, arrows, etc.) in the world. Every entity has it's unique numeric ID which is often used across this module as the first function parameter.

Index

Classes

EntityHealth

EntityHealth:

Class used to manipulate entity's health.

@deprecated

constructor

get

  • get(): number
  • @throws

    No such method.


    Returns number

    Entity's current health value.

getMax

  • getMax(): number
  • @throws

    No such method.


    Returns number

    Entity's maximum health value.

set

  • set(health: number): void
  • Sets entity's current health value.

    @throws

    No such method.


    Parameters

    • health: number

      health value to be set

    Returns void

setMax

  • setMax(maxHealth: number): void
  • Sets entity's maximum health value.

    @throws

    No such method.


    Parameters

    • maxHealth: number

    Returns void

Interfaces

AttributeInstance

AttributeInstance:

Interface used to modify attribute values.

@since

2.0.3b33

getDefaultValue

  • getDefaultValue(): number

  • Returns number

    Attribute's default value

getMaxValue

  • getMaxValue(): number

  • Returns number

    Attribute's maximum value.

getMinValue

  • getMinValue(): number

  • Returns number

    Attribute's minimum value.

getValue

  • getValue(): number

  • Returns number

    Current attribute's value.

setDefaultValue

  • setDefaultValue(value: number): void
  • Sets attribute's default value.


    Parameters

    • value: number

    Returns void

setMaxValue

  • setMaxValue(value: number): void
  • Sets attribute's maximum value.


    Parameters

    • value: number

    Returns void

setMinValue

  • setMinValue(value: number): void
  • Sets attribute's minimum value.


    Parameters

    • value: number

    Returns void

setValue

  • setValue(value: number): void
  • Sets current attribute's value.


    Parameters

    • value: number

    Returns void

EffectInstance

EffectInstance:

duration

duration: number

level

level: number

MoveParams

MoveParams:

Interface used to specify how entity should move.

optionaldenyY

denyY?: boolean

If true, entity won't change it's Y velocity.

optionaljumpVel

jumpVel?: number

Y velocity (jump speed).

optionalspeed

speed?: number

Movement speed.

MovingVector

MovingVector:

Interface used to return entity's current moving vector and some additional data.

size

size: number

Vector real length.

x

x: number

Normalized vector X coordinate.

xzsize

xzsize: number

Vector real length excluding Y coordinate.

y

y: number

Normalized vector Y coordinate.

z

z: number

Normalized vector Z coordinate.

PathNavigation

PathNavigation:

Object used to build path and move mobs to the required coordinates using specified parameters. All the setters return current Entity.PathNavigation instance to be able to produce chained calls.

@since

2.0.3b33

canOpenDoors

  • canOpenDoors(): boolean

  • Returns boolean

    Whether the entity can open doors.

canPassDoors

  • canPassDoors(): boolean

  • Returns boolean

    Whether the entity can pass doors.

getAvoidDamageBlocks

  • getAvoidDamageBlocks(): boolean
  • Returns boolean

getAvoidPortals

  • getAvoidPortals(): boolean
  • Returns boolean

getAvoidSun

  • getAvoidSun(): boolean
  • @since

    2.2.1b93


    Returns boolean

getAvoidWater

  • getAvoidWater(): boolean

  • Returns boolean

    Whether the entity avoids water.

getCanBreach

  • getCanBreach(): boolean
  • Returns boolean

getCanFloat

  • getCanFloat(): boolean
  • Returns boolean

getCanJump

  • getCanJump(): boolean

  • Returns boolean

    Whether entity can jump.

getCanOpenIronDoors

  • getCanOpenIronDoors(): boolean
  • @since

    2.2.1b93


    Returns boolean

getCanPathOverLava

  • getCanPathOverLava(): boolean
  • @since

    2.2.1b93


    Returns boolean

getCanSink

  • getCanSink(): boolean
  • Returns boolean

getCanWalkInLava

  • getCanWalkInLava(): boolean
  • @since

    2.2.1b93


    Returns boolean

getHasEndPathRadius

  • getHasEndPathRadius(): boolean
  • @since

    2.2.1b93


    Returns boolean

getSpeed

  • getSpeed(): number

  • Returns number

    Entity's speed value.

getTerminationThreshold

  • getTerminationThreshold(): number
  • getTerminationThreshold(threshold: number): PathNavigation
  • @since

    2.2.1b93


    Returns number

getTickTimeout

  • getTickTimeout(): number
  • @since

    2.2.1b93


    Returns number

isAmphibious

  • isAmphibious(): boolean
  • Returns boolean

isRiverFollowing

  • isRiverFollowing(): boolean
  • Returns boolean

isStuck

  • isStuck(ticks: number): boolean
  • @since

    2.2.1b93


    Parameters

    • ticks: number

    Returns boolean

moveToCoords

  • moveToCoords(x: number, y: number, z: number, speed: number): PathNavigation
  • Builds path to the specified coordinates.


    Parameters

    • x: number
    • y: number
    • z: number
    • speed: number

      entity movement speed

    Returns PathNavigation

moveToEntity

  • Builds path to the specified entity. Note that current coordinates of entity are used, and are not updated.


    Parameters

    • entity: number
    • speed: number

      entity movement speed

    Returns PathNavigation

setAvoidDamageBlocks

setAvoidPortals

setAvoidSun

  • Sets entity's sun avoiding.


    Parameters

    • avoid: boolean

    Returns PathNavigation

setAvoidWater

  • Sets entity's water avoiding.


    Parameters

    • avoid: boolean

    Returns PathNavigation

setCanBreach

setCanFloat

setCanJump

  • Enables or disables entity's jumping ability.


    Parameters

    • can: boolean

    Returns PathNavigation

setCanOpenDoors

  • Sets entity's door opening ability.


    Parameters

    • can: boolean

    Returns PathNavigation

setCanOpenIronDoors

setCanPassDoors

  • Sets entity's door passing ability.


    Parameters

    • can: boolean

    Returns PathNavigation

setCanPathOverLava

setCanSink

setCanWalkInLava

setEndPathRadius

setHasEndPathRadius

setIsAmphibious

setIsRiverFollowing

setResultFunction

setSpeed

  • Sets entity's speed value.


    Parameters

    • speed: number

    Returns PathNavigation

setTickTimeout

PathNavigationResultFunction

Type Aliases

Attribute

Attribute: minecraft:follow_range | minecraft:luck | minecraft:lava_movement | minecraft:underwater_movement | minecraft:movement | minecraft:knockback_resistance | minecraft:absorption | minecraft:health | minecraft:attack_damage | minecraft:jump_strength

DamageSource

DamageSource: number

Damage sources, which are used to determine entity damage type:

TypeNameMessageTranslation
0Generic"death.attack.generic" (fallback damage source)* died
1Cactus"death.attack.cactus" (only when standing on cactus)* was pricked to death
2Mob"death.attack.mob"* was slain by *
3Impactn/a
4In Wall"death.attack.inWall"* suffocated in a wall
5Fall"death.attack.fall" OR "death.fell.accident.generic"* hit the ground too hard OR * fell from a high place
6In Fire"death.attack.inFire"* went up in flames
7On Fire"death.attack.onFire"* burned to death
8Lava"death.attack.lava"* tried to swim in lava
9Drown"death.attack.drown"* drowned
10Explosion"death.attack.explosion"* blew up
11Explosion (Player)"death.attack.explosion"* was blown up by *
12Out Of World"death.attack.outOfWorld"* fell out of the world
13Commandn/a
14Magic"death.attack.magic"* was killed by magic
15Wither"death.attack.wither"* withered away
16Starve"death.attack.starve"* starved to death
17Anvil"death.attack.anvil"* was squashed by a falling anvil
18Thorns"death.attack.thorns"* was killed trying to hurt *
19Projectilen/a
20Falling Block"death.attack.fallingBlock"* was squashed by a falling block
21Fly Into Wall"death.attack.flyIntoWall"* experienced kinetic energy
22Magma"death.attack.magma"* discovered floor was lava
23Fireworks"death.attack.fireworks"* went off with a bang
24Lightning Bolt"death.attack.lightningBolt"* was struck by lightning

PathNavigationResultCode

PathNavigationResultCode: 0 | 1 | 2 | 3 | 4 | 5 | 6

Path navigation result, which is used in result callback:

Result codeMeaning
0Path successfully completed
1Cannot reach target, no available path
2Cannot reach target, out of range
3Entity has been unloaded or removed
4Cancelled by stop() or similar method
5Player left level or server closed
6Result function will be replaced

Functions

addEffect

  • addEffect(entityUid: number, effectId: number, effectData: number, effectTime: number, ambience?: boolean, particles?: boolean): void
  • addEffect(entityUid: number, effectId: number, effectData: number, effectTime: number, ambience: boolean, particles: boolean, effectAnimation: boolean): void
  • Adds an effect to entity.


    Parameters

    • entityUid: number
    • effectId: number

      effect ID, should be one one of EPotionEffect values

    • effectData: number

      effect amplifier

    • effectTime: number

      effect time in ticks

    • optionalambience: boolean

      if true, particles are ambient

    • optionalparticles: boolean

      if true, particles are not displayed

    Returns void

addPosition

  • addPosition(entityUid: number, x: number, y: number, z: number): void
  • Updates current entity position by specified coordinates.


    Parameters

    • entityUid: number
    • x: number
    • y: number
    • z: number

    Returns void

addVelocity

  • addVelocity(entityUid: number, x: number, y: number, z: number): void
  • Updates current entity's velocity by specified value.


    Parameters

    • entityUid: number
    • x: number
    • y: number
    • z: number

    Returns void

clearEffect

  • clearEffect(entityUid: number, id: number): void
  • Clears effect, applied to the mob.


    Parameters

    • entityUid: number
    • id: number

      effect ID, should be one of the EPotionEffect

    Returns void

clearEffects

  • clearEffects(entityUid: number): void
  • Clears all effects of the mob.


    Parameters

    • entityUid: number

    Returns void

damageEntity

  • damageEntity(entityUid: number, damage: number, cause?: number, properties?: { attacker?: number; bool1?: boolean }): void
  • Damages entity.


    Parameters

    • entityUid: number
    • damage: number

      damage value in half-hearts

    • optionalcause: number

      existing DamageSource or any inclusive value between 25 and 32

    • optionalproperties: { attacker?: number; bool1?: boolean }

      additional damage source properties

      • optionalattacker: number

        Entity that caused damage, determines actor of damage source.

      • optionalbool1: boolean

        If true, damage can be reduced by armor.

    Returns void

findNearest

  • findNearest(coords: Vector, type?: number, maxRange?: number): Nullable<number>
  • Retrieves nearest to the coordinates entity of the specified entity type.

    @remarks

    Overheating method, capture entities by BlockSource.fetchEntitiesInAABB and pass over them by checking radius between coords and entity.


    Parameters

    • coords: Vector

      search range center coordinates

    • optionaltype: number

      entity type ID. Parameter is no longer supported and should be 0 in all cases

    • optionalmaxRange: number

      if specified, determines search radius

    Returns Nullable<number>

getAddonEntity

getAge

  • getAge(entityUid: number): number
  • @deprecated

    Use attributes instead.


    Parameters

    • entityUid: number

    Returns number

getAll

  • getAll(): number[]

  • Returns number[]

    An array of all server entities UIDs.

getAllInRange

  • getAllInRange(coords: Vector, maxRange: number, type?: number): number[]
  • Returns array of all entities numeric IDs in given range in blocks.

    @remarks

    Overheating method, capture entities by BlockSource.fetchEntitiesInAABB and pass over them by checking radius between coords and entity.


    Parameters

    • coords: Vector

      search range center coordinates

    • maxRange: number

      determines search radius

    • optionaltype: number

      entity type ID

    Returns number[]

getAllInsideBox

  • getAllInsideBox(coords1: Vector, coords2: Vector, type?: number, flag?: boolean): number[]
  • Returns array of all entities numeric IDs in given range in blocks.

    @since

    2.0.4b35

    @remarks

    Local method, use BlockSource.listEntitiesInAABB instead.


    Parameters

    • coords1: Vector

      start search range coordinates

    • coords2: Vector

      end search range coordinates

    • optionaltype: number

      entity type ID, 255 by default

    • optionalflag: boolean

      white- or blacklist, true by default

    Returns number[]

getAllJS

  • getAllJS(): number[]
  • @deprecated

    Consider using Entity.getAll instead.


    Returns number[]

    An array of all server entities UIDs.

getAllLocal

  • getAllLocal(): number[]
  • @since

    2.4.0b120


    Returns number[]

    An array of all client entities UIDs.

getArmorSlot


  • Parameters

    • entityUid: number
    • slot: number

      armor slot index, should be one of the EArmorType values

    Returns ItemInstance

    Armor slot contents for entity.

getAttribute

  • Creates an object used to change entity's attributes.

    @since

    2.0.3b33


    Parameters

    • entityUid: number

      entity uid

    • attribute: string

      one of Attribute or your custom one

    Returns AttributeInstance

    Object used to manipulate entity's attributes.

getCarriedItem


  • Parameters

    • entityUid: number

    Returns ItemInstance

    Entity's current carried item information.

getCompoundTag

getCustom

  • @deprecated

    Not supported anymore, use behavior packs.


    Parameters

    • entityUid: number

    Returns CustomEntity

    Custom entity object by it's numeric entity UID.

getDimension

  • getDimension(entityUid: number): number
  • @since

    2.0.4b35


    Parameters

    • entityUid: number

    Returns number

    Current dimension numeric ID, one of the EDimension values or custom dimension ID.

getDistanceBetweenCoords

  • getDistanceBetweenCoords(coords1: Vector, coords2: Vector): number

  • Parameters

    Returns number

    Distance in blocks between the two coordinate sets.

getDistanceToCoords

  • getDistanceToCoords(entityUid: number, coords: Vector): number

  • Parameters

    • entityUid: number
    • coords: Vector

    Returns number

    Distance between specified entity and a fixed coordinate set.

getDistanceToEntity

  • getDistanceToEntity(ent1: number, ent2: number): number

  • Parameters

    • ent1: number
    • ent2: number

    Returns number

    Distance in blocks between two entities.

getDroppedItem

  • Gets item from specified drop entity


    Parameters

    • entityUid: number

    Returns ItemInstance

    Instance that is in the dropped item.

getEffect

  • @since

    2.2.1b102


    Parameters

    • entity: number
    • effectId: number

    Returns EffectInstance

    Object with duration and level of the potion effect with given numeric ID on the given entity. These fields are set to 0, if the given effect doesn't affect the given entity at the moment.

getExtra

  • getExtra(entityUid: number, name: string): null
  • @deprecated

    Use attributes instead, or Saver.


    Parameters

    • entityUid: number
    • name: string

    Returns null

getExtraJson

  • getExtraJson(entityUid: number, name: string): object
  • @deprecated

    Use attributes instead, or Saver.


    Parameters

    • entityUid: number
    • name: string

    Returns object

getHealth

  • getHealth(entityUid: number): number

  • Parameters

    • entityUid: number

    Returns number

    Entity's current health value.

getInventory

  • getInventory(entityUid: number, handleNames?: boolean, handleEnchant?: boolean): void
  • @deprecated

    Consider use Entity.getCarriedItem instead.


    Parameters

    • entityUid: number
    • optionalhandleNames: boolean
    • optionalhandleEnchant: boolean

    Returns void

getLookAngle


  • Parameters

    • entityUid: number

    Returns LookAngle

    Entity's look angle in radians.

getLookAt

  • getLookAt(entityUid: number, x: number, y: number, z: number): LookAngle

  • Parameters

    • entityUid: number
    • x: number
    • y: number
    • z: number

    Returns LookAngle

    Look angle between entity and static coordinates.

getLookVector

  • getLookVector(entityUid: number): Vector

  • Parameters

    • entityUid: number

    Returns Vector

    Look vector for the entity.

getLookVectorByAngle

  • Transforms look angle into look vector.


    Parameters

    Returns Vector

    Transformation result.

getMaxHealth

  • getMaxHealth(entityUid: number): number

  • Parameters

    • entityUid: number

    Returns number

    Entity's maximum health value.

getMobile

  • getMobile(entityUid: number): boolean
  • @since

    2.3.1b116-3


    Parameters

    • entityUid: number

    Returns boolean

    true, if entity was immobilized.

getMovingAngle

  • Retrieves entity look angle in the form of pitch/yaw angle. No other information included to the resulting object.


    Parameters

    • entityUid: number

    Returns LookAngle

getMovingAngleByPositions

  • getMovingAngleByPositions(pos1: any, pos2: any): undefined
  • @deprecated

    Nothing to perform here anymore.


    Parameters

    • pos1: any
    • pos2: any

    Returns undefined

getMovingVector

  • Retrieves entity's current movement information.


    Parameters

    • entityUid: number

    Returns MovingVector

    Object that contains normalized moving vector, moving speed and moving xz speed (with no Y coordinate).

getNameTag

  • getNameTag(entityUid: number): string
  • @since

    2.2.1b97 (not working before)


    Parameters

    • entityUid: number

    Returns string

    Entity name tag or player name.

getOffhandItem


  • Parameters

    • entityUid: number

    Returns ItemInstance

    Entity's current offhand item information.

getPathNavigation

  • Creates or gets an existing Entity.PathNavigation instance for the specified mob

    @since

    2.0.3b33


    Parameters

    • entityUid: number

    Returns PathNavigation

    Navigation used to control entity's target position and the way to get there.

getPosition

  • getPosition(entityUid: number): Vector

  • Parameters

    • entityUid: number

    Returns Vector

    Entity position.

getProjectileItem

getRender

  • getRender(entityUid: number): number
  • @deprecated

    Use resource packs instead.


    Parameters

    • entityUid: number

    Returns number

    Entity render type, should be one of the EMobRenderType values.

getRider

  • getRider(entityUid: number): number

  • Parameters

    • entityUid: number

    Returns number

    Entity that is riding the specified entity.

getRiding

  • getRiding(entityUid: number): number

  • Parameters

    • entityUid: number

    Returns number

    Entity that is ridden by specified entity.

getSkin

  • getSkin(entityUid: number): string
  • @deprecated

    Use NBT instead.


    Parameters

    • entityUid: number

    Returns string

getSneaking

  • getSneaking(entityUid: number): boolean

  • Parameters

    • entityUid: number

    Returns boolean

    true if entity is sneaking, false otherwise.

getTarget

  • getTarget(entityUid: number): number
  • Gets the attack target of current entity.


    Parameters

    • entityUid: number

    Returns number

    Target entity's unique ID.

getType

  • getType(entityUid: number): number

  • Parameters

    • entityUid: number

    Returns number

    Numeric entity type, one of the EEntityType.

getTypeAddon

  • getTypeAddon(entityUid: number): Nullable<string>

getTypeName

  • getTypeName(entityUid: number): string

  • Parameters

    • entityUid: number

    Returns string

    String entity type, like minecraft:chicken<> (<namespace>:<identifier>[<attributes>]).

getTypeUniversal

  • getTypeUniversal(entityUid: number): number | string

  • Parameters

    • entityUid: number

    Returns number | string

    String type for entities defined via add-ons or numeric type for all the other entities.

getVelocity

  • getVelocity(entityUid: number): Vector
  • Get current entity's velocity using velocity vector.


    Parameters

    • entityUid: number

    Returns Vector

    Containing current entity's velocity.

getXZPlayerDis

  • getXZPlayerDis(entityUid: number): number

  • Parameters

    • entityUid: number

    Returns number

    Distance between player and entity, counting only x and z values (y value is ignored).

hasEffect

  • hasEffect(entity: number, effectId: number): boolean
  • @since

    2.2.1b102


    Parameters

    • entity: number
    • effectId: number

      numeric ID of the potion effect, one of EPotionEffect values

    Returns boolean

    Whether the given entity is affected by the potion effect with given numeric ID.

healEntity

  • healEntity(entityUid: number, heal: number): void
  • Adds specified health amount to the entity.


    Parameters

    • entityUid: number
    • heal: number

      health to be added to entity, in half-hearts

    Returns void

health

isExist

  • isExist(entityUid: number): boolean

  • Parameters

    • entityUid: number

    Returns boolean

    true if specified entity is loaded within any player chunks (not despawned or unloaded) and identifier is valid.

lookAt

  • lookAt(entityUid: number, x: number, y: number, z: number): void
  • Sets entity look angle to look at specified coordinates.


    Parameters

    • entityUid: number
    • x: number
    • y: number
    • z: number

    Returns void

lookAtCoords

  • lookAtCoords(entityUid: number, coords: Vector): void
  • Same as Entity.lookAt but uses Vector as param type.


    Parameters

    • entityUid: number
    • coords: Vector

    Returns void

moveToAngle

  • Makes entity move using pitch/yaw angle to determine direction.


    Parameters

    • entityUid: number
    • angle: LookAngle

      angle to define entity's direction

    • params: MoveParams

      additional move parameters

    Returns void

moveToLook

  • moveToLook(entityUid: number, params: MoveParams): void
  • Makes entity move towards it's current look angle.


    Parameters

    • entityUid: number
    • params: MoveParams

      additional move parameters

    Returns void

moveToTarget

  • Makes entity move to the target coordinates.


    Parameters

    Returns void

putExtra

  • putExtra(entityUid: number, name: string, extra?: object): void
  • @deprecated

    Use attributes instead, or Saver.


    Parameters

    • entityUid: number
    • name: string
    • optionalextra: object

    Returns void

putExtraJson

  • putExtraJson(entityUid: number, name: string, obj: object): void
  • @deprecated

    Use attributes instead, or Saver.


    Parameters

    • entityUid: number
    • name: string
    • obj: object

    Returns void

remove

  • remove(entityUid: number): void
  • Removes entity from the world.


    Parameters

    • entityUid: number

    Returns void

rideAnimal

  • rideAnimal(entityUid: number, riderUid: number): void
  • Makes rider ride entity.


    Parameters

    • entityUid: number

      ridden entity

    • riderUid: number

      rider entity

    Returns void

setAge

  • setAge(entityUid: number, age: number): void
  • @deprecated

    Use attributes instead.


    Parameters

    • entityUid: number
    • age: number

    Returns void

setArmorSlot

  • setArmorSlot(entityUid: number, slot: number, id: number, count: number, data: number, extra?: ItemExtraData): void
  • Sets armor slot contents for the entity.


    Parameters

    • entityUid: number
    • slot: number

      armor slot index, should be one of the EArmorType values

    • id: number

      item ID

    • count: number

      item count

    • data: number

      item data

    • optionalextra: ItemExtraData

      item extra

    Returns void

setCarriedItem

  • setCarriedItem(entityUid: number, id: number, count: number, data: number, extra?: ItemExtraData): void
  • Sets current carried item for the entity.


    Parameters

    • entityUid: number
    • id: number

      item ID

    • count: number

      item count

    • data: number

      item data

    • optionalextra: ItemExtraData

      item extra

    Returns void

setCompoundTag

  • setCompoundTag(entityUid: number, tag: CompoundTag): void
  • Sets compound tag for the specified entity.

    @since

    2.0.5b44


    Parameters

    Returns void

setDroppedItem

  • setDroppedItem(entityUid: number, id: number, count: number, data: number, extra?: ItemExtraData): void
  • Sets item to the specified drop entity


    Parameters

    • entityUid: number
    • id: number

      item ID

    • count: number

      item count

    • data: number

      item data

    • optionalextra: ItemExtraData

      item extra

    Returns void

setFire

  • setFire(entityUid: number, fire: number, force: boolean): void
  • Puts entity on fire.


    Parameters

    • entityUid: number
    • fire: number

      duration (in ticks) of the fire

    • force: boolean

      should always be true

    Returns void

setHealth

  • setHealth(entityUid: number, health: number): void
  • Sets entity's current health value.


    Parameters

    • entityUid: number
    • health: number

      health value to be set

    Returns void

setHitbox

  • setHitbox(entityUid: number, w: number, h: number): void
  • Sets hitbox to the entity. Hitboxes defines entity collisions between terrain and themselves (e.g. physics).


    Parameters

    • entityUid: number
    • w: number

      hitbox width and length

    • h: number

      hitbox height

    Returns void

setLookAngle

  • setLookAngle(entityUid: number, yaw: number, pitch: number): void
  • Sets specified pitch and yaw as look angle for the entity.


    Parameters

    • entityUid: number
    • yaw: number

      look angle yaw in radians

    • pitch: number

      look angle pitch in radians

    Returns void

setMaxHealth

  • setMaxHealth(entityUid: number, health: number): void
  • Sets entity's maximum health value.


    Parameters

    • entityUid: number
    • health: number

    Returns void

setMobile

  • setMobile(entityUid: number, mobile: boolean): void
  • Sets entity's immobile state.


    Parameters

    • entityUid: number
    • mobile: boolean

      if true, entity can move, otherwise it is immobilized

    Returns void

setNameTag

  • setNameTag(entityUid: number, tag: string): void
  • Sets custom entity name tag. Custom entity tags are displayed above the entities and can be set by player using label.


    Parameters

    • entityUid: number
    • tag: string

      name tag to be set to the entity

    Returns void

setOffhandItem

  • setOffhandItem(entityUid: number, id: number, count: number, data: number, extra?: ItemExtraData): void
  • Sets current offhand item for the entity.

    @since

    2.2.1b93 (not working before)


    Parameters

    • entityUid: number
    • id: number

      item ID

    • count: number

      item count

    • data: number

      item data

    • optionalextra: ItemExtraData

      item extra

    Returns void

setPosition

  • setPosition(entityUid: number, x: number, y: number, z: number): void
  • Sets the specified coordinates as a new position for the entity. No checks are performed.


    Parameters

    • entityUid: number
    • x: number
    • y: number
    • z: number

    Returns void

setRender

  • setRender(entityUid: number, render: number): void
  • Sets entity render type.

    @deprecated

    Use resource packs instead.


    Parameters

    • entityUid: number
    • render: number

      entity render type, should be one of the EMobRenderType values

    Returns void

setSkin

  • setSkin(entityUid: number, skin: string): void
  • Sets mob skin.

    @deprecated

    Use NBT or resource packs instead.


    Parameters

    • entityUid: number
    • skin: string

      skin name, full path in the resourcepack (mod assets)

    Returns void

setSneaking

  • setSneaking(entityUid: number, sneak: boolean): void
  • Sets entity's sneaking state, supported slightly entities, resource pack render controlling it.


    Parameters

    • entityUid: number
    • sneak: boolean

      if true, entity becomes sneaking, else not

    Returns void

setTarget

  • setTarget(entityUid: number, targetUid: number): void
  • Sets the attack target for current entity. Works only for mobs that actually can attack.


    Parameters

    • entityUid: number
    • targetUid: number

      target entity's unique ID

    Returns void

setTexture

  • setTexture(entityUid: number, texture: Texture): void
  • Sets mob skin, uses Texture object.

    @deprecated

    Use NBT or resource packs instead.


    Parameters

    Returns void

setVelocity

  • setVelocity(entityUid: number, x: number, y: number, z: number): void
  • Set current entity's velocity using velocity vector.


    Parameters

    • entityUid: number
    • x: number
    • y: number
    • z: number

    Returns void

spawn

  • spawn(x: number, y: number, z: number, type: number, skin?: string): number
  • Spawns vanilla entity on the specified coordinates.

    @deprecated

    Client-side method, use BlockSource.spawnEntity instead.


    Parameters

    • x: number
    • y: number
    • z: number
    • type: number

      numeric entity type, one of the EEntityType

    • optionalskin: string

      skin to set for the entity. Leave empty or null to use default skin of the mob

    Returns number

    Numeric ID of spawn entity or -1 if entity was not created.

spawnAddon

spawnAddonAtCoords

spawnAtCoords

  • spawnAtCoords(coords: Vector, type: number, skin?: string): void

spawnCustom

  • spawnCustom(name: string, x: number, y: number, z: number, extra?: object): CustomEntity
  • Spawns custom entity on the specified coords. Allows to pass some values to controllers via extra param.

    @deprecated

    You are should implement addon entity and spawn it with BlockSource.spawnEntity instead.


    Parameters

    • name: string

      custom entity string ID

    • x: number
    • y: number
    • z: number
    • optionalextra: object

      object that contains some data for the controllers

    Returns CustomEntity

spawnCustomAtCoords