mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Separate ID handling from GameMode
the aliases of 0,1,2,3 remain for user-interface level compatibility.
This commit is contained in:
@ -29,6 +29,7 @@ use pocketmine\block\UnknownBlock;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\crafting\CraftingGrid;
|
||||
use pocketmine\data\java\GameModeIdMap;
|
||||
use pocketmine\entity\animation\Animation;
|
||||
use pocketmine\entity\animation\ArmSwingAnimation;
|
||||
use pocketmine\entity\animation\CriticalHitAnimation;
|
||||
@ -332,7 +333,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
$this->lastPlayed = $nbt->getLong("lastPlayed", $now);
|
||||
|
||||
if(!$this->server->getForceGamemode() and ($gameModeTag = $nbt->getTag("playerGameType")) instanceof IntTag){
|
||||
$this->internalSetGameMode(GameMode::fromMagicNumber($gameModeTag->getValue() & 0x03)); //TODO: bad hack here to avoid crashes on corrupted data
|
||||
$this->internalSetGameMode(GameModeIdMap::getInstance()->fromId($gameModeTag->getValue()) ?? GameMode::SURVIVAL()); //TODO: bad hack here to avoid crashes on corrupted data
|
||||
}else{
|
||||
$this->internalSetGameMode($this->server->getGamemode());
|
||||
}
|
||||
@ -2069,7 +2070,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
$nbt->setInt("SpawnZ", $spawn->getFloorZ());
|
||||
}
|
||||
|
||||
$nbt->setInt("playerGameType", $this->gamemode->getMagicNumber());
|
||||
$nbt->setInt("playerGameType", GameModeIdMap::getInstance()->toId($this->gamemode));
|
||||
$nbt->setLong("firstPlayed", $this->firstPlayed);
|
||||
$nbt->setLong("lastPlayed", (int) floor(microtime(true) * 1000));
|
||||
|
||||
|
Reference in New Issue
Block a user