diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 4ca8acee4..330f06ca6 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -113,6 +113,7 @@ use pocketmine\network\protocol\Info as ProtocolInfo; use pocketmine\network\protocol\PlayerActionPacket; use pocketmine\network\protocol\PlayStatusPacket; use pocketmine\network\protocol\RespawnPacket; +use pocketmine\network\protocol\SetPlayerGameTypePacket; use pocketmine\network\protocol\TextPacket; use pocketmine\network\protocol\MovePlayerPacket; @@ -1085,7 +1086,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return false; } - $this->gamemode = $gm; $this->allowFlight = $this->isCreative(); @@ -1098,19 +1098,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->namedtag->playerGameType = new Int("playerGameType", $this->gamemode); - $spawnPosition = $this->getSpawn(); - - $pk = new StartGamePacket(); - $pk->seed = -1; - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->spawnX = (int) $spawnPosition->x; - $pk->spawnY = (int) $spawnPosition->y; - $pk->spawnZ = (int) $spawnPosition->z; - $pk->generator = 1; //0 old, 1 infinite, 2 flat + $pk = new SetPlayerGameTypePacket(); $pk->gamemode = $this->gamemode & 0x01; - $pk->eid = 0; $this->dataPacket($pk); $this->sendSettings(); diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 729f7c5be..49053ea95 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -74,6 +74,7 @@ use pocketmine\network\protocol\TakeItemEntityPacket; use pocketmine\network\protocol\BlockEventPacket; use pocketmine\network\protocol\UpdateBlockPacket; use pocketmine\network\protocol\UseItemPacket; +use pocketmine\network\protocol\SetPlayerGameTypePacket; use pocketmine\network\protocol\PlayerListPacket; use pocketmine\Player; use pocketmine\Server; @@ -352,6 +353,7 @@ class Network{ $this->registerPacket(ProtocolInfo::BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket::class); $this->registerPacket(ProtocolInfo::FULL_CHUNK_DATA_PACKET, FullChunkDataPacket::class); $this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class); + $this->registerPacket(ProtocolInfo::SET_PLAYER_GAMETYPE_PACKET, SetPlayerGameTypePacket::class); $this->registerPacket(ProtocolInfo::PLAYER_LIST_PACKET, PlayerListPacket::class); } } diff --git a/src/pocketmine/network/protocol/Info.php b/src/pocketmine/network/protocol/Info.php index c4113e93b..3f0bdd7d6 100644 --- a/src/pocketmine/network/protocol/Info.php +++ b/src/pocketmine/network/protocol/Info.php @@ -83,7 +83,7 @@ interface Info{ const FULL_CHUNK_DATA_PACKET = 0xbf; const SET_DIFFICULTY_PACKET = 0xc0; //const CHANGE_DIMENSION_PACKET = 0xc1; - //const SET_PLAYER_GAMETYPE_PACKET = 0xc2; + const SET_PLAYER_GAMETYPE_PACKET = 0xc2; const PLAYER_LIST_PACKET = 0xc3; //const TELEMETRY_EVENT_PACKET = 0xc4; //const SPAWN_EXPERIENCE_ORB_PACKET = 0xc5 diff --git a/src/pocketmine/network/protocol/LoginPacket.php b/src/pocketmine/network/protocol/LoginPacket.php index 5608ac993..921b7ef03 100644 --- a/src/pocketmine/network/protocol/LoginPacket.php +++ b/src/pocketmine/network/protocol/LoginPacket.php @@ -52,8 +52,8 @@ class LoginPacket extends DataPacket{ $this->serverAddress = $this->getString(); $this->clientSecret = $this->getString(); - $this->getByte(); // TODO: skin transparency, experimental or not? $this->slim = $this->getByte() > 0; + $this->getByte(); // TODO: skin transparency, experimental or not? $this->skin = $this->getString(); } diff --git a/src/pocketmine/network/protocol/PlayerListPacket.php b/src/pocketmine/network/protocol/PlayerListPacket.php index 9f9658b4a..4ec5e4476 100644 --- a/src/pocketmine/network/protocol/PlayerListPacket.php +++ b/src/pocketmine/network/protocol/PlayerListPacket.php @@ -53,8 +53,8 @@ class PlayerListPacket extends DataPacket{ $this->putUUID($d[0]); $this->putLong($d[1]); $this->putString($d[2]); - $this->putByte(0); // TODO: skin transparency, experimental or not? $this->putByte($d[3] ? 1 : 0); + $this->putByte(0); // TODO: skin transparency, experimental or not? $this->putString($d[4]); }else{ $this->putUUID($d[0]); diff --git a/src/pocketmine/network/protocol/SetPlayerGameTypePacket.php b/src/pocketmine/network/protocol/SetPlayerGameTypePacket.php new file mode 100644 index 000000000..46e0ad72e --- /dev/null +++ b/src/pocketmine/network/protocol/SetPlayerGameTypePacket.php @@ -0,0 +1,41 @@ + + + +class SetPlayerGameTypePacket extends DataPacket{ + const NETWORK_ID = Info::SET_PLAYER_GAMETYPE_PACKET; + + public $gamemode; + + public function decode(){ + + } + + public function encode(){ + $this->reset(); + $this->putInt($this->gamemode); + } + +}