Namespace Player

Module used to manipulate local 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 uid, call Player.getLocal or Player.getServer depends on usage. Most of the methods are client-side, use PlayerActor instead.

Functions

  • Adds specified amount of experience to the current value.

    Parameters

    • exp: number

      amount to be added

    Returns void

    Client-side only, use PlayerActor.addExperience instead.

  • Adds items to player's inventory, stacking them if possible.

    Parameters

    • id: number

      item ID

    • count: number

      item count

    • data: number

      item data

    • Optionalextra: ItemExtraData

      item extra

    • OptionalpreventDrop: boolean

      if set to false, function drops items that could not be added to player's inventory, destroys them otherwise

    Returns void

    Client-side only, use PlayerActor.addItemToInventory instead.

  • Adds specified amount of level to the current value.

    Parameters

    • level: number

      amount to be added

    Returns void

    Client-side only, use PlayerActor.setLevel instead.

  • Changes current player position by specified vector.

    Parameters

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

    Returns void

    Client-side only, use Entity.addPosition instead.

  • Updates current entity's velocity by specified values.

    Parameters

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

    Returns void

    Client-side only, use Entity.addVelocity instead.

  • Gets server player uid or local one if client connected to remote server and client uid is available.

    Returns number

    -1 if there is no player, for example, on dedicated servers

  • Gets one of the player's abilities in a boolean form.

    Parameters

    • ability: string

      ability name constant, should be one of the EPlayerAbility constants

    Returns number

    Current value of the ability in a boolean form.

    2.0.3b33

  • Returns number

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

  • Returns number

    Player's current exhaustion.

  • Returns number

    Player's current experience.

  • Gets one of the player's abilities in a form of floating-point number.

    Parameters

    • ability: string

      ability name constant, should be one of the EPlayerAbility constants

    Returns number

    Current value of the ability in a form of floating-point number.

    2.0.3b33

  • Returns boolean

    true if player is flying, false otherwise.

  • Returns boolean

    true if player is allowed to fly, false otherwise.

  • Returns number

    Player's current health.

  • Returns number

    Player's current hunger.

  • Parameters

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

    Returns void

    Consider use Player.getInventorySlot instead.

  • Returns number

    Player's current level.

  • Gets local player entity uid, which can be used in various client operations with player, like Player.getPointed.

    Returns number

    -1 if there is no player, for example, on dedicated servers

    2.3.1b115

  • Returns number

    Player's current saturation.

  • Returns number

    Player's current score.

  • Returns number

    Currently selected inventory slot, from 0 to 8.

  • Gets player entity uid, which can be used in various server operations with player, like Player.addItemToInventory.

    Returns number

    -1 if there is no player, for example, on dedicated servers

    2.3.1b115

  • Parameters

    • entityUid: number

    Returns boolean

    true if specified entity is of player type, false otherwise.

    Works only with local player, use Entity.getType instead.

  • Simulates local player rotation by specified delta.

    Parameters

    • deltaX: number

      horizontal radians offset

    • deltaY: number

      vertical radians offset

    Returns void

    2.4.0b120 (implemented in 2.3.1b116)

  • Resets player's camera if it was previously set to another entity.

    Returns void

  • Resets view zoom to the default value.

    Returns void

  • Sets some of the player's abilities. If the argument is of type boolean, sets the ability as the boolean one, otherwise as numeric one.

    Parameters

    • ability: string

      ability name constant, should be one of the EPlayerAbility constants

    • value: number | boolean

      the value to be set for the ability; can be either boolean or number, depending on the ability

    Returns void

    2.0.3b33

    Client-side only, use PlayerActor.setPlayerBooleanAbility and PlayerActor.setPlayerFloatAbility instead.

  • Sets contents of the specified armor slot.

    Parameters

    • slot: number

      armor slot ID, 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

    Client-side only, use PlayerActor.setArmor instead.

  • Sets player's camera to the specified entity.

    Parameters

    • entityUid: number

      entity uid

    Returns void

  • Sets player's exhaustion.

    Parameters

    • value: number

      exhaustion value to be set

    Returns void

    2.0.1b17 (not worked before)

    Client-side only, use PlayerActor.setExhaustion instead.

  • Sets player's experience.

    Parameters

    • exp: number

      experience value to be set

    Returns void

    Client-side only, use PlayerActor.setExperience instead.

  • 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

  • Enables or disables player's ability to fly.

    Parameters

    • enabled: boolean

      whether the player can fly or not

    Returns void

    Client-side only, use PlayerActor.setCanFly instead.

  • Sets view zoom, to reset value call Player.resetFov.

    Parameters

    • fov: number

      view zoom, default zoom is about 70

    Returns void

  • Sets player's hunger.

    Parameters

    • value: number

      hunger value to be set

    Returns void

    2.0.1b17 (not worked before)

    Client-side only, use PlayerActor.setHunger instead.

  • 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

    • Optionalextra: ItemExtraData

      item extra

    Returns void

    Client-side only, use PlayerActor.setInventorySlot instead.

  • Sets player's level.

    Parameters

    • level: number

      level value to be set

    Returns void

    Client-side only, use PlayerActor.setLevel instead.

  • Sets current offhand item for the player.

    Parameters

    • id: number

      item ID

    • count: number

      item count

    • data: number

      item data

    • Optionalextra: ItemExtraData

      item extra

    Returns void

    Client-side only, use Entity.setOffhandItem instead.

  • Sets specified coordinates as player's position.

    Parameters

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

    Returns void

    Client-side only, use Entity.setPosition instead.

  • Sets player's saturation.

    Parameters

    • value: number

      saturation value to be set

    Returns void

    2.0.1b17 (not worked before)

    Client-side only, use PlayerActor.setSaturation instead.

  • Selects currently selected inventory slot.

    Parameters

    • slot: number

      slot ID to be selected, from 0 to 8

    Returns void

  • Set player's velocity using velocity vector.

    Parameters

    • x: number

      velocity

    • y: number

      velocity

    • z: number

      velocity

    Returns void

    Client-side only, use Entity.setVelocity instead.

Copyright © 2024 Nernar. Copyright © 2020 #mineprogramming. Built with ❤ and TypeDoc.