From 7cd7a7fbf67bf565fa29349aeb328078ef19f202 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 11 Oct 2016 22:31:13 +0100 Subject: [PATCH] Spawn working on new build. TODO: Resource packs. --- src/pocketmine/Player.php | 5 +- src/pocketmine/network/Network.php | 4 ++ .../ResourcePackClientResponsePacket.php | 38 +++++++++++++ .../protocol/ResourcePacksInfoPacket.php | 57 +++++++++++++++++++ .../resourcepacks/ResourcePackInfoEntry.php | 47 +++++++++++++++ 5 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 src/pocketmine/network/protocol/ResourcePackClientResponsePacket.php create mode 100644 src/pocketmine/network/protocol/ResourcePacksInfoPacket.php create mode 100644 src/pocketmine/resourcepacks/ResourcePackInfoEntry.php diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 5b7b6f555..325b8cb33 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -114,6 +114,7 @@ use pocketmine\network\protocol\InteractPacket; use pocketmine\network\protocol\MovePlayerPacket; use pocketmine\network\protocol\PlayerActionPacket; use pocketmine\network\protocol\PlayStatusPacket; +use pocketmine\network\protocol\ResourcePacksInfoPacket; use pocketmine\network\protocol\RespawnPacket; use pocketmine\network\protocol\SetDifficultyPacket; use pocketmine\network\protocol\SetEntityMotionPacket; @@ -1644,9 +1645,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->inventory->setHeldItemSlot($this->inventory->getHotbarSlotIndex(0)); } - $pk = new PlayStatusPacket(); - $pk->status = PlayStatusPacket::LOGIN_SUCCESS; - $this->dataPacket($pk); + $this->dataPacket(new ResourcePacksInfoPacket()); if($this->spawnPosition === null and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level){ $this->spawnPosition = new Position($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level); diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 7b1859a58..cb6500d53 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -71,6 +71,8 @@ use pocketmine\network\protocol\RemoveBlockPacket; use pocketmine\network\protocol\RemoveEntityPacket; use pocketmine\network\protocol\ReplaceSelectedItemPacket; use pocketmine\network\protocol\RequestChunkRadiusPacket; +use pocketmine\network\protocol\ResourcePackClientResponsePacket; +use pocketmine\network\protocol\ResourcePacksInfoPacket; use pocketmine\network\protocol\RespawnPacket; use pocketmine\network\protocol\SetCommandsEnabledPacket; use pocketmine\network\protocol\SetDifficultyPacket; @@ -337,6 +339,8 @@ class Network{ $this->registerPacket(ProtocolInfo::REMOVE_ENTITY_PACKET, RemoveEntityPacket::class); $this->registerPacket(ProtocolInfo::REPLACE_SELECTED_ITEM_PACKET, ReplaceSelectedItemPacket::class); $this->registerPacket(ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET, RequestChunkRadiusPacket::class); + $this->registerPacket(ProtocolInfo::RESOURCE_PACK_CLIENT_RESPONSE_PACKET, ResourcePackClientResponsePacket::class); + $this->registerPacket(ProtocolInfo::RESOURCE_PACKS_INFO_PACKET, ResourcePacksInfoPacket::class); $this->registerPacket(ProtocolInfo::RESPAWN_PACKET, RespawnPacket::class); $this->registerPacket(ProtocolInfo::SET_COMMANDS_ENABLED_PACKET, SetCommandsEnabledPacket::class); $this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class); diff --git a/src/pocketmine/network/protocol/ResourcePackClientResponsePacket.php b/src/pocketmine/network/protocol/ResourcePackClientResponsePacket.php new file mode 100644 index 000000000..02a7fb467 --- /dev/null +++ b/src/pocketmine/network/protocol/ResourcePackClientResponsePacket.php @@ -0,0 +1,38 @@ + + + +class ResourcePackClientResponsePacket extends DataPacket{ + const NETWORK_ID = Info::RESOURCE_PACK_CLIENT_RESPONSE_PACKET; + + public function decode(){ + var_dump($this->buffer); + } + + public function encode(){ + + } + +} \ No newline at end of file diff --git a/src/pocketmine/network/protocol/ResourcePacksInfoPacket.php b/src/pocketmine/network/protocol/ResourcePacksInfoPacket.php new file mode 100644 index 000000000..b39e53ebc --- /dev/null +++ b/src/pocketmine/network/protocol/ResourcePacksInfoPacket.php @@ -0,0 +1,57 @@ + + + +class ResourcePacksInfoPacket extends DataPacket{ + const NETWORK_ID = Info::RESOURCE_PACKS_INFO_PACKET; + + public $mustAccept = false; //force client to use selected resource packs + /** @var ResourcePackInfoEntry */ + public $behaviourPackEntries = []; + /** @var ResourcePackInfoEntry */ + public $resourcePackEntries = []; + + public function decode(){ + + } + + public function encode(){ + $this->reset(); + + $this->putByte($this->mustAccept); + $this->putShort(count($this->behaviourPackEntries)); + foreach($this->behaviourPackEntries as $entry){ + $this->putString($entry->getName()); + $this->putString($entry->getVersion()); + $this->putLong($entry->getUint64()); + } + $this->putShort(count($this->resourcePackEntries)); + foreach($this->resourcePackEntries as $entry){ + $this->putString($entry->getName()); + $this->putString($entry->getVersion()); + $this->putLong($entry->getUint64()); + } + } +} \ No newline at end of file diff --git a/src/pocketmine/resourcepacks/ResourcePackInfoEntry.php b/src/pocketmine/resourcepacks/ResourcePackInfoEntry.php new file mode 100644 index 000000000..f504f4a05 --- /dev/null +++ b/src/pocketmine/resourcepacks/ResourcePackInfoEntry.php @@ -0,0 +1,47 @@ +name = $name; + $this->version = $version; + $this->uint64 = $uint64; + } + + public function getName() : string{ + return $this->name; + } + + public function getVersion() : string{ + return $this->version; + } + + public function getUint64(){ + return $this->uint64; + } + +} \ No newline at end of file