From e0b07ff3087b652407439a29c941f3b66ca92c86 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 3 Nov 2021 20:45:55 +0000 Subject: [PATCH] Human: do not add more XP if totalXp limit was already reached this matches the vanilla behaviour. For some reason it doesn't consider levels (so you can have a level higher or lower than this without actually having that amount of XP), but this matches Java behaviour as of 1.10. fixes #4543 --- src/pocketmine/entity/Human.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 9d590db0c..5036415bd 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -403,6 +403,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ * @param bool $playSound Whether to play level-up and XP gained sounds. */ public function addXp(int $amount, bool $playSound = true) : bool{ + $amount = min($amount, INT32_MAX - $this->totalXp); $oldLevel = $this->getXpLevel(); $oldTotal = $this->getCurrentTotalXp();