Documentation

ExperienceManager
in package

Table of Contents

$entity  : Human
$levelAttr  : Attribute
$progressAttr  : Attribute
$totalXp  : int
$xpCooldown  : int
__construct()  : mixed
addXp()  : bool
Adds an amount of XP to the player, recalculating their XP level and progress. XP amount will be added to the player's lifetime XP.
addXpLevels()  : bool
Adds a number of XP levels to the player.
canPickupXp()  : bool
Returns whether the human can pickup XP orbs (checks cooldown time)
getCurrentTotalXp()  : int
Returns the amount of XP points the player currently has, calculated from their current level and progress through their current level. This will be reduced by enchanting deducting levels and is used to calculate the amount of XP the player drops on death.
getLifetimeTotalXp()  : int
Returns the total XP the player has collected in their lifetime. Resets when the player dies.
getRemainderXp()  : int
Returns the number of XP points the player has progressed into their current level.
getXpLevel()  : int
Returns the player's experience level.
getXpProgress()  : float
Returns a value between 0.0 and 1.0 to indicate how far through the current level the player is.
onPickupXp()  : void
resetXpCooldown()  : void
Sets the duration in ticks until the human can pick up another XP orb.
setCurrentTotalXp()  : bool
Sets the current total of XP the player has, recalculating their XP level and progress.
setLifetimeTotalXp()  : void
Sets the lifetime total XP of the player. This does not recalculate their level or progress. Used for player score when they die. (TODO: add this when MCPE supports it)
setXpAndProgress()  : bool
setXpLevel()  : bool
Sets the player's experience level. This does not affect their total XP or their XP progress.
setXpProgress()  : bool
Sets the player's progress through the current level to a value between 0.0 and 1.0.
subtractXp()  : bool
Takes an amount of XP from the player, recalculating their XP level and progress.
subtractXpLevels()  : bool
Subtracts a number of XP levels from the player.
tick()  : void
fetchAttribute()  : Attribute

Properties

Methods

addXp()

Adds an amount of XP to the player, recalculating their XP level and progress. XP amount will be added to the player's lifetime XP.

public addXp(int $amount[, bool $playSound = true ]) : bool
Parameters
$amount : int
$playSound : bool = true

Whether to play level-up and XP gained sounds.

Return values
bool

addXpLevels()

Adds a number of XP levels to the player.

public addXpLevels(int $amount[, bool $playSound = true ]) : bool
Parameters
$amount : int
$playSound : bool = true
Return values
bool

canPickupXp()

Returns whether the human can pickup XP orbs (checks cooldown time)

public canPickupXp() : bool
Return values
bool

getCurrentTotalXp()

Returns the amount of XP points the player currently has, calculated from their current level and progress through their current level. This will be reduced by enchanting deducting levels and is used to calculate the amount of XP the player drops on death.

public getCurrentTotalXp() : int
Return values
int

getLifetimeTotalXp()

Returns the total XP the player has collected in their lifetime. Resets when the player dies.

public getLifetimeTotalXp() : int

XP levels being removed in enchanting do not reduce this number.

Return values
int

getRemainderXp()

Returns the number of XP points the player has progressed into their current level.

public getRemainderXp() : int
Return values
int

getXpLevel()

Returns the player's experience level.

public getXpLevel() : int
Return values
int

getXpProgress()

Returns a value between 0.0 and 1.0 to indicate how far through the current level the player is.

public getXpProgress() : float
Return values
float

onPickupXp()

public onPickupXp(int $xpValue) : void
Parameters
$xpValue : int
Return values
void

resetXpCooldown()

Sets the duration in ticks until the human can pick up another XP orb.

public resetXpCooldown([int $value = 2 ]) : void
Parameters
$value : int = 2
Return values
void

setCurrentTotalXp()

Sets the current total of XP the player has, recalculating their XP level and progress.

public setCurrentTotalXp(int $amount) : bool

Note that this DOES NOT update the player's lifetime total XP.

Parameters
$amount : int
Return values
bool

setLifetimeTotalXp()

Sets the lifetime total XP of the player. This does not recalculate their level or progress. Used for player score when they die. (TODO: add this when MCPE supports it)

public setLifetimeTotalXp(int $amount) : void
Parameters
$amount : int
Return values
void

setXpAndProgress()

public setXpAndProgress(int|null $level, float|null $progress) : bool
Parameters
$level : int|null
$progress : float|null
Return values
bool

setXpLevel()

Sets the player's experience level. This does not affect their total XP or their XP progress.

public setXpLevel(int $level) : bool
Parameters
$level : int
Return values
bool

setXpProgress()

Sets the player's progress through the current level to a value between 0.0 and 1.0.

public setXpProgress(float $progress) : bool
Parameters
$progress : float
Return values
bool

subtractXp()

Takes an amount of XP from the player, recalculating their XP level and progress.

public subtractXp(int $amount) : bool
Parameters
$amount : int
Return values
bool

subtractXpLevels()

Subtracts a number of XP levels from the player.

public subtractXpLevels(int $amount) : bool
Parameters
$amount : int
Return values
bool

tick()

public tick([int $tickDiff = 1 ]) : void
Parameters
$tickDiff : int = 1
Return values
void

Search results