Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Entity

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

Index

Functions

addEffect

  • addEffect(ent: number, effectId: number, effectData: number, effectTime: number, ambiance?: boolean, particles?: boolean): void
  • Adds an effect to the mob

    Parameters

    • ent: number
    • effectId: number

      effect id, should be one of the Native.PotionEffect values

    • effectData: number

      effect amplifier

    • effectTime: number

      effect time in ticks

    • Optional ambiance: boolean
    • Optional particles: boolean

      if true, particles are not displayed

    Returns void

addPosition

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

    Parameters

    • ent: number
    • x: number
    • y: number
    • z: number

    Returns void

addVelocity

  • addVelocity(ent: number, x: number, y: number, z: number): void
  • Updates current entity's velocity by specified valus

    Parameters

    • ent: number
    • x: number
    • y: number
    • z: number

    Returns void

clearEffect

  • clearEffect(ent: number, id: number): void

clearEffects

  • clearEffects(ent: number): void

damageEntity

  • damageEntity(ent: number, damage: number, cause?: number, params?: { attacker?: number; bool1?: boolean; bool2?: boolean }): void
  • Damages entity

    Parameters

    • ent: number
    • damage: number

      damage value

    • Optional cause: number

      if specified, can be used as callback cause param

    • Optional params: { attacker?: number; bool1?: boolean; bool2?: boolean }

      additional params for the damage

      • Optional attacker?: number

        entity that caused damage, can be used as callback cause param

      • Optional bool1?: boolean

        unknown param

      • Optional bool2?: boolean

        unknown param

    Returns void

findNearest

  • findNearest(coords: Vector, type?: number, maxRange?: number): number | null
  • Retreives nearest to the coordinates entity of the specified entity type

    Parameters

    • coords: Vector

      search range center coordinates

    • Optional type: number

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

    • Optional maxRange: number

      if specified, determines search radius

    Returns number | null

getAge

  • getAge(ent: number): number

getAll

  • getAll(): number[]

getAllInRange

  • getAllInRange(coords: any, maxRange: any, type?: any): void
  • Parameters

    • coords: any

      search range center coordinates

    • maxRange: any

      determines search radius

    • Optional type: any

      entity type ID. Parameter is no longer supported and should not be used

    Returns void

getAllJS

  • getAllJS(): number[]

getArmorSlot

getCarriedItem

  • getCarriedItem(ent: number, bool1?: boolean, bool2?: boolean): ItemInstance
  • Parameters

    • ent: number
    • Optional bool1: boolean

      parameter is no longer supported and should not be used

    • Optional bool2: boolean

      parameter is no longer supported and should not be used

    Returns ItemInstance

    entity's current carried item information

getCustom

getDistanceBetweenCoords

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

getDistanceToCoords

  • getDistanceToCoords(ent: number, coords: any): void
  • Parameters

    • ent: number
    • coords: any

    Returns void

    distance between specified entity and a fixed coordinate set

getDistanceToEntity

  • getDistanceToEntity(ent1: any, ent2: any): void
  • Parameters

    • ent1: any
    • ent2: any

    Returns void

    distance in blocks between two entities

getDroppedItem

getExtra

  • getExtra(ent: number, name: string): null
  • deprecated

    No longer supported

    Parameters

    • ent: number
    • name: string

    Returns null

getExtraJson

  • getExtraJson(ent: number, name: string): object
  • deprecated

    No longer supported

    Parameters

    • ent: number
    • name: string

    Returns object

getHealth

  • getHealth(ent: number): number

getInventory

  • getInventory(ent: number, handleNames: any, handleEnchant: any): void
  • deprecated

    No longer supported

    Parameters

    • ent: number
    • handleNames: any
    • handleEnchant: any

    Returns void

getLookAngle

getLookAt

  • getLookAt(ent: number, x: number, y: number, z: number): LookAngle
  • Parameters

    • ent: number
    • x: number
    • y: number
    • z: number

    Returns LookAngle

    look angle between entity and static coordinates

getLookVector

  • getLookVector(ent: number): Vector

getLookVectorByAngle

getMaxHealth

  • getMaxHealth(ent: number): number

getMobile

  • getMobile(ent: number): boolean
  • Parameters

    • ent: 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

    • ent: number

    Returns LookAngle

getMovingAngleByPositions

  • getMovingAngleByPositions(pos1: any, pos2: any): void
  • deprecated

    No longer supported

    Parameters

    • pos1: any
    • pos2: any

    Returns void

getMovingVector

  • Retrieves entity's current movement information

    Parameters

    • ent: number

    Returns MovingVector

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

getNameTag

  • getNameTag(ent: number): string

getPosition

  • getPosition(ent: number): Vector

getProjectileItem

getRender

  • getRender(ent: number): number

getRider

  • getRider(ent: number): number
  • Parameters

    • ent: number

    Returns number

    entity that is riding the specified entity

getRiding

  • getRiding(ent: number): void
  • Parameters

    • ent: number

    Returns void

    entity that is ridden by specified entity

getSkin

  • getSkin(ent: number): string

