Entity
Index
Classes
Interfaces
Type Aliases
Functions
- addEffect
- addPosition
- addVelocity
- clearEffect
- clearEffects
- damageEntity
- findNearest
- getAddonEntity
- getAge
- getAll
- getAllInRange
- getAllInsideBox
- getAllJS
- getAllLocal
- getArmorSlot
- getAttribute
- getCarriedItem
- getCompoundTag
- getCustom
- getDimension
- getDistanceBetweenCoords
- getDistanceToCoords
- getDistanceToEntity
- getDroppedItem
- getEffect
- getExtra
- getExtraJson
- getHealth
- getInventory
- getLookAngle
- getLookAt
- getLookVector
- getLookVectorByAngle
- getMaxHealth
- getMobile
- getMovingAngle
- getMovingAngleByPositions
- getMovingVector
- getNameTag
- getOffhandItem
- getPathNavigation
- getPosition
- getProjectileItem
- getRender
- getRider
- getRiding
- getSkin
- getSneaking
- getTarget
- getType
- getTypeAddon
- getTypeName
- getTypeUniversal
- getVelocity
- getXZPlayerDis
- hasEffect
- healEntity
- health
- isExist
- lookAt
- lookAtCoords
- moveToAngle
- moveToLook
- moveToTarget
- putExtra
- putExtraJson
- remove
- rideAnimal
- setAge
- setArmorSlot
- setCarriedItem
- setCompoundTag
- setDroppedItem
- setFire
- setHealth
- setHitbox
- setLookAngle
- setMaxHealth
- setMobile
- setNameTag
- setOffhandItem
- setPosition
- setRender
- setSkin
- setSneaking
- setTarget
- setTexture
- setVelocity
- spawn
- spawnAddon
- spawnAddonAtCoords
- spawnAtCoords
- spawnCustom
- spawnCustomAtCoords
Classes
EntityHealth
Class used to manipulate entity's health.
constructor
Returns EntityHealth
get
Returns number
Entity's current health value.
getMax
Returns number
Entity's maximum health value.
set
Sets entity's current health value.
Parameters
health: number
health value to be set
Returns void
setMax
Sets entity's maximum health value.
Parameters
maxHealth: number
Returns void
Interfaces
AttributeInstance
Interface used to modify attribute values.
getDefaultValue
Returns number
Attribute's default value
getMaxValue
Returns number
Attribute's maximum value.
getMinValue
Returns number
Attribute's minimum value.
getValue
Returns number
Current attribute's value.
setDefaultValue
Sets attribute's default value.
Parameters
value: number
Returns void
setMaxValue
Sets attribute's maximum value.
Parameters
value: number
Returns void
setMinValue
Sets attribute's minimum value.
Parameters
value: number
Returns void
setValue
Sets current attribute's value.
Parameters
value: number
Returns void
EffectInstance
duration
level
MoveParams
Interface used to specify how entity should move.
optionaldenyY
If true
, entity won't change it's Y velocity.
optionaljumpVel
Y velocity (jump speed).
optionalspeed
Movement speed.
MovingVector
Interface used to return entity's current moving vector and some additional data.
size
Vector real length.
x
Normalized vector X coordinate.
xzsize
Vector real length excluding Y coordinate.
y
Normalized vector Y coordinate.
z
Normalized vector Z coordinate.
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.
canOpenDoors
Returns boolean
Whether the entity can open doors.
canPassDoors
Returns boolean
Whether the entity can pass doors.
getAvoidDamageBlocks
Returns boolean
getAvoidPortals
Returns boolean
getAvoidSun
Returns boolean
getAvoidWater
Returns boolean
Whether the entity avoids water.
getCanBreach
Returns boolean
getCanFloat
Returns boolean
getCanJump
Returns boolean
Whether entity can jump.
getCanOpenIronDoors
Returns boolean
getCanPathOverLava
Returns boolean
getCanSink
Returns boolean
getCanWalkInLava
Returns boolean
getHasEndPathRadius
Returns boolean
getSpeed
Returns number
Entity's speed value.
getTerminationThreshold
Returns number
getTickTimeout
Returns number
isAmphibious
Returns boolean
isRiverFollowing
Returns boolean
isStuck
Parameters
ticks: number
Returns boolean
moveToCoords
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
Parameters
avoid: boolean
Returns PathNavigation
setAvoidPortals
Parameters
avoid: boolean
Returns PathNavigation
setAvoidSun
Sets entity's sun avoiding.
Parameters
avoid: boolean
Returns PathNavigation
setAvoidWater
Sets entity's water avoiding.
Parameters
avoid: boolean
Returns PathNavigation
setCanBreach
Parameters
can: boolean
Returns PathNavigation
setCanFloat
Parameters
can: boolean
Returns PathNavigation
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
Parameters
can: boolean
Returns PathNavigation
setCanPassDoors
Sets entity's door passing ability.
Parameters
can: boolean
Returns PathNavigation
setCanPathOverLava
Parameters
can: boolean
Returns PathNavigation
setCanSink
Parameters
can: boolean
Returns PathNavigation
setCanWalkInLava
Parameters
can: boolean
Returns PathNavigation
setEndPathRadius
Parameters
radius: number
Returns PathNavigation
setHasEndPathRadius
Parameters
has: boolean
Returns PathNavigation
setIsAmphibious
Parameters
amphibious: boolean
Returns PathNavigation
setIsRiverFollowing
Parameters
follow: boolean
Returns PathNavigation
setResultFunction
Sets function to be notified when path navigation is finished or aborted.
Parameters
callback: PathNavigationResultFunction
function to be called when navigation is finished or aborted
Returns PathNavigation
setSpeed
Sets entity's speed value.
Parameters
speed: number
Returns PathNavigation
setTickTimeout
Parameters
ticks: number
Returns PathNavigation
PathNavigationResultFunction
Parameters
navigation: PathNavigation
result: PathNavigationResultCode
Returns void
Type Aliases
Attribute
DamageSource
Damage sources, which are used to determine entity damage type:
Type | Name | Message | Translation |
---|---|---|---|
0 | Generic | "death.attack.generic" (fallback damage source) | * died |
1 | Cactus | "death.attack.cactus" (only when standing on cactus) | * was pricked to death |
2 | Mob | "death.attack.mob" | * was slain by * |
3 | Impact | n/a | |
4 | In Wall | "death.attack.inWall" | * suffocated in a wall |
5 | Fall | "death.attack.fall" OR "death.fell.accident.generic" | * hit the ground too hard OR * fell from a high place |
6 | In Fire | "death.attack.inFire" | * went up in flames |
7 | On Fire | "death.attack.onFire" | * burned to death |
8 | Lava | "death.attack.lava" | * tried to swim in lava |
9 | Drown | "death.attack.drown" | * drowned |
10 | Explosion | "death.attack.explosion" | * blew up |
11 | Explosion (Player) | "death.attack.explosion" | * was blown up by * |
12 | Out Of World | "death.attack.outOfWorld" | * fell out of the world |
13 | Command | n/a | |
14 | Magic | "death.attack.magic" | * was killed by magic |
15 | Wither | "death.attack.wither" | * withered away |
16 | Starve | "death.attack.starve" | * starved to death |
17 | Anvil | "death.attack.anvil" | * was squashed by a falling anvil |
18 | Thorns | "death.attack.thorns" | * was killed trying to hurt * |
19 | Projectile | n/a | |
20 | Falling Block | "death.attack.fallingBlock" | * was squashed by a falling block |
21 | Fly Into Wall | "death.attack.flyIntoWall" | * experienced kinetic energy |
22 | Magma | "death.attack.magma" | * discovered floor was lava |
23 | Fireworks | "death.attack.fireworks" | * went off with a bang |
24 | Lightning Bolt | "death.attack.lightningBolt" | * was struck by lightning |
PathNavigationResultCode
Path navigation result, which is used in result callback:
Result code | Meaning |
---|---|
0 | Path successfully completed |
1 | Cannot reach target, no available path |
2 | Cannot reach target, out of range |
3 | Entity has been unloaded or removed |
4 | Cancelled by stop() or similar method |
5 | Player left level or server closed |
6 | Result function will be replaced |
Functions
addEffect
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
Updates current entity position by specified coordinates.
Parameters
entityUid: number
x: number
y: number
z: number
Returns void
addVelocity
Updates current entity's velocity by specified value.
Parameters
entityUid: number
x: number
y: number
z: number
Returns void
clearEffect
Clears effect, applied to the mob.
Parameters
entityUid: number
id: number
effect ID, should be one of the EPotionEffect
Returns void
clearEffects
Clears all effects of the mob.
Parameters
entityUid: number
Returns void
damageEntity
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
Retrieves nearest to the coordinates entity of the specified entity type.
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
Parameters
entity: number
Returns Nullable<AddonEntityRegistry.AddonEntity>
Instance to performing commands on requested addon entity if it spawned by Inner Core or
null
instead.
getAge
Parameters
entityUid: number
Returns number
getAll
Returns number[]
An array of all server entities UIDs.
getAllInRange
Returns array of all entities numeric IDs in given range in blocks.
Parameters
coords: Vector
search range center coordinates
maxRange: number
determines search radius
optionaltype: number
entity type ID
Returns number[]
getAllInsideBox
getAllJS
Returns number[]
An array of all server entities UIDs.
getAllLocal
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.
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
Parameters
entityUid: number
Returns Nullable<NBT.CompoundTag>
Compound tag for the specified entity.
getCustom
Parameters
entityUid: number
Returns CustomEntity
Custom entity object by it's numeric entity UID.
getDimension
Parameters
entityUid: number
Returns number
Current dimension numeric ID, one of the EDimension values or custom dimension ID.
getDistanceBetweenCoords
getDistanceToCoords
Parameters
entityUid: number
coords: Vector
Returns number
Distance between specified entity and a fixed coordinate set.
getDistanceToEntity
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
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
Parameters
entityUid: number
name: string
Returns null
getExtraJson
Parameters
entityUid: number
name: string
Returns object
getHealth
Parameters
entityUid: number
Returns number
Entity's current health value.
getInventory
Parameters
entityUid: number
optionalhandleNames: boolean
optionalhandleEnchant: boolean
Returns void
getLookAngle
Parameters
entityUid: number
Returns LookAngle
Entity's look angle in radians.
getLookAt
Parameters
entityUid: number
x: number
y: number
z: number
Returns LookAngle
Look angle between entity and static coordinates.
getLookVector
Parameters
entityUid: number
Returns Vector
Look vector for the entity.
getLookVectorByAngle
getMaxHealth
Parameters
entityUid: number
Returns number
Entity's maximum health value.
getMobile
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
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
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
Parameters
entityUid: number
Returns PathNavigation
Navigation used to control entity's target position and the way to get there.
getPosition
Parameters
entityUid: number
Returns Vector
Entity position.
getProjectileItem
Parameters
projectile: number
Returns ItemInstance
getRender
Parameters
entityUid: number
Returns number
Entity render type, should be one of the EMobRenderType values.
getRider
Parameters
entityUid: number
Returns number
Entity that is riding the specified entity.
getRiding
Parameters
entityUid: number
Returns number
Entity that is ridden by specified entity.
getSkin
Parameters
entityUid: number
Returns string
getSneaking
Parameters
entityUid: number
Returns boolean
true
if entity is sneaking,false
otherwise.
getTarget
Gets the attack target of current entity.
Parameters
entityUid: number
Returns number
Target entity's unique ID.
getType
Parameters
entityUid: number
Returns number
Numeric entity type, one of the EEntityType.
getTypeAddon
Parameters
entityUid: number
Returns Nullable<string>
String type for entities defined via add-ons, otherwise
null
.
getTypeName
Parameters
entityUid: number
Returns string
String entity type, like
minecraft:chicken<>
(<namespace>:<identifier>[<attributes>]
).
getTypeUniversal
Parameters
entityUid: number
Returns number | string
String type for entities defined via add-ons or numeric type for all the other entities.
getVelocity
Get current entity's velocity using velocity vector.
Parameters
entityUid: number
Returns Vector
Containing current entity's velocity.
getXZPlayerDis
Parameters
entityUid: number
Returns number
Distance between player and entity, counting only x and z values (y value is ignored).
hasEffect
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
Adds specified health amount to the entity.
Parameters
entityUid: number
heal: number
health to be added to entity, in half-hearts
Returns void
health
Parameters
entityUid: number
Returns EntityHealth
An object that allows to manipulate entity health.
isExist
Parameters
entityUid: number
Returns boolean
true
if specified entity is loaded within any player chunks (not despawned or unloaded) and identifier is valid.
lookAt
Sets entity look angle to look at specified coordinates.
Parameters
entityUid: number
x: number
y: number
z: number
Returns void
lookAtCoords
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
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
entityUid: number
target: Vector
params: MoveParams
additional move parameters
Returns void
putExtra
Parameters
entityUid: number
name: string
optionalextra: object
Returns void
putExtraJson
Parameters
entityUid: number
name: string
obj: object
Returns void
remove
Removes entity from the world.
Parameters
entityUid: number
Returns void
rideAnimal
Makes rider ride entity.
Parameters
entityUid: number
ridden entity
riderUid: number
rider entity
Returns void
setAge
Parameters
entityUid: number
age: number
Returns void
setArmorSlot
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
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
Sets compound tag for the specified entity.
Parameters
entityUid: number
tag: CompoundTag
Returns void
setDroppedItem
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
Puts entity on fire.
Parameters
entityUid: number
fire: number
duration (in ticks) of the fire
force: boolean
should always be true
Returns void
setHealth
Sets entity's current health value.
Parameters
entityUid: number
health: number
health value to be set
Returns void
setHitbox
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
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
Sets entity's maximum health value.
Parameters
entityUid: number
health: number
Returns void
setMobile
Sets entity's immobile state.
Parameters
entityUid: number
mobile: boolean
if
true
, entity can move, otherwise it is immobilized
Returns void
setNameTag
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
Sets current offhand 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
setPosition
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
Sets entity render type.
Parameters
entityUid: number
render: number
entity render type, should be one of the EMobRenderType values
Returns void
setSkin
Sets mob skin.
Parameters
entityUid: number
skin: string
skin name, full path in the resourcepack (mod assets)
Returns void
setSneaking
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
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
setVelocity
Set current entity's velocity using velocity vector.
Parameters
entityUid: number
x: number
y: number
z: number
Returns void
spawn
Spawns vanilla entity on the specified coordinates.
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
Spawns custom entity defined in behavior packs or game itself.
Parameters
x: number
y: number
z: number
name: string
Returns AddonEntityRegistry.AddonEntity
Instance to performing commands on entity.
spawnAddonAtCoords
Same as Entity.spawnAddon, but uses Vector object to represent coordinates.
Parameters
coords: Vector
name: string
Returns AddonEntityRegistry.AddonEntity
Instance to performing commands on entity.
spawnAtCoords
Same as Entity.spawn, but uses Vector object to represent coordinates.
Parameters
coords: Vector
type: number
optionalskin: string
Returns void
spawnCustom
Spawns custom entity on the specified coords. Allows to pass some values to controllers via extra param.
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
Same as Entity.spawnCustom, but uses Vector object to represent coordinates.
Parameters
name: string
coords: Vector
optionalextra: any
Returns CustomEntity
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.