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
This commit is contained in:
Dylan K. Taylor 2021-11-03 20:45:55 +00:00
parent 729f831b8f
commit e0b07ff308
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -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();