do not rely on GameMode::getMagicNumber() to match protocol IDs

This commit is contained in:
Dylan K. Taylor
2020-06-13 12:26:17 +01:00
parent 5c16261374
commit 465285b3c2
4 changed files with 22 additions and 5 deletions

View File

@ -582,7 +582,8 @@ class InGamePacketHandler extends PacketHandler{
}
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
if($packet->gamemode !== $this->player->getGamemode()->getMagicNumber()){
$converter = TypeConverter::getInstance();
if(!$converter->protocolGameModeToCore($packet->gamemode)->equals($this->player->getGamemode())){
//Set this back to default. TODO: handle this properly
$this->session->syncGameMode($this->player->getGamemode(), true);
}

View File

@ -59,13 +59,13 @@ class PreSpawnPacketHandler extends PacketHandler{
$pk = new StartGamePacket();
$pk->entityUniqueId = $this->player->getId();
$pk->entityRuntimeId = $this->player->getId();
$pk->playerGamemode = TypeConverter::getInstance()->getClientFriendlyGamemode($this->player->getGamemode());
$pk->playerGamemode = TypeConverter::getInstance()->coreGameModeToProtocol($this->player->getGamemode());
$pk->playerPosition = $this->player->getOffsetPosition($location);
$pk->pitch = $location->pitch;
$pk->yaw = $location->yaw;
$pk->seed = -1;
$pk->dimension = DimensionIds::OVERWORLD; //TODO: implement this properly
$pk->worldGamemode = TypeConverter::getInstance()->getClientFriendlyGamemode($this->server->getGamemode());
$pk->worldGamemode = TypeConverter::getInstance()->coreGameModeToProtocol($this->server->getGamemode());
$pk->difficulty = $location->getWorldNonNull()->getDifficulty();
$pk->spawnX = $spawnPosition->getFloorX();
$pk->spawnY = $spawnPosition->getFloorY();