mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Merge branch 'stable'
This commit is contained in:
@ -27,6 +27,7 @@ use pocketmine\entity\utils\ExperienceUtils;
|
||||
use pocketmine\event\player\PlayerExperienceChangeEvent;
|
||||
use pocketmine\item\Durable;
|
||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\Limits;
|
||||
use pocketmine\world\sound\XpCollectSound;
|
||||
use pocketmine\world\sound\XpLevelUpSound;
|
||||
@ -35,6 +36,7 @@ use function ceil;
|
||||
use function count;
|
||||
use function max;
|
||||
use function min;
|
||||
use function sprintf;
|
||||
|
||||
class ExperienceManager{
|
||||
|
||||
@ -142,7 +144,12 @@ class ExperienceManager{
|
||||
public function setCurrentTotalXp(int $amount) : bool{
|
||||
$newLevel = ExperienceUtils::getLevelFromXp($amount);
|
||||
|
||||
return $this->setXpAndProgress((int) $newLevel, $newLevel - ((int) $newLevel));
|
||||
$xpLevel = (int) $newLevel;
|
||||
$xpProgress = $newLevel - (int) $newLevel;
|
||||
if($xpProgress > 1.0){
|
||||
throw new AssumptionFailedError(sprintf("newLevel - (int) newLevel should never be bigger than 1, but have %.53f (newLevel=%.53f)", $xpProgress, $newLevel));
|
||||
}
|
||||
return $this->setXpAndProgress($xpLevel, $xpProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user