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

PlayerEntity

Class to manipulate player based on PlayerActor. Due to limitations of underlying PlayerActor class this class can be used only during 1 server tick!

Index

Constructors

constructor

  • Creates new instance of PlayerEntity.


    Parameters

    • playerUid: number

      player's numeric entity id

    Returns PlayerEntity

Properties

readonlyactor

actor: PlayerActor

privatereadonlyplayerUid

playerUid: any

Methods

addExperience

  • addExperience(amount: number): void
  • Add experience to player.


    Parameters

    • amount: number

    Returns void

addItemToInventory

  • addItemToInventory(item: ItemInstance): void
  • addItemToInventory(id: number, count: number, data: number, extra?: ItemExtraData): void
  • Adds item to player's inventory. Drops surplus items near player.


    Parameters

    • item: ItemInstance

    Returns void

decreaseCarriedItem

  • decreaseCarriedItem(amount?: number): void
  • Decreases carried item count by specified number.


    Parameters

    • optionalamount: number

      amount of items to decrease, default is 1

    Returns void

getArmor

  • getArmor(slot: number): ItemInstance

  • Parameters

    • slot: number

    Returns ItemInstance

    armor slot's contents.

getCarriedItem

getDimension

  • getDimension(): number

  • Returns number

    the id of dimension where player is.

getExhaustion

  • getExhaustion(): number

  • Returns number

    player's exhaustion.

getExperience

  • getExperience(): number

  • Returns number

    player's experience.

getGameMode

  • getGameMode(): number

  • Returns number

    player's gamemode.

getHunger

  • getHunger(): number

  • Returns number

    player's hunger.

getInventorySlot


  • Parameters

    • slot: number

    Returns ItemStack

    inventory slot's contents.

getItemUseDuration

  • getItemUseDuration(): number
  • Returns number

getItemUseIntervalProgress

  • getItemUseIntervalProgress(): number
  • Returns number

getItemUseStartupProgress

  • getItemUseStartupProgress(): number
  • Returns number

getLevel

  • getLevel(): number

  • Returns number

    player's xp level.

getSaturation

  • getSaturation(): number

  • Returns number

    player's saturation.

getScore

  • getScore(): number

  • Returns number

    player's score.

getSelectedSlot

  • getSelectedSlot(): number

  • Returns number

    player's selected slot.

getUid

  • getUid(): number

  • Returns number

    player's unique numeric entity id.

isValid

  • isValid(): boolean

  • Returns boolean

    whether the player is a valid entity.

setArmor

  • setArmor(slot: number, item: ItemInstance): void
  • setArmor(slot: number, id: number, count: number, data: number, extra?: ItemExtraData): void
  • Sets armor slot's contents.


    Parameters

    • slot: number
    • item: ItemInstance

    Returns void

setCarriedItem

  • setCarriedItem(item: ItemInstance): void
  • setCarriedItem(id: number, count: number, data: number, extra?: ItemExtraData): void
  • Sets item in player's hand.


    Parameters

    • item: ItemInstance

    Returns void

setExhaustion

  • setExhaustion(value: number): void
  • Sets player's exhaustion.


    Parameters

    • value: number

    Returns void

setExperience

  • setExperience(value: number): void
  • Sets player's experience.


    Parameters

    • value: number

    Returns void

setHunger

  • setHunger(value: number): void
  • Sets player's hunger.


    Parameters

    • value: number

    Returns void

setInventorySlot

  • setInventorySlot(slot: number, item: ItemInstance): void
  • setInventorySlot(slot: number, id: number, count: number, data: number, extra?: ItemExtraData): void
  • Sets inventory slot's contents.


    Parameters

    • slot: number
    • item: ItemInstance

    Returns void

setLevel

  • setLevel(level: number): void
  • Sets player's xp level.


    Parameters

    • level: number

    Returns void

setRespawnCoords

  • setRespawnCoords(x: number, y: number, z: number): void
  • Sets respawn coords for the player.


    Parameters

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

    Returns void

setSaturation

  • setSaturation(value: number): void
  • Sets player's saturation.


    Parameters

    • value: number

    Returns void

setScore

  • setScore(value: number): void
  • Sets player's score.


    Parameters

    • value: number

    Returns void

setSelectedSlot

  • setSelectedSlot(slot: number): void
  • Sets player's selected slot.


    Parameters

    • slot: number

    Returns void

spawnExpOrbs

  • spawnExpOrbs(x: number, y: number, z: number, value: number): void
  • Spawns exp on coords.


    Parameters

    • x: number
    • y: number
    • z: number
    • value: number

      experience points value

    Returns void