Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Player

Module used to manipulate player. Player is also an entity in Minecraft, so you can use all the functions from Entity module as well. To get player's entity id, call Player.get function

Index

Functions

addExperience

  • addExperience(exp: number): void
  • Adds specified amount of experience to the current value

    Parameters

    • exp: number

      amount to be added

    Returns void

addItemToInventory

  • addItemToInventory(id: number, count: number, data: number, extra?: ItemExtra, preventDrop?: boolean): void
  • Adds items to player's inventory, stacking them if possible

    Parameters

    • id: number

      item id

    • count: number

      item count

    • data: number

      item data

    • Optional extra: ItemExtra

      item extra

    • Optional preventDrop: boolean

    Returns void

addLevel

  • addLevel(level: number): void
  • Adds specified amount of level to the current value

    Parameters

    • level: number

      amount to be added

    Returns void

addPosition

  • addPosition(x: number, y: number, z: number): void
  • Changes current player position by specified vector

    Parameters

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

    Returns void

addVelocity

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

    Parameters

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

    Returns void

decreaseCarriedItem

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

    Parameters

    • Optional count: number

      amount of items to decrease carried item by, default value is 1

    Returns void

exhaustion

experience

flying

get

  • get(): number

getArmorSlot

getCarriedItem

  • getCarriedItem(handleEnchant: boolean, handleNames: boolean): ItemInstance
  • Parameters

    • handleEnchant: boolean

      No longer supported and should not be passed

    • handleNames: boolean

      No longer supported and should not be passed

    Returns ItemInstance

    item in player's hand

getDimension

  • getDimension(): number

getExhaustion

  • getExhaustion(): number

getExperience

  • getExperience(): number

getFlying

  • getFlying(): boolean

getFlyingEnabled

  • getFlyingEnabled(): boolean

getHealth

  • getHealth(): number

getHunger

  • getHunger(): void

getInventory

  • getInventory(loadPart: any, handleEnchant: any, handleNames: any): void
  • deprecated

    No longer supported

    Parameters

    • loadPart: any
    • handleEnchant: any
    • handleNames: any

    Returns void

getInventorySlot

getLevel

  • getLevel(): void

getName

  • getName(): void

getNameForEnt

  • getNameForEnt(ent: number): string

getPointed

  • Fetches information about the objects player is currently pointing

    Returns { block: Tile; entity: number; pos: BlockPosition; vec: Vector }

    • block: Tile

      pointed block data, if player doesn't look at the block, air block is returned ({id: 0, data: 0})

    • entity: number

      pointed entity, if no entity's pointed, returns -1

    • pos: BlockPosition

      pointed block position

    • vec: Vector

      look vector

getPosition

getSaturation

  • getSaturation(): number

getScore

  • getScore(): number

getSelectedSlotId

  • getSelectedSlotId(): void

getVelocity

  • getVelocity(): void

health

hunger

isPlayer

  • isPlayer(ent: number): boolean
  • Parameters

    • ent: number

    Returns boolean

    true if specified entity is of player type, false otherwise

level

resetCameraEntity

  • resetCameraEntity(): void
  • Resets player's camera if it was previously set to another entity

    Returns void

resetFov

  • resetFov(): void

saturation

score

setArmorSlot

  • setArmorSlot(slot: number, id: number, count: number, data: number, extra?: ItemExtra): void
  • Sets contents of the specified armor slot

    Parameters

    • 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

setCameraEntity

  • setCameraEntity(ent: number): void
  • Sets player's camera to the specified entity

    Parameters

    • ent: number

      entity id

    Returns void

setCarriedItem

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

    Parameters

    • id: number

      item id

    • count: number

      item count

    • data: number

      item data

    • Optional extra: ItemExtra

      item extra

    Returns void

setExhaustion

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

    Parameters

    • value: number

      exhaustion value to be set

    Returns void

setExperience

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

    Parameters

    • exp: number

      experience value to be set

    Returns void

setFlying

  • setFlying(enabled: boolean): void
  • Changes player's current flying state, call Player.setFlyingEnabled to be able to set this property to true

    Parameters

    • enabled: boolean

      whether the player should fly or not

    Returns void

setFlyingEnabled

  • setFlyingEnabled(enabled: boolean): void
  • Enables or disables player's ability to fly

    Parameters

    • enabled: boolean

      whether the player can fly or not

    Returns void

setFov

  • setFov(fov: number): void

setHealth

  • setHealth(value: number): void
  • Sets player's health

    Parameters

    • value: number

      health value to be set

    Returns void

setHunger

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

    Parameters

    • value: number

      hunger value to be set

    Returns void

setInventorySlot

  • setInventorySlot(slot: number, id: number, count: number, data: number, extra?: ItemExtra): void
  • Sets contents of the specified inventory slot

    Parameters

    • slot: number

      slot id, from 0 to 36

    • id: number

      item id

    • count: number

      item count

    • data: number

      item data

    • Optional extra: ItemExtra

      item extra

    Returns void

setLevel

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

    Parameters

    • level: number

      level value to be set

    Returns void

setPosition

  • setPosition(x: number, y: number, z: number): void
  • Sets specified coordinates as player's position

    Parameters

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

    Returns void

setSaturation

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

    Parameters

    • value: number

      saturation value to be set

    Returns void

setSelectedSlotId

  • setSelectedSlotId(slot: number): void
  • Selects currently selected inventory slot

    Parameters

    • slot: number

      slot id to be selected, from 0 to 8

    Returns void

setVelocity

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

    Parameters

    • x: number

      velocity

    • y: number

      velocity

    • z: number

      velocity

    Returns void

Generated using TypeDoc