PocketMine-MP 5.15.1 git-fb9a74e8799c71ed8292cfa53abe7a4c9204629d
pocketmine\entity\ExperienceManager Class Reference
+ Collaboration diagram for pocketmine\entity\ExperienceManager:

Public Member Functions

 __construct (private Human $entity)
 addXp (int $amount, bool $playSound=true)
 addXpLevels (int $amount, bool $playSound=true)
 canAttractXpOrbs ()
 canPickupXp ()
 getCurrentTotalXp ()
 getLifetimeTotalXp ()
 getRemainderXp ()
 getXpLevel ()
 getXpProgress ()
 onPickupXp (int $xpValue)
 resetXpCooldown (int $value=2)
 setCanAttractXpOrbs (bool $v=true)
 setCurrentTotalXp (int $amount)
 setLifetimeTotalXp (int $amount)
 setXpAndProgress (?int $level, ?float $progress)
 setXpAndProgressNoEvent (int $level, float $progress)
 setXpLevel (int $level)
 setXpProgress (float $progress)
 subtractXp (int $amount)
 subtractXpLevels (int $amount)
 tick (int $tickDiff=1)

Detailed Description

Definition at line 39 of file ExperienceManager.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\entity\ExperienceManager::__construct ( private Human  $entity)

Definition at line 50 of file ExperienceManager.php.

Member Function Documentation

◆ addXp()

pocketmine\entity\ExperienceManager::addXp ( int  $amount,
bool  $playSound = true 

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.

bool$playSoundWhether to play level-up and XP gained sounds.

Definition at line 151 of file ExperienceManager.php.

◆ addXpLevels()

pocketmine\entity\ExperienceManager::addXpLevels ( int  $amount,
bool  $playSound = true 

Adds a number of XP levels to the player.

Definition at line 80 of file ExperienceManager.php.

◆ canAttractXpOrbs()

pocketmine\entity\ExperienceManager::canAttractXpOrbs ( )

Definition at line 292 of file ExperienceManager.php.

◆ canPickupXp()

pocketmine\entity\ExperienceManager::canPickupXp ( )

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

Definition at line 235 of file ExperienceManager.php.

◆ getCurrentTotalXp()

pocketmine\entity\ExperienceManager::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.

Definition at line 129 of file ExperienceManager.php.

◆ getLifetimeTotalXp()

pocketmine\entity\ExperienceManager::getLifetimeTotalXp ( )

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.

Definition at line 216 of file ExperienceManager.php.

◆ getRemainderXp()

pocketmine\entity\ExperienceManager::getRemainderXp ( )

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

Definition at line 120 of file ExperienceManager.php.

◆ getXpLevel()

pocketmine\entity\ExperienceManager::getXpLevel ( )

Returns the player's experience level.

Definition at line 66 of file ExperienceManager.php.

◆ getXpProgress()

pocketmine\entity\ExperienceManager::getXpProgress ( )

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

Definition at line 106 of file ExperienceManager.php.

◆ onPickupXp()

pocketmine\entity\ExperienceManager::onPickupXp ( int  $xpValue)

Definition at line 239 of file ExperienceManager.php.

◆ resetXpCooldown()

pocketmine\entity\ExperienceManager::resetXpCooldown ( int  $value = 2)

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

Definition at line 282 of file ExperienceManager.php.

◆ setCanAttractXpOrbs()

pocketmine\entity\ExperienceManager::setCanAttractXpOrbs ( bool  $v = true)

Definition at line 296 of file ExperienceManager.php.

◆ setCurrentTotalXp()

pocketmine\entity\ExperienceManager::setCurrentTotalXp ( int  $amount)

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.

Definition at line 137 of file ExperienceManager.php.

◆ setLifetimeTotalXp()

pocketmine\entity\ExperienceManager::setLifetimeTotalXp ( int  $amount)

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)

Definition at line 224 of file ExperienceManager.php.

◆ setXpAndProgress()

pocketmine\entity\ExperienceManager::setXpAndProgress ( ?int  $level,
?float  $progress 

Definition at line 182 of file ExperienceManager.php.

◆ setXpAndProgressNoEvent()

pocketmine\entity\ExperienceManager::setXpAndProgressNoEvent ( int  $level,
float  $progress 

Definition at line 207 of file ExperienceManager.php.

◆ setXpLevel()

pocketmine\entity\ExperienceManager::setXpLevel ( int  $level)

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

Definition at line 73 of file ExperienceManager.php.

◆ setXpProgress()

pocketmine\entity\ExperienceManager::setXpProgress ( float  $progress)

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

Definition at line 113 of file ExperienceManager.php.

◆ subtractXp()

pocketmine\entity\ExperienceManager::subtractXp ( int  $amount)

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

Definition at line 178 of file ExperienceManager.php.

◆ subtractXpLevels()

pocketmine\entity\ExperienceManager::subtractXpLevels ( int  $amount)

Subtracts a number of XP levels from the player.

Definition at line 99 of file ExperienceManager.php.

◆ tick()

pocketmine\entity\ExperienceManager::tick ( int  $tickDiff = 1)

Definition at line 286 of file ExperienceManager.php.

The documentation for this class was generated from the following file: