XpLevelUpSound: fixed crash on non-multiples of 5

This commit is contained in:
Dylan K. Taylor 2019-03-30 18:44:30 +00:00
parent 3ea5260935
commit 004e81ea35

View File

@ -25,6 +25,7 @@ namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use function intdiv;
use function min;
class XpLevelUpSound implements Sound{
@ -46,6 +47,6 @@ class XpLevelUpSound implements Sound{
public function encode(Vector3 $pos){
//No idea why such odd numbers, but this works...
//TODO: check arbitrary volume
return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_LEVELUP, $pos, 0x10000000 * (min(30, $this->xpLevel) / 5));
return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_LEVELUP, $pos, 0x10000000 * intdiv(min(30, $this->xpLevel), 5));
}
}