Skip to content

ExperienceManager ​

class · pocketmine\entity\ExperienceManager · source

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Human $entity)

addXp() ​

php
public function addXp(int $amount, bool $playSound = true) : 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() ​

php
public function addXpLevels(int $amount, bool $playSound = true) : bool

Adds a number of XP levels to the player.

canAttractXpOrbs() ​

php
public function canAttractXpOrbs() : bool

canPickupXp() ​

php
public function canPickupXp() : bool

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

getCurrentTotalXp() ​

php
public function 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() ​

php
public function getLifetimeTotalXp() : int

Returns the total XP the player has collected in their lifetime. Resets when the player dies. XP levels being removed in enchanting do not reduce this number.

getRemainderXp() ​

php
public function getRemainderXp() : int

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

getXpLevel() ​

php
public function getXpLevel() : int

Returns the player's experience level.

getXpProgress() ​

php
public function getXpProgress() : float

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

onPickupXp() ​

php
public function onPickupXp(int $xpValue) : void

resetXpCooldown() ​

php
public function resetXpCooldown(int $value = 2) : void

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

setCanAttractXpOrbs() ​

php
public function setCanAttractXpOrbs(bool $v = true) : void

setCurrentTotalXp() ​

php
public function setCurrentTotalXp(int $amount) : bool

Sets the current total of XP the player has, recalculating their XP level and progress. Note that this DOES NOT update the player's lifetime total XP.

setLifetimeTotalXp() ​

php
public function setLifetimeTotalXp(int $amount) : 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() ​

php
public function setXpAndProgress(?int $level, ?float $progress) : bool

setXpLevel() ​

php
public function setXpLevel(int $level) : bool

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

setXpProgress() ​

php
public function setXpProgress(float $progress) : bool

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

subtractXp() ​

php
public function subtractXp(int $amount) : bool

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

subtractXpLevels() ​

php
public function subtractXpLevels(int $amount) : bool

Subtracts a number of XP levels from the player.

tick() ​

php
public function tick(int $tickDiff = 1) : void

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.