Player
Index
Interfaces
Functions
- addExperience
- addItemToInventory
- addLevel
- addPosition
- addVelocity
- decreaseCarriedItem
- exhaustion
- experience
- flying
- get
- getArmorSlot
- getBooleanAbility
- getCarriedItem
- getDimension
- getExhaustion
- getExperience
- getFloatAbility
- getFlying
- getFlyingEnabled
- getHealth
- getHunger
- getInventory
- getInventorySlot
- getLevel
- getLocal
- getOffhandItem
- getPointed
- getPosition
- getSaturation
- getScore
- getSelectedSlotId
- getServer
- getVelocity
- health
- hunger
- isPlayer
- level
- localPlayerTurn
- resetCameraEntity
- resetFov
- saturation
- score
- setAbility
- setArmorSlot
- setCameraEntity
- setCarriedItem
- setExhaustion
- setExperience
- setFlying
- setFlyingEnabled
- setFov
- setHealth
- setHunger
- setInventorySlot
- setLevel
- setOffhandItem
- setPosition
- setSaturation
- setSelectedSlotId
- setVelocity
Interfaces
PlayerExhaustion
Interface used to manipulate player's exhaustion.
get
Returns number
Player's current exhaustion.
set
Sets player's exhaustion.
Parameters
value: number
exhaustion value to be set
Returns void
PlayerExperience
Interface used to manipulate player's experience.
add
Adds specified amount of experience to the current value.
Parameters
exp: number
amount to be added
Returns void
get
Returns number
Player's current experience.
set
Sets player's experience.
Parameters
exp: number
experience value to be set
Returns void
PlayerFlying
Interface used to manipulate player's flying ability and state.
get
Returns boolean
true
if player is flying,false
otherwise.
getEnabled
Returns boolean
true
if player is allowed to fly,false
otherwise.
set
Changes player's current flying state, call Player.PlayerFlying.setEnabled to be able to set this property to
true
.Parameters
enabled: boolean
whether the player should fly or not
Returns void
setEnabled
Enables or disables player's ability to fly.
Parameters
enabled: boolean
whether the player can fly or not
Returns void
PlayerHealth
Interface used to manipulate player's health.
get
Returns number
Player's current health.
set
Sets player's health.
Parameters
value: number
health value to be set
Returns void
PlayerHunger
Interface used to manipulate player's hunger.
get
Returns number
Player's current hunger.
set
Sets player's hunger.
Parameters
value: number
hunger value to be set
Returns void
PlayerLevel
Interface used to manipulate player's level.
add
Adds specified amount of level to the current value.
Parameters
level: number
amount to be added
Returns void
get
Returns number
Player's current level.
set
Sets player's level.
Parameters
level: number
level value to be set
Returns void
PlayerSaturation
Interface used to manipulate player's saturation.
get
Returns number
Player's current saturation.
set
Sets player's saturation.
Parameters
value: number
saturation value to be set
Returns void
PlayerScore
Interface used to manipulate player's score.
get
Returns number
Player's current score.
PointedData
Entity pointed data, which is used in Player.getPointed.
block
Pointed block data, if player doesn't look at the block, air block is returned.
entity
Pointed entity, if no entity's pointed, returns -1
.
pos
Pointed block position.
vec
Look vector.
Functions
addExperience
Adds specified amount of experience to the current value.
Parameters
exp: number
amount to be added
Returns void
addItemToInventory
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
addLevel
Adds specified amount of level to the current value.
Parameters
level: number
amount to be added
Returns void
addPosition
Changes current player position by specified vector.
Parameters
x: number
y: number
z: number
Returns void
addVelocity
Updates current entity's velocity by specified values.
Parameters
x: number
y: number
z: number
Returns void
decreaseCarriedItem
Decreases carried item count by specified number.
Parameters
optionalcount: number
amount of items to decrease carried item by, default value is
1
Returns void
exhaustion
Returns PlayerExhaustion
An object that allows to manipulate player's exhaustion.
experience
Returns PlayerExperience
An object that allows to manipulate player experience.
flying
Returns PlayerFlying
An object that allows to manipulate player flying ability and state.
get
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
getArmorSlot
Parameters
slot: number
armor slot ID, should be one of the EArmorType values.
Returns ItemInstance
Information about item in the specified armor slot.
getBooleanAbility
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.
getCarriedItem
Returns ItemInstance
Item in player's hand.
getDimension
Returns number
Current dimension numeric uid, one of the EDimension values or custom dimension ID.
getExhaustion
Returns number
Player's current exhaustion.
getExperience
Returns number
Player's current experience.
getFloatAbility
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.
getFlying
Returns boolean
true
if player is flying,false
otherwise.
getFlyingEnabled
Returns boolean
true
if player is allowed to fly,false
otherwise.
getHealth
Returns number
Player's current health.
getHunger
Returns number
Player's current hunger.
getInventory
Parameters
loadPart: any
handleEnchant: any
handleNames: any
Returns void
getInventorySlot
Parameters
slot: number
slot ID, from 0 to 36
Returns ItemInstance
Information about item in the specified inventory slot.
getLevel
Returns number
Player's current level.
getLocal
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
getOffhandItem
Returns ItemInstance
Player's current offhand item information.
getPointed
Fetches information about the objects player is currently pointing.
Returns PointedData
getPosition
Returns Vector
Current player's position.
getSaturation
Returns number
Player's current saturation.
getScore
Returns number
Player's current score.
getSelectedSlotId
Returns number
Currently selected inventory slot, from 0 to 8.
getServer
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
getVelocity
health
Returns PlayerHealth
An object that allows to manipulate player's health.
hunger
Returns PlayerHunger
An object that allows to manipulate player's exhaustion.
isPlayer
Parameters
entityUid: number
Returns boolean
true
if specified entity is of player type,false
otherwise.
level
Returns PlayerLevel
An object that allows to manipulate player level.
localPlayerTurn
Simulates local player rotation by specified delta.
Parameters
deltaX: number
horizontal radians offset
deltaY: number
vertical radians offset
Returns void
resetCameraEntity
Resets player's camera if it was previously set to another entity.
Returns void
resetFov
Resets view zoom to the default value.
Returns void
saturation
Returns PlayerSaturation
An object that allows to manipulate player's saturation.
score
Returns PlayerScore
An object that allows to manipulate player's score.
setAbility
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
setArmorSlot
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
setCameraEntity
Sets player's camera to the specified entity.
Parameters
entityUid: number
entity uid
Returns void
setCarriedItem
Sets item in player's hand.
Parameters
id: number
item ID
count: number
item count
data: number
item data
optionalextra: ItemExtraData
item extra
Returns void
setExhaustion
Sets player's exhaustion.
Parameters
value: number
exhaustion value to be set
Returns void
setExperience
Sets player's experience.
Parameters
exp: number
experience value to be set
Returns void
setFlying
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
Enables or disables player's ability to fly.
Parameters
enabled: boolean
whether the player can fly or not
Returns void
setFov
Sets view zoom, to reset value call Player.resetFov.
Parameters
fov: number
view zoom, default zoom is about 70
Returns void
setHealth
Sets player's health.
Parameters
value: number
Health value to be set.
Returns void
setHunger
Sets player's hunger.
Parameters
value: number
hunger value to be set
Returns void
setInventorySlot
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
setLevel
Sets player's level.
Parameters
level: number
level value to be set
Returns void
setOffhandItem
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
setPosition
Sets specified coordinates as player's position.
Parameters
x: number
y: number
z: number
Returns void
setSaturation
Sets player's saturation.
Parameters
value: number
saturation value to be set
Returns void
setSelectedSlotId
Selects currently selected inventory slot.
Parameters
slot: number
slot ID to be selected, from 0 to 8
Returns void
setVelocity
Set player's velocity using velocity vector.
Parameters
x: number
velocity
y: number
velocity
z: number
velocity
Returns void
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.