getSneaking

  • getSneaking(ent: number): boolean
  • Parameters

    • ent: number

    Returns boolean

    true if entity is sneaking, false otherwise

getTarget

  • getTarget(ent: number): void

getType

  • getType(ent: number): number

getVelocity

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

    Parameters

    • ent: number

    Returns Vector

    Vector containing current entity's velocity

getXZPlayerDis

  • getXZPlayerDis(ent: number): void
  • Parameters

    • ent: number

    Returns void

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

healEntity

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

    Parameters

    • ent: number
    • heal: number

      health to be added to entity, in half-hearts

    Returns void

health

isExist

  • isExist(ent: number): boolean
  • Parameters

    • ent: number

    Returns boolean

    true if specified entity id is valid and entity with this id exists in the world

lookAt

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

    Parameters

    • ent: number
    • x: number
    • y: number
    • z: number

    Returns void

lookAtCoords

  • lookAtCoords(ent: number, coords: Vector): void

moveToAngle

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

    Parameters

    • ent: number
    • angle: LookAngle

      angle to define entity's direction

    • params: MoveParams

      additional move parameters

    Returns void

moveToLook

  • moveToLook(ent: number, params: MoveParams): void
  • Makes entity move towords its current look angle

    Parameters

    • ent: number
    • params: MoveParams

      additional move parameters

    Returns void

moveToTarget

putExtra

  • putExtra(ent: number, name: string, extra?: ItemExtra): void

putExtraJson

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

    No longer supported

    Parameters

    • ent: number
    • name: string
    • obj: object

    Returns void

remove

  • remove(ent: number): void

rideAnimal

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

    Parameters

    • entity: number

      ridden entity

    • rider: number

      rider entity

    Returns void

setAge

  • setAge(ent: number, age: any): void
  • deprecated

    No longer supported

    Parameters

    • ent: number
    • age: any

    Returns void

setArmorSlot

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

    Parameters

    • ent: number
    • slot: number

      armor slot id, should be one of the Native.ArmorType values

    • id: number

      item id

    • count: number

      item count

    • data: number

      item data

    • Optional extra: ItemExtra

      item extra

    Returns void

setCarriedItem

  • setCarriedItem(ent: number, id: number, count: number, data: number, extra?: ItemExtra): void
  • Sets currena carried item for the entity

    Parameters

    • ent: number
    • id: number

      item id

    • count: number

      item count

    • data: number

      item data

    • Optional extra: ItemExtra

      item extra

    Returns void

setDroppedItem

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

    Parameters

    • ent: number
    • id: number

      item id

    • count: number

      item count

    • data: number

      item data

    • Optional extra: ItemExtra

      item extra

    Returns void

setFire

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

    Parameters

    • ent: number
    • fire: number

      duration (in ticks) of the fire

    • force: boolean

      should always be true

    Returns void

setHealth

  • setHealth(ent: number, health: any): void
  • Sets entity's current health value

    Parameters

    • ent: number
    • health: any

      health value to be set

    Returns void

setHitbox

  • setHitbox(ent: number, w: number, h: number): void
  • Sets hitbox to the entity. Hitboxes define entities collisions

    Parameters

    • ent: number
    • w: number

      hitbox width and length

    • h: number

      hitbox height

    Returns void

setLookAngle

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

    Parameters

    • ent: number
    • yaw: any

      look angle yaw in radians

    • pitch: any

      look angle pitch in radians

    Returns void

setMaxHealth

  • setMaxHealth(ent: number, health: any): void
  • Sets entity's maximum health value

    Parameters

    • ent: number
    • health: any

    Returns void

setMobile

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

    Parameters

    • ent: number
    • mobile: boolean

      if true, entity is immobilized, otherwise it can move

    Returns void

setNameTag

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

    Parameters

    • ent: number
    • tag: string

      name tag to be set to the entity

    Returns void

setPosition

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

    Parameters

    • ent: number
    • x: number
    • y: number
    • z: number

    Returns void

setRender

  • setRender(ent: number, render: number): void

setSkin

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

    Parameters

    • ent: number
    • skin: string

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

    Returns void

setSneaking

  • setSneaking(ent: number, sneak: any): void
  • Sets entity's sneaking state

    Parameters

    • ent: number
    • sneak: any

      if true, entity becomes sneaking, else not

    Returns void

setTarget

  • setTarget(ent: number, target: any): void
  • deprecated

    No longer supported

    Parameters

    • ent: number
    • target: any

    Returns void

setTexture

  • setTexture(ent: number, texture: Texture): void

setVelocity

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

    Parameters

    • ent: number
    • x: number

      velocity

    • y: number

      velocity

    • z: number

      velocity

    Returns void

spawn

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

    Parameters

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

      numeric entity type, one of the Native.EntityType

    • Optional skin: string | null

      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

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

    Parameters

    • name: string

      custom entity string id

    • x: number
    • y: number
    • z: number
    • Optional extra: object

      object that contains some data for the controllers

    Returns CustomEntity

spawnCustomAtCoords

Generated using TypeDoc