ExperienceManager
Methods
__construct()
public function __construct(\pocketmine\entity\Human $entity)addXp()
public function addXp(int $amount, bool $playSound = true) : boolAdds 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()
public function addXpLevels(int $amount, bool $playSound = true) : boolAdds a number of XP levels to the player.
canAttractXpOrbs()
public function canAttractXpOrbs() : boolcanPickupXp()
public function canPickupXp() : boolReturns whether the human can pickup XP orbs (checks cooldown time)
getCurrentTotalXp()
public function getCurrentTotalXp() : intReturns 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()
public function getLifetimeTotalXp() : intReturns 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()
public function getRemainderXp() : intReturns the number of XP points the player has progressed into their current level.
getXpLevel()
public function getXpLevel() : intReturns the player's experience level.
getXpProgress()
public function getXpProgress() : floatReturns a value between 0.0 and 1.0 to indicate how far through the current level the player is.
onPickupXp()
public function onPickupXp(int $xpValue) : voidresetXpCooldown()
public function resetXpCooldown(int $value = 2) : voidSets the duration in ticks until the human can pick up another XP orb.
setCanAttractXpOrbs()
public function setCanAttractXpOrbs(bool $v = true) : voidsetCurrentTotalXp()
public function setCurrentTotalXp(int $amount) : boolSets 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()
public function setLifetimeTotalXp(int $amount) : voidSets 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()
public function setXpAndProgress(?int $level, ?float $progress) : boolsetXpLevel()
public function setXpLevel(int $level) : boolSets the player's experience level. This does not affect their total XP or their XP progress.
setXpProgress()
public function setXpProgress(float $progress) : boolSets the player's progress through the current level to a value between 0.0 and 1.0.
subtractXp()
public function subtractXp(int $amount) : boolTakes an amount of XP from the player, recalculating their XP level and progress.
subtractXpLevels()
public function subtractXpLevels(int $amount) : boolSubtracts a number of XP levels from the player.
tick()
public function tick(int $tickDiff = 1) : void