From 77cd8e7799978042ebc22dbd75856658e468f6d8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 1 Aug 2017 20:06:02 +0100 Subject: [PATCH] More broken mess to spawn 1.2 --- src/pocketmine/Player.php | 110 +++----- src/pocketmine/entity/Entity.php | 7 +- src/pocketmine/inventory/BaseInventory.php | 18 +- src/pocketmine/inventory/PlayerInventory.php | 63 ++--- src/pocketmine/level/format/EmptySubChunk.php | 2 +- src/pocketmine/level/format/SubChunk.php | 3 +- .../network/mcpe/NetworkSession.php | 122 +++++--- .../mcpe/PlayerNetworkSessionAdapter.php | 46 ++- .../network/mcpe/protocol/AddEntityPacket.php | 8 +- .../network/mcpe/protocol/AddPlayerPacket.php | 19 ++ .../mcpe/protocol/AdventureSettingsPacket.php | 97 ++++--- .../network/mcpe/protocol/BatchPacket.php | 16 ++ .../mcpe/protocol/BlockPickRequestPacket.php | 3 + .../network/mcpe/protocol/BookEditPacket.php | 115 ++++++++ ...ItemPacket.php => CommandOutputPacket.php} | 14 +- ...tepPacket.php => CommandRequestPacket.php} | 34 +-- .../mcpe/protocol/ContainerSetSlotPacket.php | 3 + .../network/mcpe/protocol/DataPacket.php | 24 +- .../network/mcpe/protocol/DropItemPacket.php | 3 + .../mcpe/protocol/EntityPickRequestPacket.php | 49 ++++ .../mcpe/protocol/GuiDataPickItemPacket.php | 47 ++++ .../network/mcpe/protocol/InteractPacket.php | 21 ++ .../mcpe/protocol/InventoryContentPacket.php | 58 ++++ ...tionPacket.php => InventorySlotPacket.php} | 28 +- .../protocol/InventoryTransactionPacket.php | 53 ++++ .../mcpe/protocol/LevelSoundEventPacket.php | 263 +++++++++++------- .../network/mcpe/protocol/LoginPacket.php | 14 +- .../mcpe/protocol/ModalFormRequestPacket.php | 49 ++++ ...Packet.php => ModalFormResponsePacket.php} | 13 +- .../mcpe/protocol/NpcRequestPacket.php | 59 ++++ .../network/mcpe/protocol/PacketPool.php | 28 +- .../mcpe/protocol/PhotoTransferPacket.php | 55 ++++ .../mcpe/protocol/PlayerActionPacket.php | 31 ++- ...ntentPacket.php => PlayerHotbarPacket.php} | 49 +--- .../mcpe/protocol/PlayerListPacket.php | 20 +- .../mcpe/protocol/PlayerSkinPacket.php | 73 +++++ .../network/mcpe/protocol/ProtocolInfo.php | 98 ++++--- .../mcpe/protocol/RemoveBlockPacket.php | 3 + .../mcpe/protocol/ResourcePackStackPacket.php | 2 + .../mcpe/protocol/ResourcePacksInfoPacket.php | 2 + .../protocol/ServerSettingsRequestPacket.php | 44 +++ .../protocol/ServerSettingsResponsePacket.php | 44 +++ .../ServerToClientHandshakePacket.php | 13 +- .../mcpe/protocol/SetEntityLinkPacket.php | 13 +- .../mcpe/protocol/SetLastHurtByPacket.php | 46 +++ .../network/mcpe/protocol/StartGamePacket.php | 47 +++- .../mcpe/protocol/SubClientLoginPacket.php | 44 +++ .../network/mcpe/protocol/TextPacket.php | 3 + .../network/mcpe/protocol/UseItemPacket.php | 3 + .../network/mcpe/protocol/WSConnectPacket.php | 47 ++++ .../mcpe/protocol/types/PlayerPermissions.php | 32 +++ src/pocketmine/utils/Utils.php | 6 + 52 files changed, 1558 insertions(+), 506 deletions(-) create mode 100644 src/pocketmine/network/mcpe/protocol/BookEditPacket.php rename src/pocketmine/network/mcpe/protocol/{AddItemPacket.php => CommandOutputPacket.php} (82%) rename src/pocketmine/network/mcpe/protocol/{CommandStepPacket.php => CommandRequestPacket.php} (51%) create mode 100644 src/pocketmine/network/mcpe/protocol/EntityPickRequestPacket.php create mode 100644 src/pocketmine/network/mcpe/protocol/GuiDataPickItemPacket.php create mode 100644 src/pocketmine/network/mcpe/protocol/InventoryContentPacket.php rename src/pocketmine/network/mcpe/protocol/{InventoryActionPacket.php => InventorySlotPacket.php} (65%) create mode 100644 src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket.php create mode 100644 src/pocketmine/network/mcpe/protocol/ModalFormRequestPacket.php rename src/pocketmine/network/mcpe/protocol/{ReplaceItemInSlotPacket.php => ModalFormResponsePacket.php} (80%) create mode 100644 src/pocketmine/network/mcpe/protocol/NpcRequestPacket.php create mode 100644 src/pocketmine/network/mcpe/protocol/PhotoTransferPacket.php rename src/pocketmine/network/mcpe/protocol/{ContainerSetContentPacket.php => PlayerHotbarPacket.php} (52%) create mode 100644 src/pocketmine/network/mcpe/protocol/PlayerSkinPacket.php create mode 100644 src/pocketmine/network/mcpe/protocol/ServerSettingsRequestPacket.php create mode 100644 src/pocketmine/network/mcpe/protocol/ServerSettingsResponsePacket.php create mode 100644 src/pocketmine/network/mcpe/protocol/SetLastHurtByPacket.php create mode 100644 src/pocketmine/network/mcpe/protocol/SubClientLoginPacket.php create mode 100644 src/pocketmine/network/mcpe/protocol/WSConnectPacket.php create mode 100644 src/pocketmine/network/mcpe/protocol/types/PlayerPermissions.php diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 3043dc34a..5113295f7 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -115,9 +115,7 @@ use pocketmine\network\mcpe\protocol\BossEventPacket; use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket; use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket; use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket; -use pocketmine\network\mcpe\protocol\CommandStepPacket; use pocketmine\network\mcpe\protocol\ContainerClosePacket; -use pocketmine\network\mcpe\protocol\ContainerSetContentPacket; use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket; use pocketmine\network\mcpe\protocol\CraftingEventPacket; use pocketmine\network\mcpe\protocol\DataPacket; @@ -156,6 +154,7 @@ use pocketmine\network\mcpe\protocol\TextPacket; use pocketmine\network\mcpe\protocol\TransferPacket; use pocketmine\network\mcpe\protocol\types\ContainerIds; use pocketmine\network\mcpe\protocol\types\DimensionIds; +use pocketmine\network\mcpe\protocol\types\PlayerPermissions; use pocketmine\network\mcpe\protocol\UpdateAttributesPacket; use pocketmine\network\mcpe\protocol\UpdateBlockPacket; use pocketmine\network\mcpe\protocol\UseItemPacket; @@ -1321,14 +1320,17 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ */ public function sendSettings(){ $pk = new AdventureSettingsPacket(); - $pk->flags = 0; - $pk->worldImmutable = $this->isSpectator(); - $pk->noPvp = $this->isSpectator(); - $pk->autoJump = $this->autoJump; - $pk->allowFlight = $this->allowFlight; - $pk->noClip = $this->isSpectator(); - $pk->isFlying = $this->flying; - $pk->userPermission = ($this->isOp() ? AdventureSettingsPacket::PERMISSION_OPERATOR : AdventureSettingsPacket::PERMISSION_NORMAL); + + $pk->setFlag(AdventureSettingsPacket::WORLD_IMMUTABLE, $this->isSpectator()); + $pk->setFlag(AdventureSettingsPacket::NO_PVP, $this->isSpectator()); + $pk->setFlag(AdventureSettingsPacket::AUTO_JUMP, $this->autoJump); + $pk->setFlag(AdventureSettingsPacket::ALLOW_FLIGHT, $this->allowFlight); + $pk->setFlag(AdventureSettingsPacket::NO_CLIP, $this->isSpectator()); + $pk->setFlag(AdventureSettingsPacket::FLYING, $this->flying); + + $pk->commandPermission = ($this->isOp() ? AdventureSettingsPacket::PERMISSION_OPERATOR : AdventureSettingsPacket::PERMISSION_NORMAL); + $pk->playerPermission = ($this->isOp() ? PlayerPermissions::OPERATOR : PlayerPermissions::MEMBER); + $this->dataPacket($pk); } @@ -1864,7 +1866,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $pk->spawnY = $spawnPosition->getFloorY(); $pk->spawnZ = $spawnPosition->getFloorZ(); $pk->hasAchievementsDisabled = true; - $pk->dayCycleStopTime = -1; //TODO: implement this properly + $pk->time = $this->level->getTime(); $pk->eduMode = false; $pk->rainLevel = 0; //TODO: implement these properly $pk->lightningLevel = 0; @@ -2029,40 +2031,40 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return true; } - public function handleText(TextPacket $packet) : bool{ + /** + * Sends a chat message as this player. If the message begins with a / (forward-slash) it will be treated + * as a command. + * + * @param string $message + * + * @return bool + */ + public function chat(string $message) : bool{ if($this->spawned === false or !$this->isAlive()){ - return true; + return false; } $this->craftingType = 0; - if($packet->type === TextPacket::TYPE_CHAT){ - $packet->message = TextFormat::clean($packet->message, $this->removeFormat); - foreach(explode("\n", $packet->message) as $message){ - if(trim($message) != "" and strlen($message) <= 255 and $this->messageCounter-- > 0){ - if(substr($message, 0, 2) === "./"){ //Command (./ = fast hack for old plugins post 0.16) - $message = substr($message, 1); - } - $ev = new PlayerCommandPreprocessEvent($this, $message); + $message = TextFormat::clean($message, $this->removeFormat); + foreach(explode("\n", $message) as $messagePart){ + if(trim($messagePart) !== "" and strlen($messagePart) <= 255 and $this->messageCounter-- > 0){ + $ev = new PlayerCommandPreprocessEvent($this, $message); - if(mb_strlen($ev->getMessage(), "UTF-8") > 320){ - $ev->setCancelled(); - } - $this->server->getPluginManager()->callEvent($ev); + $this->server->getPluginManager()->callEvent($ev); - if($ev->isCancelled()){ - break; - } + if($ev->isCancelled()){ + break; + } - if(substr($ev->getMessage(), 0, 1) === "/"){ - Timings::$playerCommandTimer->startTiming(); - $this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1)); - Timings::$playerCommandTimer->stopTiming(); - }else{ - $this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage())); - if(!$ev->isCancelled()){ - $this->server->broadcastMessage($this->getServer()->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients()); - } + if(strpos($ev->getMessage(), "/") === 0){ + Timings::$playerCommandTimer->startTiming(); + $this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1)); + Timings::$playerCommandTimer->stopTiming(); + }else{ + $this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage())); + if(!$ev->isCancelled()){ + $this->server->broadcastMessage($this->getServer()->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients()); } } } @@ -2475,7 +2477,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } public function handlePlayerAction(PlayerActionPacket $packet) : bool{ - if($this->spawned === false or (!$this->isAlive() and $packet->action !== PlayerActionPacket::ACTION_RESPAWN and $packet->action !== PlayerActionPacket::ACTION_DIMENSION_CHANGE)){ + if($this->spawned === false or (!$this->isAlive() and $packet->action !== PlayerActionPacket::ACTION_RESPAWN and $packet->action !== PlayerActionPacket::ACTION_DIMENSION_CHANGE_REQUEST)){ return true; } @@ -3033,11 +3035,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{ - if($packet->isFlying and !$this->allowFlight and !$this->server->getAllowFlight()){ + $isFlying = $packet->getFlag(AdventureSettingsPacket::FLYING); + if($isFlying and !$this->allowFlight and !$this->server->getAllowFlight()){ $this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.flight"])); return true; - }elseif($packet->isFlying !== $this->isFlying()){ - $this->server->getPluginManager()->callEvent($ev = new PlayerToggleFlightEvent($this, $packet->isFlying)); + }elseif($isFlying !== $this->isFlying()){ + $this->server->getPluginManager()->callEvent($ev = new PlayerToggleFlightEvent($this, $isFlying)); if($ev->isCancelled()){ $this->sendSettings(); }else{ @@ -3045,7 +3048,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } } - if($packet->noClip and !$this->allowMovementCheats and !$this->isSpectator()){ + if($packet->getFlag(AdventureSettingsPacket::NO_CLIP) and !$this->allowMovementCheats and !$this->isSpectator()){ $this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.noclip"])); return true; } @@ -3143,29 +3146,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return false; //TODO: handle resume } - public function handleCommandStep(CommandStepPacket $packet) : bool{ - if($this->spawned === false or !$this->isAlive()){ - return true; - } - $this->craftingType = 0; - $commandText = $packet->command; - if($packet->inputJson !== null){ - foreach($packet->inputJson as $arg){ //command ordering will be an issue - $commandText .= " " . $arg; - } - } - $this->server->getPluginManager()->callEvent($ev = new PlayerCommandPreprocessEvent($this, "/" . $commandText)); - if($ev->isCancelled()){ - return true; - } - - Timings::$playerCommandTimer->startTiming(); - $this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1)); - Timings::$playerCommandTimer->stopTiming(); - - return true; - } - public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool{ return false; //TODO } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 94de3d2ed..a6f7909f5 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -200,7 +200,9 @@ abstract class Entity extends Location implements Metadatable{ const DATA_FLAG_EVOKER_SPELL = 40; const DATA_FLAG_CHARGE_ATTACK = 41; - const DATA_FLAG_LINGER = 45; + const DATA_FLAG_LINGER = 44; + const DATA_FLAG_HAS_COLLISION = 45; + const DATA_FLAG_AFFECTED_BY_GRAVITY = 46; public static $entityCount = 1; /** @var Entity[] */ @@ -397,6 +399,9 @@ abstract class Entity extends Location implements Metadatable{ $this->attributeMap = new AttributeMap(); $this->addAttributes(); + $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_AFFECTED_BY_GRAVITY, true); + $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_HAS_COLLISION, true); + $this->chunk->addEntity($this); $this->level->addEntity($this); $this->initEntity(); diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index fa9960c05..f440f0b7d 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -27,8 +27,8 @@ use pocketmine\entity\Entity; use pocketmine\event\entity\EntityInventoryChangeEvent; use pocketmine\event\inventory\InventoryOpenEvent; use pocketmine\item\Item; -use pocketmine\network\mcpe\protocol\ContainerSetContentPacket; -use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket; +use pocketmine\network\mcpe\protocol\InventoryContentPacket; +use pocketmine\network\mcpe\protocol\InventorySlotPacket; use pocketmine\Player; use pocketmine\Server; @@ -419,10 +419,9 @@ abstract class BaseInventory implements Inventory{ $target = [$target]; } - $pk = new ContainerSetContentPacket(); - $pk->slots = []; + $pk = new InventoryContentPacket(); for($i = 0; $i < $this->getSize(); ++$i){ - $pk->slots[$i] = $this->getItem($i); + $pk->items[$i] = $this->getItem($i); } foreach($target as $player){ @@ -430,8 +429,7 @@ abstract class BaseInventory implements Inventory{ $this->close($player); continue; } - $pk->windowid = $id; - $pk->targetEid = $player->getId(); + $pk->windowId = $id; $player->dataPacket($pk); } } @@ -445,8 +443,8 @@ abstract class BaseInventory implements Inventory{ $target = [$target]; } - $pk = new ContainerSetSlotPacket(); - $pk->slot = $index; + $pk = new InventorySlotPacket(); + $pk->slotIndex = $index; $pk->item = clone $this->getItem($index); foreach($target as $player){ @@ -454,7 +452,7 @@ abstract class BaseInventory implements Inventory{ $this->close($player); continue; } - $pk->windowid = $id; + $pk->windowId = $id; $player->dataPacket($pk); } } diff --git a/src/pocketmine/inventory/PlayerInventory.php b/src/pocketmine/inventory/PlayerInventory.php index 6250b62c0..ca8d28000 100644 --- a/src/pocketmine/inventory/PlayerInventory.php +++ b/src/pocketmine/inventory/PlayerInventory.php @@ -28,10 +28,11 @@ use pocketmine\event\entity\EntityArmorChangeEvent; use pocketmine\event\entity\EntityInventoryChangeEvent; use pocketmine\event\player\PlayerItemHeldEvent; use pocketmine\item\Item; -use pocketmine\network\mcpe\protocol\ContainerSetContentPacket; -use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket; +use pocketmine\network\mcpe\protocol\InventoryContentPacket; +use pocketmine\network\mcpe\protocol\InventorySlotPacket; use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket; use pocketmine\network\mcpe\protocol\MobEquipmentPacket; +use pocketmine\network\mcpe\protocol\PlayerHotbarPacket; use pocketmine\network\mcpe\protocol\types\ContainerIds; use pocketmine\Player; use pocketmine\Server; @@ -424,10 +425,9 @@ class PlayerInventory extends BaseInventory{ foreach($target as $player){ if($player === $this->getHolder()){ - $pk2 = new ContainerSetContentPacket(); - $pk2->windowid = ContainerIds::ARMOR; - $pk2->slots = $armor; - $pk2->targetEid = $player->getId(); + $pk2 = new InventoryContentPacket(); + $pk2->windowId = ContainerIds::ARMOR; + $pk2->items = $armor; $player->dataPacket($pk2); }else{ $player->dataPacket($pk); @@ -472,9 +472,10 @@ class PlayerInventory extends BaseInventory{ foreach($target as $player){ if($player === $this->getHolder()){ /** @var Player $player */ - $pk2 = new ContainerSetSlotPacket(); - $pk2->windowid = ContainerIds::ARMOR; - $pk2->slot = $index - $this->getSize(); + + $pk2 = new InventorySlotPacket(); + $pk2->windowId = ContainerIds::ARMOR; + $pk2->slotIndex = $index - $this->getSize(); $pk2->item = $this->getItem($index); $player->dataPacket($pk2); }else{ @@ -491,45 +492,39 @@ class PlayerInventory extends BaseInventory{ $target = [$target]; } - $pk = new ContainerSetContentPacket(); - $pk->slots = []; + $pk = new InventoryContentPacket(); for($i = 0; $i < $this->getSize(); ++$i){ //Do not send armor by error here - $pk->slots[$i] = $this->getItem($i); - } - - //Because PE is stupid and shows 9 less slots than you send it, give it 9 dummy slots so it shows all the REAL slots. - for($i = $this->getSize(); $i < $this->getSize() + $this->getHotbarSize(); ++$i){ - $pk->slots[$i] = Item::get(Item::AIR, 0, 0); + $pk->items[$i] = $this->getItem($i); } foreach($target as $player){ - $pk->hotbar = []; - if($player === $this->getHolder()){ - for($i = 0; $i < $this->getHotbarSize(); ++$i){ - $index = $this->getHotbarSlotIndex($i); - $pk->hotbar[] = $index <= -1 ? -1 : $index + $this->getHotbarSize(); - } - } if(($id = $player->getWindowId($this)) === -1 or $player->spawned !== true){ $this->close($player); continue; } - $pk->windowid = $id; - $pk->targetEid = $player->getId(); //TODO: check if this is correct + $pk->windowId = $id; $player->dataPacket(clone $pk); + + if($player === $this->getHolder()){ + $pk = new PlayerHotbarPacket(); + $pk->slots = array_map(function(int $i){ return $i + $this->getHotbarSize(); }, $this->hotbar); + $pk->selectedSlot = $this->getHeldItemIndex(); + $pk->windowId = ContainerIds::INVENTORY; + $player->dataPacket($pk); + } } } public function sendCreativeContents(){ - $pk = new ContainerSetContentPacket(); - $pk->windowid = ContainerIds::CREATIVE; + $pk = new InventoryContentPacket(); + $pk->windowId = ContainerIds::CREATIVE; if($this->getHolder()->getGamemode() === Player::CREATIVE){ foreach(Item::getCreativeItems() as $i => $item){ - $pk->slots[$i] = clone $item; + $pk->items[$i] = clone $item; } } - $pk->targetEid = $this->getHolder()->getId(); + $this->getHolder()->dataPacket($pk); } @@ -542,21 +537,21 @@ class PlayerInventory extends BaseInventory{ $target = [$target]; } - $pk = new ContainerSetSlotPacket(); - $pk->slot = $index; + $pk = new InventorySlotPacket(); + $pk->slotIndex = $index; $pk->item = clone $this->getItem($index); foreach($target as $player){ if($player === $this->getHolder()){ /** @var Player $player */ - $pk->windowid = 0; + $pk->windowId = ContainerIds::INVENTORY; $player->dataPacket(clone $pk); }else{ if(($id = $player->getWindowId($this)) === -1){ $this->close($player); continue; } - $pk->windowid = $id; + $pk->windowId = $id; $player->dataPacket(clone $pk); } } diff --git a/src/pocketmine/level/format/EmptySubChunk.php b/src/pocketmine/level/format/EmptySubChunk.php index 88d002429..7af20c6cd 100644 --- a/src/pocketmine/level/format/EmptySubChunk.php +++ b/src/pocketmine/level/format/EmptySubChunk.php @@ -114,7 +114,7 @@ class EmptySubChunk implements SubChunkInterface{ } public function networkSerialize() : string{ - return "\x00" . str_repeat("\x00", 10240); + return "\x00" . str_repeat("\x00", 6144); } public function fastSerialize() : string{ diff --git a/src/pocketmine/level/format/SubChunk.php b/src/pocketmine/level/format/SubChunk.php index 733a83a59..acfb32283 100644 --- a/src/pocketmine/level/format/SubChunk.php +++ b/src/pocketmine/level/format/SubChunk.php @@ -219,8 +219,7 @@ class SubChunk implements SubChunkInterface{ } public function networkSerialize() : string{ - // storage version, ids, data, skylight, blocklight - return "\x00" . $this->ids . $this->data . $this->skyLight . $this->blockLight; + return "\x00" . $this->ids . $this->data; } public function fastSerialize() : string{ diff --git a/src/pocketmine/network/mcpe/NetworkSession.php b/src/pocketmine/network/mcpe/NetworkSession.php index d3f93a0c8..01db10f9a 100644 --- a/src/pocketmine/network/mcpe/NetworkSession.php +++ b/src/pocketmine/network/mcpe/NetworkSession.php @@ -27,7 +27,6 @@ use pocketmine\network\mcpe\protocol\AddBehaviorTreePacket; use pocketmine\network\mcpe\protocol\AddEntityPacket; use pocketmine\network\mcpe\protocol\AddHangingEntityPacket; use pocketmine\network\mcpe\protocol\AddItemEntityPacket; -use pocketmine\network\mcpe\protocol\AddItemPacket; use pocketmine\network\mcpe\protocol\AddPaintingPacket; use pocketmine\network\mcpe\protocol\AddPlayerPacket; use pocketmine\network\mcpe\protocol\AdventureSettingsPacket; @@ -36,6 +35,7 @@ use pocketmine\network\mcpe\protocol\AvailableCommandsPacket; use pocketmine\network\mcpe\protocol\BlockEntityDataPacket; use pocketmine\network\mcpe\protocol\BlockEventPacket; use pocketmine\network\mcpe\protocol\BlockPickRequestPacket; +use pocketmine\network\mcpe\protocol\BookEditPacket; use pocketmine\network\mcpe\protocol\BossEventPacket; use pocketmine\network\mcpe\protocol\CameraPacket; use pocketmine\network\mcpe\protocol\ChangeDimensionPacket; @@ -43,26 +43,28 @@ use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket; use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket; use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket; use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket; -use pocketmine\network\mcpe\protocol\CommandStepPacket; +use pocketmine\network\mcpe\protocol\CommandOutputPacket; +use pocketmine\network\mcpe\protocol\CommandRequestPacket; use pocketmine\network\mcpe\protocol\ContainerClosePacket; use pocketmine\network\mcpe\protocol\ContainerOpenPacket; -use pocketmine\network\mcpe\protocol\ContainerSetContentPacket; use pocketmine\network\mcpe\protocol\ContainerSetDataPacket; -use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket; use pocketmine\network\mcpe\protocol\CraftingDataPacket; use pocketmine\network\mcpe\protocol\CraftingEventPacket; use pocketmine\network\mcpe\protocol\DataPacket; use pocketmine\network\mcpe\protocol\DisconnectPacket; -use pocketmine\network\mcpe\protocol\DropItemPacket; use pocketmine\network\mcpe\protocol\EntityEventPacket; use pocketmine\network\mcpe\protocol\EntityFallPacket; +use pocketmine\network\mcpe\protocol\EntityPickRequestPacket; use pocketmine\network\mcpe\protocol\EventPacket; use pocketmine\network\mcpe\protocol\ExplodePacket; use pocketmine\network\mcpe\protocol\FullChunkDataPacket; use pocketmine\network\mcpe\protocol\GameRulesChangedPacket; +use pocketmine\network\mcpe\protocol\GuiDataPickItemPacket; use pocketmine\network\mcpe\protocol\HurtArmorPacket; use pocketmine\network\mcpe\protocol\InteractPacket; -use pocketmine\network\mcpe\protocol\InventoryActionPacket; +use pocketmine\network\mcpe\protocol\InventoryContentPacket; +use pocketmine\network\mcpe\protocol\InventorySlotPacket; +use pocketmine\network\mcpe\protocol\InventoryTransactionPacket; use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; @@ -71,17 +73,21 @@ use pocketmine\network\mcpe\protocol\MapInfoRequestPacket; use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket; use pocketmine\network\mcpe\protocol\MobEffectPacket; use pocketmine\network\mcpe\protocol\MobEquipmentPacket; +use pocketmine\network\mcpe\protocol\ModalFormRequestPacket; +use pocketmine\network\mcpe\protocol\ModalFormResponsePacket; use pocketmine\network\mcpe\protocol\MoveEntityPacket; use pocketmine\network\mcpe\protocol\MovePlayerPacket; +use pocketmine\network\mcpe\protocol\NpcRequestPacket; +use pocketmine\network\mcpe\protocol\PhotoTransferPacket; use pocketmine\network\mcpe\protocol\PlaySoundPacket; use pocketmine\network\mcpe\protocol\PlayStatusPacket; use pocketmine\network\mcpe\protocol\PlayerActionPacket; +use pocketmine\network\mcpe\protocol\PlayerHotbarPacket; use pocketmine\network\mcpe\protocol\PlayerInputPacket; use pocketmine\network\mcpe\protocol\PlayerListPacket; +use pocketmine\network\mcpe\protocol\PlayerSkinPacket; use pocketmine\network\mcpe\protocol\PurchaseReceiptPacket; -use pocketmine\network\mcpe\protocol\RemoveBlockPacket; use pocketmine\network\mcpe\protocol\RemoveEntityPacket; -use pocketmine\network\mcpe\protocol\ReplaceItemInSlotPacket; use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket; use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket; use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket; @@ -91,6 +97,8 @@ use pocketmine\network\mcpe\protocol\ResourcePackStackPacket; use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket; use pocketmine\network\mcpe\protocol\RespawnPacket; use pocketmine\network\mcpe\protocol\RiderJumpPacket; +use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket; +use pocketmine\network\mcpe\protocol\ServerSettingsResponsePacket; use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket; use pocketmine\network\mcpe\protocol\SetCommandsEnabledPacket; use pocketmine\network\mcpe\protocol\SetDifficultyPacket; @@ -98,6 +106,7 @@ use pocketmine\network\mcpe\protocol\SetEntityDataPacket; use pocketmine\network\mcpe\protocol\SetEntityLinkPacket; use pocketmine\network\mcpe\protocol\SetEntityMotionPacket; use pocketmine\network\mcpe\protocol\SetHealthPacket; +use pocketmine\network\mcpe\protocol\SetLastHurtByPacket; use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket; use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket; use pocketmine\network\mcpe\protocol\SetTimePacket; @@ -109,6 +118,7 @@ use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket; use pocketmine\network\mcpe\protocol\StartGamePacket; use pocketmine\network\mcpe\protocol\StopSoundPacket; use pocketmine\network\mcpe\protocol\StructureBlockUpdatePacket; +use pocketmine\network\mcpe\protocol\SubClientLoginPacket; use pocketmine\network\mcpe\protocol\TakeItemEntityPacket; use pocketmine\network\mcpe\protocol\TextPacket; use pocketmine\network\mcpe\protocol\TransferPacket; @@ -116,7 +126,7 @@ use pocketmine\network\mcpe\protocol\UpdateAttributesPacket; use pocketmine\network\mcpe\protocol\UpdateBlockPacket; use pocketmine\network\mcpe\protocol\UpdateEquipPacket; use pocketmine\network\mcpe\protocol\UpdateTradePacket; -use pocketmine\network\mcpe\protocol\UseItemPacket; +use pocketmine\network\mcpe\protocol\WSConnectPacket; abstract class NetworkSession{ @@ -202,10 +212,6 @@ abstract class NetworkSession{ return false; } - public function handleRemoveBlock(RemoveBlockPacket $packet) : bool{ - return false; - } - public function handleUpdateBlock(UpdateBlockPacket $packet) : bool{ return false; } @@ -242,6 +248,10 @@ abstract class NetworkSession{ return false; } + public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool{ + return false; + } + public function handleMobEquipment(MobEquipmentPacket $packet) : bool{ return false; } @@ -258,7 +268,7 @@ abstract class NetworkSession{ return false; } - public function handleUseItem(UseItemPacket $packet) : bool{ + public function handleEntityPickRequest(EntityPickRequestPacket $packet) : bool{ return false; } @@ -302,14 +312,6 @@ abstract class NetworkSession{ return false; } - public function handleDropItem(DropItemPacket $packet) : bool{ - return false; - } - - public function handleInventoryAction(InventoryActionPacket $packet) : bool{ - return false; - } - public function handleContainerOpen(ContainerOpenPacket $packet) : bool{ return false; } @@ -318,7 +320,15 @@ abstract class NetworkSession{ return false; } - public function handleContainerSetSlot(ContainerSetSlotPacket $packet) : bool{ + public function handlePlayerHotbar(PlayerHotbarPacket $packet) : bool{ + return false; + } + + public function handleInventoryContent(InventoryContentPacket $packet) : bool{ + return false; + } + + public function handleInventorySlot(InventorySlotPacket $packet) : bool{ return false; } @@ -326,10 +336,6 @@ abstract class NetworkSession{ return false; } - public function handleContainerSetContent(ContainerSetContentPacket $packet) : bool{ - return false; - } - public function handleCraftingData(CraftingDataPacket $packet) : bool{ return false; } @@ -338,6 +344,10 @@ abstract class NetworkSession{ return false; } + public function handleGuiDataPickItem(GuiDataPickItemPacket $packet) : bool{ + return false; + } + public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{ return false; } @@ -406,10 +416,6 @@ abstract class NetworkSession{ return false; } - public function handleReplaceItemInSlot(ReplaceItemInSlotPacket $packet) : bool{ - return false; - } - public function handleGameRulesChanged(GameRulesChangedPacket $packet) : bool{ return false; } @@ -418,10 +424,6 @@ abstract class NetworkSession{ return false; } - public function handleAddItem(AddItemPacket $packet) : bool{ - return false; - } - public function handleBossEvent(BossEventPacket $packet) : bool{ return false; } @@ -434,7 +436,7 @@ abstract class NetworkSession{ return false; } - public function handleCommandStep(CommandStepPacket $packet) : bool{ + public function handleCommandRequest(CommandRequestPacket $packet) : bool{ return false; } @@ -442,6 +444,10 @@ abstract class NetworkSession{ return false; } + public function handleCommandOutput(CommandOutputPacket $packet) : bool{ + return false; + } + public function handleUpdateTrade(UpdateTradePacket $packet) : bool{ return false; } @@ -494,4 +500,48 @@ abstract class NetworkSession{ return false; } + public function handlePlayerSkin(PlayerSkinPacket $packet) : bool{ + return false; + } + + public function handleSubClientLogin(SubClientLoginPacket $packet) : bool{ + return false; + } + + public function handleWSConnect(WSConnectPacket $packet) : bool{ + return false; + } + + public function handleSetLastHurtBy(SetLastHurtByPacket $packet) : bool{ + return false; + } + + public function handleBookEdit(BookEditPacket $packet) : bool{ + return false; + } + + public function handleNpcRequest(NpcRequestPacket $packet) : bool{ + return false; + } + + public function handlePhotoTransfer(PhotoTransferPacket $packet) : bool{ + return false; + } + + public function handleModalFormRequest(ModalFormRequestPacket $packet) : bool{ + return false; + } + + public function handleModalFormResponse(ModalFormResponsePacket $packet) : bool{ + return false; + } + + public function handleServerSettingsRequest(ServerSettingsRequestPacket $packet) : bool{ + return false; + } + + public function handleServerSettingsResponse(ServerSettingsResponsePacket $packet) : bool{ + return false; + } + } \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php b/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php index 9fff1a75f..a16b78236 100644 --- a/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php +++ b/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php @@ -33,7 +33,7 @@ use pocketmine\network\mcpe\protocol\BlockPickRequestPacket; use pocketmine\network\mcpe\protocol\BossEventPacket; use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket; use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket; -use pocketmine\network\mcpe\protocol\CommandStepPacket; +use pocketmine\network\mcpe\protocol\CommandRequestPacket; use pocketmine\network\mcpe\protocol\ContainerClosePacket; use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket; use pocketmine\network\mcpe\protocol\CraftingEventPacket; @@ -51,6 +51,7 @@ use pocketmine\network\mcpe\protocol\MobEquipmentPacket; use pocketmine\network\mcpe\protocol\MovePlayerPacket; use pocketmine\network\mcpe\protocol\PlayerActionPacket; use pocketmine\network\mcpe\protocol\PlayerInputPacket; +use pocketmine\network\mcpe\protocol\PlayerSkinPacket; use pocketmine\network\mcpe\protocol\RemoveBlockPacket; use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket; use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket; @@ -76,11 +77,6 @@ class PlayerNetworkSessionAdapter extends NetworkSession{ } public function handleDataPacket(DataPacket $packet){ - //TODO: Remove this hack once InteractPacket spam issue is fixed - if($packet->buffer === "\x21\x04\x00"){ - return; - } - $timings = Timings::getReceiveDataPacketTimings($packet); $timings->startTiming(); @@ -111,13 +107,23 @@ class PlayerNetworkSessionAdapter extends NetworkSession{ } public function handleText(TextPacket $packet) : bool{ - return $this->player->handleText($packet); + if($packet->type === TextPacket::TYPE_CHAT){ + return $this->player->chat($packet->message); + } + + return false; } public function handleMovePlayer(MovePlayerPacket $packet) : bool{ return $this->player->handleMovePlayer($packet); } + /** + * TODO: REMOVE + * @param RemoveBlockPacket $packet + * + * @return bool + */ public function handleRemoveBlock(RemoveBlockPacket $packet) : bool{ return $this->player->handleRemoveBlock($packet); } @@ -146,6 +152,12 @@ class PlayerNetworkSessionAdapter extends NetworkSession{ return $this->player->handleBlockPickRequest($packet); } + /** + * TODO: REMOVE + * @param UseItemPacket $packet + * + * @return bool + */ public function handleUseItem(UseItemPacket $packet) : bool{ return $this->player->handleUseItem($packet); } @@ -162,6 +174,12 @@ class PlayerNetworkSessionAdapter extends NetworkSession{ return $this->player->handleAnimate($packet); } + /** + * TODO: REMOVE + * @param DropItemPacket $packet + * + * @return bool + */ public function handleDropItem(DropItemPacket $packet) : bool{ return $this->player->handleDropItem($packet); } @@ -170,6 +188,12 @@ class PlayerNetworkSessionAdapter extends NetworkSession{ return $this->player->handleContainerClose($packet); } + /** + * TODO: REMOVE + * @param ContainerSetSlotPacket $packet + * + * @return bool + */ public function handleContainerSetSlot(ContainerSetSlotPacket $packet) : bool{ return $this->player->handleContainerSetSlot($packet); } @@ -218,8 +242,8 @@ class PlayerNetworkSessionAdapter extends NetworkSession{ return $this->player->handleShowCredits($packet); } - public function handleCommandStep(CommandStepPacket $packet) : bool{ - return $this->player->handleCommandStep($packet); + public function handleCommandRequest(CommandRequestPacket $packet) : bool{ + return $this->player->chat($packet->command); } public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool{ @@ -229,4 +253,8 @@ class PlayerNetworkSessionAdapter extends NetworkSession{ public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{ return $this->player->handleResourcePackChunkRequest($packet); } + + public function handlePlayerSkin(PlayerSkinPacket $packet) : bool{ + return false; //TODO + } } \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php b/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php index 705d612e9..d29ff2796 100644 --- a/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php @@ -79,9 +79,7 @@ class AddEntityPacket extends DataPacket{ $this->metadata = $this->getEntityMetadata(); $linkCount = $this->getUnsignedVarInt(); for($i = 0; $i < $linkCount; ++$i){ - $this->links[$i][0] = $this->getEntityUniqueId(); - $this->links[$i][1] = $this->getEntityUniqueId(); - $this->links[$i][2] = $this->getByte(); + $this->links[] = $this->getEntityLink(); } } @@ -105,9 +103,7 @@ class AddEntityPacket extends DataPacket{ $this->putEntityMetadata($this->metadata); $this->putUnsignedVarInt(count($this->links)); foreach($this->links as $link){ - $this->putEntityUniqueId($link[0]); - $this->putEntityUniqueId($link[1]); - $this->putByte($link[2]); + $this->putEntityLink($link); } } diff --git a/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php b/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php index b1e8af929..38c39d88e 100644 --- a/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php @@ -53,6 +53,13 @@ class AddPlayerPacket extends DataPacket{ public $item; public $metadata = []; + //TODO + public $uvarint1 = 0; + public $uvarint2 = 0; + public $uvarint3 = 0; + public $uvarint4 = 0; + public $long1 = 0; + public function decodePayload(){ $this->uuid = $this->getUUID(); $this->username = $this->getString(); @@ -65,6 +72,12 @@ class AddPlayerPacket extends DataPacket{ $this->yaw = $this->getLFloat(); $this->item = $this->getSlot(); $this->metadata = $this->getEntityMetadata(); + + $this->uvarint1 = $this->getUnsignedVarInt(); + $this->uvarint2 = $this->getUnsignedVarInt(); + $this->uvarint3 = $this->getUnsignedVarInt(); + $this->uvarint4 = $this->getUnsignedVarInt(); + $this->long1 = $this->getLLong(); } public function encodePayload(){ @@ -79,6 +92,12 @@ class AddPlayerPacket extends DataPacket{ $this->putLFloat($this->yaw); $this->putSlot($this->item); $this->putEntityMetadata($this->metadata); + + $this->putUnsignedVarInt($this->uvarint1); + $this->putUnsignedVarInt($this->uvarint2); + $this->putUnsignedVarInt($this->uvarint3); + $this->putUnsignedVarInt($this->uvarint4); + $this->putLLong($this->long1); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php b/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php index 839023311..8e37f8fa7 100644 --- a/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php @@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\NetworkSession; +use pocketmine\network\mcpe\protocol\types\PlayerPermissions; class AdventureSettingsPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::ADVENTURE_SETTINGS_PACKET; @@ -37,53 +38,75 @@ class AdventureSettingsPacket extends DataPacket{ const PERMISSION_AUTOMATION = 3; const PERMISSION_ADMIN = 4; - public $worldImmutable = false; - public $noPvp = false; - public $noPvm = false; - public $noMvp = false; + //TODO: check level 3 - public $autoJump = true; - public $allowFlight = false; - public $noClip = false; - public $worldBuilder = false; - public $isFlying = false; - public $muted = false; + /** + * This constant is used to identify flags that should be set on the second field. In a sensible world, these + * flags would all be set on the same packet field, but as of MCPE 1.2, the new abilities flags have for some + * reason been assigned a separate field. + */ + const BITFLAG_SECOND_SET = 1 << 16; + + const WORLD_IMMUTABLE = 0x01; + const NO_PVP = 0x02; + + const AUTO_JUMP = 0x20; + const ALLOW_FLIGHT = 0x40; + const NO_CLIP = 0x80; + const WORLD_BUILDER = 0x100; + const FLYING = 0x200; + const MUTED = 0x400; + + const BUILD_AND_MINE = 0x01 | self::BITFLAG_SECOND_SET; + const DOORS_AND_SWITCHES = 0x02 | self::BITFLAG_SECOND_SET; + const OPEN_CONTAINERS = 0x04 | self::BITFLAG_SECOND_SET; + const ATTACK_PLAYERS = 0x08 | self::BITFLAG_SECOND_SET; + const ATTACK_MOBS = 0x10 | self::BITFLAG_SECOND_SET; + const OPERATOR = 0x20 | self::BITFLAG_SECOND_SET; + const TELEPORT = 0x80 | self::BITFLAG_SECOND_SET; public $flags = 0; - public $userPermission; + public $commandPermission = self::PERMISSION_NORMAL; + public $flags2 = -1; + public $playerPermission = PlayerPermissions::MEMBER; + public $long1 = 0; public function decodePayload(){ $this->flags = $this->getUnsignedVarInt(); - $this->userPermission = $this->getUnsignedVarInt(); - - $this->worldImmutable = (bool) ($this->flags & 1); - $this->noPvp = (bool) ($this->flags & (1 << 1)); - $this->noPvm = (bool) ($this->flags & (1 << 2)); - $this->noMvp = (bool) ($this->flags & (1 << 3)); - - $this->autoJump = (bool) ($this->flags & (1 << 5)); - $this->allowFlight = (bool) ($this->flags & (1 << 6)); - $this->noClip = (bool) ($this->flags & (1 << 7)); - $this->worldBuilder = (bool) ($this->flags & (1 << 8)); - $this->isFlying = (bool) ($this->flags & (1 << 9)); - $this->muted = (bool) ($this->flags & (1 << 10)); + $this->commandPermission = $this->getUnsignedVarInt(); + $this->flags2 = $this->getUnsignedVarInt(); + $this->playerPermission = $this->getUnsignedVarInt(); + $this->long1 = $this->getLLong(); } public function encodePayload(){ - $this->flags |= ((int) $this->worldImmutable); - $this->flags |= ((int) $this->noPvp) << 1; - $this->flags |= ((int) $this->noPvm) << 2; - $this->flags |= ((int) $this->noMvp) << 3; - - $this->flags |= ((int) $this->autoJump) << 5; - $this->flags |= ((int) $this->allowFlight) << 6; - $this->flags |= ((int) $this->noClip) << 7; - $this->flags |= ((int) $this->worldBuilder) << 8; - $this->flags |= ((int) $this->isFlying) << 9; - $this->flags |= ((int) $this->muted) << 10; - $this->putUnsignedVarInt($this->flags); - $this->putUnsignedVarInt($this->userPermission); + $this->putUnsignedVarInt($this->commandPermission); + $this->putUnsignedVarInt($this->flags2); + $this->putUnsignedVarInt($this->playerPermission); + $this->putLLong($this->long1); + } + + public function getFlag(int $flag) : bool{ + if($flag & self::BITFLAG_SECOND_SET){ + return ($this->flags2 & $flag) !== 0; + } + + return ($this->flags & $flag) !== 0; + } + + public function setFlag(int $flag, bool $value){ + if($flag & self::BITFLAG_SECOND_SET){ + $flagSet =& $this->flags2; + }else{ + $flagSet =& $this->flags; + } + + if($value){ + $flagSet |= $flag; + }else{ + $flagSet &= ~$flag; + } } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/BatchPacket.php b/src/pocketmine/network/mcpe/protocol/BatchPacket.php index 5ffa247cb..8834ffac5 100644 --- a/src/pocketmine/network/mcpe/protocol/BatchPacket.php +++ b/src/pocketmine/network/mcpe/protocol/BatchPacket.php @@ -48,6 +48,22 @@ class BatchPacket extends DataPacket{ return true; } + public function decode(){ + $this->offset = 1; + $this->decodePayload(); + } + + public function encode(){ + $this->reset(); + $this->encodePayload(); + $this->isEncoded = true; + } + + public function reset(){ + $this->buffer = "\xfe"; + $this->offset = 0; + } + public function decodePayload(){ $data = $this->getRemaining(); try{ diff --git a/src/pocketmine/network/mcpe/protocol/BlockPickRequestPacket.php b/src/pocketmine/network/mcpe/protocol/BlockPickRequestPacket.php index e748e6437..0f67a9212 100644 --- a/src/pocketmine/network/mcpe/protocol/BlockPickRequestPacket.php +++ b/src/pocketmine/network/mcpe/protocol/BlockPickRequestPacket.php @@ -35,15 +35,18 @@ class BlockPickRequestPacket extends DataPacket{ public $tileX; public $tileY; public $tileZ; + public $addUserData = false; public $hotbarSlot; public function decodePayload(){ $this->getSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ); + $this->addUserData = $this->getBool(); $this->hotbarSlot = $this->getByte(); } public function encodePayload(){ $this->putSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ); + $this->putBool($this->addUserData); $this->putByte($this->hotbarSlot); } diff --git a/src/pocketmine/network/mcpe/protocol/BookEditPacket.php b/src/pocketmine/network/mcpe/protocol/BookEditPacket.php new file mode 100644 index 000000000..cc03fb802 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/BookEditPacket.php @@ -0,0 +1,115 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class BookEditPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::BOOK_EDIT_PACKET; + + const TYPE_REPLACE_PAGE = 0; + const TYPE_ADD_PAGE = 1; + const TYPE_DELETE_PAGE = 2; + const TYPE_SWAP_PAGES = 3; + const TYPE_SIGN_BOOK = 4; + + /** @var int */ + public $type; + /** @var int */ + public $inventorySlot; + /** @var int */ + public $pageNumber; + /** @var int */ + public $secondaryPageNumber; + + /** @var string */ + public $content1; + /** @var string */ + public $content2; + + /** @var string */ + public $title; + /** @var string */ + public $author; + + public function decodePayload(){ + $this->type = $this->getByte(); + $this->inventorySlot = $this->getByte(); + + switch($this->type){ + case self::TYPE_REPLACE_PAGE: + case self::TYPE_ADD_PAGE: + $this->pageNumber = $this->getByte(); + $this->content1 = $this->getString(); + $this->content2 = $this->getString(); + break; + case self::TYPE_DELETE_PAGE: + $this->pageNumber = $this->getByte(); + break; + case self::TYPE_SWAP_PAGES: + $this->pageNumber = $this->getByte(); + $this->secondaryPageNumber = $this->getByte(); + break; + case self::TYPE_SIGN_BOOK: + $this->title = $this->getString(); + $this->author = $this->getString(); + break; + default: + throw new \UnexpectedValueException("Unknown book edit type $this->type!"); + } + } + + public function encodePayload(){ + $this->putByte($this->type); + $this->putByte($this->inventorySlot); + + switch($this->type){ + case self::TYPE_REPLACE_PAGE: + case self::TYPE_ADD_PAGE: + $this->putByte($this->pageNumber); + $this->putString($this->content1); + $this->putString($this->content2); + break; + case self::TYPE_DELETE_PAGE: + $this->putByte($this->pageNumber); + break; + case self::TYPE_SWAP_PAGES: + $this->putByte($this->pageNumber); + $this->putByte($this->secondaryPageNumber); + break; + case self::TYPE_SIGN_BOOK: + $this->putString($this->title); + $this->putString($this->author); + break; + default: + throw new \UnexpectedValueException("Unknown book edit type $this->type!"); + } + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleBookEdit($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/AddItemPacket.php b/src/pocketmine/network/mcpe/protocol/CommandOutputPacket.php similarity index 82% rename from src/pocketmine/network/mcpe/protocol/AddItemPacket.php rename to src/pocketmine/network/mcpe/protocol/CommandOutputPacket.php index 30d3cdd38..c84a14220 100644 --- a/src/pocketmine/network/mcpe/protocol/AddItemPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CommandOutputPacket.php @@ -25,24 +25,20 @@ namespace pocketmine\network\mcpe\protocol; #include - use pocketmine\network\mcpe\NetworkSession; -class AddItemPacket extends DataPacket{ - const NETWORK_ID = ProtocolInfo::ADD_ITEM_PACKET; - - public $item; +class CommandOutputPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::COMMAND_OUTPUT_PACKET; public function decodePayload(){ - $this->item = $this->getSlot(); + //TODO } public function encodePayload(){ - $this->putSlot($this->item); + //TODO } public function handle(NetworkSession $session) : bool{ - return $session->handleAddItem($this); + return $session->handleCommandOutput($this); } - } \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/CommandStepPacket.php b/src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php similarity index 51% rename from src/pocketmine/network/mcpe/protocol/CommandStepPacket.php rename to src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php index 7f80464b2..6ff311e74 100644 --- a/src/pocketmine/network/mcpe/protocol/CommandStepPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php @@ -27,46 +27,22 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\NetworkSession; -class CommandStepPacket extends DataPacket{ - const NETWORK_ID = ProtocolInfo::COMMAND_STEP_PACKET; +class CommandRequestPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::COMMAND_REQUEST_PACKET; public $command; - public $overload; - public $uvarint1; - public $currentStep; - public $done; - public $clientId; - public $inputJson; - public $outputJson; public function decodePayload(){ $this->command = $this->getString(); - $this->overload = $this->getString(); - $this->uvarint1 = $this->getUnsignedVarInt(); - $this->currentStep = $this->getUnsignedVarInt(); - $this->done = $this->getBool(); - $this->clientId = $this->getUnsignedVarLong(); - $this->inputJson = json_decode($this->getString()); - $this->outputJson = json_decode($this->getString()); - - $this->getRemaining(); //TODO: read command origin data + //TODO: everything else } public function encodePayload(){ $this->putString($this->command); - $this->putString($this->overload); - $this->putUnsignedVarInt($this->uvarint1); - $this->putUnsignedVarInt($this->currentStep); - $this->putBool($this->done); - $this->putUnsignedVarLong($this->clientId); - $this->putString(json_encode($this->inputJson)); - $this->putString(json_encode($this->outputJson)); - - $this->put("\x00\x00\x00"); //TODO: command origin data + //TODO } public function handle(NetworkSession $session) : bool{ - return $session->handleCommandStep($this); + return $session->handleCommandRequest($this); } - } \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/ContainerSetSlotPacket.php b/src/pocketmine/network/mcpe/protocol/ContainerSetSlotPacket.php index 105f690c7..c94d4c7a9 100644 --- a/src/pocketmine/network/mcpe/protocol/ContainerSetSlotPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ContainerSetSlotPacket.php @@ -28,6 +28,9 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\item\Item; use pocketmine\network\mcpe\NetworkSession; +/** + * @removed + */ class ContainerSetSlotPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::CONTAINER_SET_SLOT_PACKET; diff --git a/src/pocketmine/network/mcpe/protocol/DataPacket.php b/src/pocketmine/network/mcpe/protocol/DataPacket.php index dd70a4e90..6d0cf38ce 100644 --- a/src/pocketmine/network/mcpe/protocol/DataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DataPacket.php @@ -29,6 +29,7 @@ use pocketmine\entity\Attribute; use pocketmine\entity\Entity; use pocketmine\item\Item; use pocketmine\network\mcpe\NetworkSession; +use pocketmine\utils\Binary; use pocketmine\utils\BinaryStream; use pocketmine\utils\Utils; @@ -56,7 +57,7 @@ abstract class DataPacket extends BinaryStream{ } public function decode(){ - $this->offset = 1; + $this->offset = 3; $this->decodePayload(); } @@ -69,6 +70,7 @@ abstract class DataPacket extends BinaryStream{ public function encode(){ $this->reset(); + $this->put("\x00\x00"); $this->encodePayload(); $this->isEncoded = true; } @@ -93,7 +95,7 @@ abstract class DataPacket extends BinaryStream{ abstract public function handle(NetworkSession $session) : bool; public function reset(){ - $this->buffer = chr($this::NETWORK_ID); + $this->buffer = Binary::writeUnsignedVarInt(static::NETWORK_ID); $this->offset = 0; } @@ -440,4 +442,22 @@ abstract class DataPacket extends BinaryStream{ } } } + + /** + * @return array + */ + protected function getEntityLink() : array{ + return [$this->getEntityUniqueId(), $this->getEntityUniqueId(), $this->getByte(), $this->getByte()]; + } + + /** + * @param array $link + */ + protected function putEntityLink(array $link){ + $this->putEntityUniqueId($link[0]); + $this->putEntityUniqueId($link[1]); + $this->putByte($link[2]); + $this->putByte($link[3]); + + } } diff --git a/src/pocketmine/network/mcpe/protocol/DropItemPacket.php b/src/pocketmine/network/mcpe/protocol/DropItemPacket.php index 462830139..72b81e5a3 100644 --- a/src/pocketmine/network/mcpe/protocol/DropItemPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DropItemPacket.php @@ -29,6 +29,9 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\item\Item; use pocketmine\network\mcpe\NetworkSession; +/** + * @removed + */ class DropItemPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::DROP_ITEM_PACKET; diff --git a/src/pocketmine/network/mcpe/protocol/EntityPickRequestPacket.php b/src/pocketmine/network/mcpe/protocol/EntityPickRequestPacket.php new file mode 100644 index 000000000..f3a497018 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/EntityPickRequestPacket.php @@ -0,0 +1,49 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class EntityPickRequestPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::ENTITY_PICK_REQUEST_PACKET; + + public $entityTypeId; + public $hotbarSlot; + + public function decodePayload(){ + $this->entityTypeId = $this->getLLong(); + $this->hotbarSlot = $this->getByte(); + } + + public function encodePayload(){ + $this->putLLong($this->entityTypeId); + $this->putByte($this->hotbarSlot); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleEntityPickRequest($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/GuiDataPickItemPacket.php b/src/pocketmine/network/mcpe/protocol/GuiDataPickItemPacket.php new file mode 100644 index 000000000..e8491b92d --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/GuiDataPickItemPacket.php @@ -0,0 +1,47 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class GuiDataPickItemPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::GUI_DATA_PICK_ITEM_PACKET; + + /** @var int */ + public $hotbarSlot; + + public function decodePayload(){ + $this->hotbarSlot = $this->getLInt(); + } + + public function encodePayload(){ + $this->putLInt($this->hotbarSlot); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleGuiDataPickItem($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/InteractPacket.php b/src/pocketmine/network/mcpe/protocol/InteractPacket.php index 357cd8518..bdd553035 100644 --- a/src/pocketmine/network/mcpe/protocol/InteractPacket.php +++ b/src/pocketmine/network/mcpe/protocol/InteractPacket.php @@ -38,17 +38,38 @@ class InteractPacket extends DataPacket{ const ACTION_OPEN_INVENTORY = 6; + /** @var int */ public $action; + /** @var int */ public $target; + /** @var float */ + public $x; + /** @var float */ + public $y; + /** @var float */ + public $z; + public function decodePayload(){ $this->action = $this->getByte(); $this->target = $this->getEntityRuntimeId(); + + if($this->action === self::ACTION_MOUSEOVER){ + $this->x = $this->getLFloat(); + $this->y = $this->getLFloat(); + $this->z = $this->getLFloat(); + } } public function encodePayload(){ $this->putByte($this->action); $this->putEntityRuntimeId($this->target); + + if($this->action === self::ACTION_MOUSEOVER){ + $this->putLFloat($this->x); + $this->putLFloat($this->y); + $this->putLFloat($this->z); + } } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/InventoryContentPacket.php b/src/pocketmine/network/mcpe/protocol/InventoryContentPacket.php new file mode 100644 index 000000000..c29b14317 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/InventoryContentPacket.php @@ -0,0 +1,58 @@ + + +use pocketmine\item\Item; +use pocketmine\network\mcpe\NetworkSession; + +class InventoryContentPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::INVENTORY_CONTENT_PACKET; + + /** @var int */ + public $windowId; + /** @var Item[] */ + public $items = []; + + public function decodePayload(){ + $this->windowId = $this->getUnsignedVarInt(); + $count = $this->getUnsignedVarInt(); + for($i = 0; $i < $count; ++$i){ + $this->items[] = $this->getSlot(); + } + } + + public function encodePayload(){ + $this->putUnsignedVarInt($this->windowId); + $this->putUnsignedVarInt(count($this->items)); + foreach($this->items as $item){ + $this->putSlot($item); + } + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleInventoryContent($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/InventoryActionPacket.php b/src/pocketmine/network/mcpe/protocol/InventorySlotPacket.php similarity index 65% rename from src/pocketmine/network/mcpe/protocol/InventoryActionPacket.php rename to src/pocketmine/network/mcpe/protocol/InventorySlotPacket.php index 562b6fbbe..20c4476bc 100644 --- a/src/pocketmine/network/mcpe/protocol/InventoryActionPacket.php +++ b/src/pocketmine/network/mcpe/protocol/InventorySlotPacket.php @@ -25,34 +25,32 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\item\Item; use pocketmine\network\mcpe\NetworkSession; -class InventoryActionPacket extends DataPacket{ - const NETWORK_ID = ProtocolInfo::INVENTORY_ACTION_PACKET; +class InventorySlotPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::INVENTORY_SLOT_PACKET; - const ACTION_GIVE_ITEM = 0; - const ACTION_ENCHANT_ITEM = 2; - - public $actionId; + /** @var int */ + public $windowId; + /** @var int */ + public $slotIndex; + /** @var Item */ public $item; - public $enchantmentId = 0; - public $enchantmentLevel = 0; public function decodePayload(){ - $this->actionId = $this->getUnsignedVarInt(); + $this->windowId = $this->getUnsignedVarInt(); + $this->slotIndex = $this->getUnsignedVarInt(); $this->item = $this->getSlot(); - $this->enchantmentId = $this->getVarInt(); - $this->enchantmentLevel = $this->getVarInt(); } public function encodePayload(){ - $this->putUnsignedVarInt($this->actionId); + $this->putUnsignedVarInt($this->windowId); + $this->putUnsignedVarInt($this->slotIndex); $this->putSlot($this->item); - $this->putVarInt($this->enchantmentId); - $this->putVarInt($this->enchantmentLevel); } public function handle(NetworkSession $session) : bool{ - return $session->handleInventoryAction($this); + return $session->handleInventorySlot($this); } } \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket.php b/src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket.php new file mode 100644 index 000000000..f85237cbe --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket.php @@ -0,0 +1,53 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class InventoryTransactionPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::INVENTORY_TRANSACTION_PACKET; + + const TYPE_USE_ITEM = 2; + const TYPE_USE_ITEM_ON_ENTITY = 3; + const TYPE_RELEASE_ITEM = 4; + + + public function decodePayload(){ + $type = $this->getUnsignedVarInt(); + + + //TODO + } + + public function encodePayload(){ + + //TODO + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleInventoryTransaction($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket.php b/src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket.php index 190a1fe25..61b9606d1 100644 --- a/src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket.php @@ -33,111 +33,164 @@ class LevelSoundEventPacket extends DataPacket{ const SOUND_ITEM_USE_ON = 0; const SOUND_HIT = 1; const SOUND_STEP = 2; - const SOUND_JUMP = 3; - const SOUND_BREAK = 4; - const SOUND_PLACE = 5; - const SOUND_HEAVY_STEP = 6; - const SOUND_GALLOP = 7; - const SOUND_FALL = 8; - const SOUND_AMBIENT = 9; - const SOUND_AMBIENT_BABY = 10; - const SOUND_AMBIENT_IN_WATER = 11; - const SOUND_BREATHE = 12; - const SOUND_DEATH = 13; - const SOUND_DEATH_IN_WATER = 14; - const SOUND_DEATH_TO_ZOMBIE = 15; - const SOUND_HURT = 16; - const SOUND_HURT_IN_WATER = 17; - const SOUND_MAD = 18; - const SOUND_BOOST = 19; - const SOUND_BOW = 20; - const SOUND_SQUISH_BIG = 21; - const SOUND_SQUISH_SMALL = 22; - const SOUND_FALL_BIG = 23; - const SOUND_FALL_SMALL = 24; - const SOUND_SPLASH = 25; - const SOUND_FIZZ = 26; - const SOUND_FLAP = 27; - const SOUND_SWIM = 28; - const SOUND_DRINK = 29; - const SOUND_EAT = 30; - const SOUND_TAKEOFF = 31; - const SOUND_SHAKE = 32; - const SOUND_PLOP = 33; - const SOUND_LAND = 34; - const SOUND_SADDLE = 35; - const SOUND_ARMOR = 36; - const SOUND_ADD_CHEST = 37; - const SOUND_THROW = 38; - const SOUND_ATTACK = 39; - const SOUND_ATTACK_NODAMAGE = 40; - const SOUND_WARN = 41; - const SOUND_SHEAR = 42; - const SOUND_MILK = 43; - const SOUND_THUNDER = 44; - const SOUND_EXPLODE = 45; - const SOUND_FIRE = 46; - const SOUND_IGNITE = 47; - const SOUND_FUSE = 48; - const SOUND_STARE = 49; - const SOUND_SPAWN = 50; - const SOUND_SHOOT = 51; - const SOUND_BREAK_BLOCK = 52; - const SOUND_REMEDY = 53; - const SOUND_UNFECT = 54; - const SOUND_LEVELUP = 55; - const SOUND_BOW_HIT = 56; - const SOUND_BULLET_HIT = 57; - const SOUND_EXTINGUISH_FIRE = 58; - const SOUND_ITEM_FIZZ = 59; - const SOUND_CHEST_OPEN = 60; - const SOUND_CHEST_CLOSED = 61; - const SOUND_SHULKERBOX_OPEN = 62; - const SOUND_SHULKERBOX_CLOSED = 63; - const SOUND_POWER_ON = 64; - const SOUND_POWER_OFF = 65; - const SOUND_ATTACH = 66; - const SOUND_DETACH = 67; - const SOUND_DENY = 68; - const SOUND_TRIPOD = 69; - const SOUND_POP = 70; - const SOUND_DROP_SLOT = 71; - const SOUND_NOTE = 72; - const SOUND_THORNS = 73; - const SOUND_PISTON_IN = 74; - const SOUND_PISTON_OUT = 75; - const SOUND_PORTAL = 76; - const SOUND_WATER = 77; - const SOUND_LAVA_POP = 78; - const SOUND_LAVA = 79; - const SOUND_BURP = 80; - const SOUND_BUCKET_FILL_WATER = 81; - const SOUND_BUCKET_FILL_LAVA = 82; - const SOUND_BUCKET_EMPTY_WATER = 83; - const SOUND_BUCKET_EMPTY_LAVA = 84; - const SOUND_GUARDIAN_FLOP = 85; - const SOUND_ELDERGUARDIAN_CURSE = 86; - const SOUND_MOB_WARNING = 87; - const SOUND_MOB_WARNING_BABY = 88; - const SOUND_TELEPORT = 89; - const SOUND_SHULKER_OPEN = 90; - const SOUND_SHULKER_CLOSE = 91; - const SOUND_HAGGLE = 92; - const SOUND_HAGGLE_YES = 93; - const SOUND_HAGGLE_NO = 94; - const SOUND_HAGGLE_IDLE = 95; - const SOUND_CHORUSGROW = 96; - const SOUND_CHORUSDEATH = 97; - const SOUND_GLASS = 98; - const SOUND_CAST_SPELL = 99; - const SOUND_PREPARE_ATTACK = 100; - const SOUND_PREPARE_SUMMON = 101; - const SOUND_PREPARE_WOLOLO = 102; - const SOUND_FANG = 103; - const SOUND_CHARGE = 104; - const SOUND_CAMERA_TAKE_PICTURE = 105; - const SOUND_DEFAULT = 106; - const SOUND_UNDEFINED = 107; + const SOUND_FLY = 3; + const SOUND_JUMP = 4; + const SOUND_BREAK = 5; + const SOUND_PLACE = 6; + const SOUND_HEAVY_STEP = 7; + const SOUND_GALLOP = 8; + const SOUND_FALL = 9; + const SOUND_AMBIENT = 10; + const SOUND_AMBIENT_BABY = 11; + const SOUND_AMBIENT_IN_WATER = 12; + const SOUND_BREATHE = 13; + const SOUND_DEATH = 14; + const SOUND_DEATH_IN_WATER = 15; + const SOUND_DEATH_TO_ZOMBIE = 16; + const SOUND_HURT = 17; + const SOUND_HURT_IN_WATER = 18; + const SOUND_MAD = 19; + const SOUND_BOOST = 20; + const SOUND_BOW = 21; + const SOUND_SQUISH_BIG = 22; + const SOUND_SQUISH_SMALL = 23; + const SOUND_FALL_BIG = 24; + const SOUND_FALL_SMALL = 25; + const SOUND_SPLASH = 26; + const SOUND_FIZZ = 27; + const SOUND_FLAP = 28; + const SOUND_SWIM = 29; + const SOUND_DRINK = 30; + const SOUND_EAT = 31; + const SOUND_TAKEOFF = 32; + const SOUND_SHAKE = 33; + const SOUND_PLOP = 34; + const SOUND_LAND = 35; + const SOUND_SADDLE = 36; + const SOUND_ARMOR = 37; + const SOUND_ADD_CHEST = 38; + const SOUND_THROW = 39; + const SOUND_ATTACK = 40; + const SOUND_ATTACK_NODAMAGE = 41; + const SOUND_WARN = 42; + const SOUND_SHEAR = 43; + const SOUND_MILK = 44; + const SOUND_THUNDER = 45; + const SOUND_EXPLODE = 46; + const SOUND_FIRE = 47; + const SOUND_IGNITE = 48; + const SOUND_FUSE = 49; + const SOUND_STARE = 50; + const SOUND_SPAWN = 51; + const SOUND_SHOOT = 52; + const SOUND_BREAK_BLOCK = 53; + const SOUND_LAUNCH = 54; + const SOUND_BLAST = 55; + const SOUND_LARGE_BLAST = 56; + const SOUND_TWINKLE = 57; + const SOUND_REMEDY = 58; + const SOUND_UNFECT = 59; + const SOUND_LEVELUP = 60; + const SOUND_BOW_HIT = 61; + const SOUND_BULLET_HIT = 62; + const SOUND_EXTINGUISH_FIRE = 63; + const SOUND_ITEM_FIZZ = 64; + const SOUND_CHEST_OPEN = 65; + const SOUND_CHEST_CLOSED = 66; + const SOUND_SHULKERBOX_OPEN = 67; + const SOUND_SHULKERBOX_CLOSED = 68; + const SOUND_POWER_ON = 69; + const SOUND_POWER_OFF = 70; + const SOUND_ATTACH = 71; + const SOUND_DETACH = 72; + const SOUND_DENY = 73; + const SOUND_TRIPOD = 74; + const SOUND_POP = 75; + const SOUND_DROP_SLOT = 76; + const SOUND_NOTE = 77; + const SOUND_THORNS = 78; + const SOUND_PISTON_IN = 79; + const SOUND_PISTON_OUT = 80; + const SOUND_PORTAL = 81; + const SOUND_WATER = 82; + const SOUND_LAVA_POP = 83; + const SOUND_LAVA = 84; + const SOUND_BURP = 85; + const SOUND_BUCKET_FILL_WATER = 86; + const SOUND_BUCKET_FILL_LAVA = 87; + const SOUND_BUCKET_EMPTY_WATER = 88; + const SOUND_BUCKET_EMPTY_LAVA = 89; + const SOUND_RECORD_13 = 90; + const SOUND_RECORD_CAT = 91; + const SOUND_RECORD_BLOCKS = 92; + const SOUND_RECORD_CHIRP = 93; + const SOUND_RECORD_FAR = 94; + const SOUND_RECORD_MALL = 95; + const SOUND_RECORD_MELLOHI = 96; + const SOUND_RECORD_STAL = 97; + const SOUND_RECORD_STRAD = 98; + const SOUND_RECORD_WARD = 99; + const SOUND_RECORD_11 = 100; + const SOUND_RECORD_WAIT = 101; + const SOUND_GUARDIAN_FLOP = 103; + const SOUND_ELDERGUARDIAN_CURSE = 104; + const SOUND_MOB_WARNING = 105; + const SOUND_MOB_WARNING_BABY = 106; + const SOUND_TELEPORT = 107; + const SOUND_SHULKER_OPEN = 108; + const SOUND_SHULKER_CLOSE = 109; + const SOUND_HAGGLE = 110; + const SOUND_HAGGLE_YES = 111; + const SOUND_HAGGLE_NO = 112; + const SOUND_HAGGLE_IDLE = 113; + const SOUND_CHORUSGROW = 114; + const SOUND_CHORUSDEATH = 115; + const SOUND_GLASS = 116; + const SOUND_CAST_SPELL = 117; + const SOUND_PREPARE_ATTACK = 118; + const SOUND_PREPARE_SUMMON = 119; + const SOUND_PREPARE_WOLOLO = 120; + const SOUND_FANG = 121; + const SOUND_CHARGE = 122; + const SOUND_CAMERA_TAKE_PICTURE = 123; + const SOUND_LEASHKNOT_PLACE = 124; + const SOUND_LEASHKNOT_BREAK = 125; + const SOUND_GROWL = 126; + const SOUND_WHINE = 127; + const SOUND_PANT = 128; + const SOUND_PURR = 129; + const SOUND_PURREOW = 130; + const SOUND_DEATH_MIN_VOLUME = 131; + const SOUND_DEATH_MID_VOLUME = 132; + const SOUND_IMITATE_BLAZE = 133; + const SOUND_IMITATE_CAVE_SPIDER = 134; + const SOUND_IMITATE_CREEPER = 135; + const SOUND_IMITATE_ELDER_GUARDIAN = 136; + const SOUND_IMITATE_ENDER_DRAGON = 137; + const SOUND_IMITATE_ENDERMAN = 138; + const SOUND_IMITATE_EVOCATION_ILLAGER = 140; + const SOUND_IMITATE_GHAST = 141; + const SOUND_IMITATE_HUSK = 142; + const SOUND_IMITATE_ILLUSION_ILLAGER = 143; + const SOUND_IMITATE_MAGMA_CUBE = 144; + const SOUND_IMITATE_POLAR_BEAR = 145; + const SOUND_IMITATE_SHULKER = 146; + const SOUND_IMITATE_SILVERFISH = 147; + const SOUND_IMITATE_SKELETON = 148; + const SOUND_IMITATE_SLIME = 149; + const SOUND_IMITATE_SPIDER = 150; + const SOUND_IMITATE_STRAY = 151; + const SOUND_IMITATE_VEX = 152; + const SOUND_IMITATE_VINDICATION_ILLAGER = 153; + const SOUND_IMITATE_WITCH = 154; + const SOUND_IMITATE_WITHER = 155; + const SOUND_IMITATE_WITHER_SKELETON = 156; + const SOUND_IMITATE_WOLF = 157; + const SOUND_IMITATE_ZOMBIE = 158; + const SOUND_IMITATE_ZOMBIE_PIGMAN = 159; + const SOUND_IMITATE_ZOMBIE_VILLAGER = 160; + const SOUND_DEFAULT = 161; + const SOUND_UNDEFINED = 162; public $sound; public $x; diff --git a/src/pocketmine/network/mcpe/protocol/LoginPacket.php b/src/pocketmine/network/mcpe/protocol/LoginPacket.php index a92858edb..8cb24a59c 100644 --- a/src/pocketmine/network/mcpe/protocol/LoginPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LoginPacket.php @@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\NetworkSession; +use pocketmine\utils\Utils; class LoginPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::LOGIN_PACKET; @@ -35,7 +36,6 @@ class LoginPacket extends DataPacket{ public $username; public $protocol; - public $gameEdition; public $clientUUID; public $clientId; public $identityPublicKey; @@ -63,13 +63,11 @@ class LoginPacket extends DataPacket{ return; //Do not attempt to decode for non-accepted protocols } - $this->gameEdition = $this->getByte(); - $this->setBuffer($this->getString(), 0); $this->chainData = json_decode($this->get($this->getLInt()), true); foreach($this->chainData["chain"] as $chain){ - $webtoken = $this->decodeToken($chain); + $webtoken = Utils::decodeJWT($chain); if(isset($webtoken["extraData"])){ if(isset($webtoken["extraData"]["displayName"])){ $this->username = $webtoken["extraData"]["displayName"]; @@ -84,7 +82,7 @@ class LoginPacket extends DataPacket{ } $this->clientDataJwt = $this->get($this->getLInt()); - $this->clientData = $this->decodeToken($this->clientDataJwt); + $this->clientData = Utils::decodeJWT($this->clientDataJwt); $this->clientId = $this->clientData["ClientRandomId"] ?? null; $this->serverAddress = $this->clientData["ServerAddress"] ?? null; @@ -99,12 +97,6 @@ class LoginPacket extends DataPacket{ //TODO } - public function decodeToken($token){ - list($headB64, $payloadB64, $sigB64) = explode(".", $token); - - return json_decode(base64_decode($payloadB64), true); - } - public function handle(NetworkSession $session) : bool{ return $session->handleLogin($this); } diff --git a/src/pocketmine/network/mcpe/protocol/ModalFormRequestPacket.php b/src/pocketmine/network/mcpe/protocol/ModalFormRequestPacket.php new file mode 100644 index 000000000..fbe6cca35 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/ModalFormRequestPacket.php @@ -0,0 +1,49 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class ModalFormRequestPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::MODAL_FORM_REQUEST_PACKET; + + /** @var int */ + public $uvarint1; + /** @var string */ + public $string1; + + public function decodePayload(){ + //TODO + } + + public function encodePayload(){ + //TODO + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleModalFormRequest($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/ReplaceItemInSlotPacket.php b/src/pocketmine/network/mcpe/protocol/ModalFormResponsePacket.php similarity index 80% rename from src/pocketmine/network/mcpe/protocol/ReplaceItemInSlotPacket.php rename to src/pocketmine/network/mcpe/protocol/ModalFormResponsePacket.php index c255f8532..de32b9442 100644 --- a/src/pocketmine/network/mcpe/protocol/ReplaceItemInSlotPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ModalFormResponsePacket.php @@ -25,23 +25,20 @@ namespace pocketmine\network\mcpe\protocol; #include - use pocketmine\network\mcpe\NetworkSession; -class ReplaceItemInSlotPacket extends DataPacket{ - const NETWORK_ID = ProtocolInfo::REPLACE_ITEM_IN_SLOT_PACKET; - - public $item; +class ModalFormResponsePacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::MODAL_FORM_RESPONSE_PACKET; public function decodePayload(){ - $this->item = $this->getSlot(); + //TODO } public function encodePayload(){ - $this->putSlot($this->item); + //TODO } public function handle(NetworkSession $session) : bool{ - return $session->handleReplaceItemInSlot($this); + return $session->handleModalFormResponse($this); } } \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/NpcRequestPacket.php b/src/pocketmine/network/mcpe/protocol/NpcRequestPacket.php new file mode 100644 index 000000000..956c2db50 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/NpcRequestPacket.php @@ -0,0 +1,59 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class NpcRequestPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::NPC_REQUEST_PACKET; + + /** @var int */ + public $entityRuntimeId; + /** @var int */ + public $requestType; + /** @var string */ + public $commandString; + /** @var int */ + public $actionType; + + public function decodePayload(){ + $this->entityRuntimeId = $this->getEntityRuntimeId(); + $this->requestType = $this->getByte(); + $this->commandString = $this->getString(); + $this->actionType = $this->getByte(); + } + + public function encodePayload(){ + $this->putEntityRuntimeId($this->entityRuntimeId); + $this->putByte($this->requestType); + $this->putString($this->commandString); + $this->putByte($this->actionType); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleNpcRequest($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/PacketPool.php b/src/pocketmine/network/mcpe/protocol/PacketPool.php index 8cd7a99f3..78bf3013e 100644 --- a/src/pocketmine/network/mcpe/protocol/PacketPool.php +++ b/src/pocketmine/network/mcpe/protocol/PacketPool.php @@ -51,7 +51,6 @@ class PacketPool{ static::registerPacket(new MoveEntityPacket()); static::registerPacket(new MovePlayerPacket()); static::registerPacket(new RiderJumpPacket()); - static::registerPacket(new RemoveBlockPacket()); static::registerPacket(new UpdateBlockPacket()); static::registerPacket(new AddPaintingPacket()); static::registerPacket(new ExplodePacket()); @@ -61,11 +60,12 @@ class PacketPool{ static::registerPacket(new EntityEventPacket()); static::registerPacket(new MobEffectPacket()); static::registerPacket(new UpdateAttributesPacket()); + static::registerPacket(new InventoryTransactionPacket()); static::registerPacket(new MobEquipmentPacket()); static::registerPacket(new MobArmorEquipmentPacket()); static::registerPacket(new InteractPacket()); static::registerPacket(new BlockPickRequestPacket()); - static::registerPacket(new UseItemPacket()); + static::registerPacket(new EntityPickRequestPacket()); static::registerPacket(new PlayerActionPacket()); static::registerPacket(new EntityFallPacket()); static::registerPacket(new HurtArmorPacket()); @@ -76,15 +76,15 @@ class PacketPool{ static::registerPacket(new SetSpawnPositionPacket()); static::registerPacket(new AnimatePacket()); static::registerPacket(new RespawnPacket()); - static::registerPacket(new DropItemPacket()); - static::registerPacket(new InventoryActionPacket()); static::registerPacket(new ContainerOpenPacket()); static::registerPacket(new ContainerClosePacket()); - static::registerPacket(new ContainerSetSlotPacket()); + static::registerPacket(new PlayerHotbarPacket()); + static::registerPacket(new InventoryContentPacket()); + static::registerPacket(new InventorySlotPacket()); static::registerPacket(new ContainerSetDataPacket()); - static::registerPacket(new ContainerSetContentPacket()); static::registerPacket(new CraftingDataPacket()); static::registerPacket(new CraftingEventPacket()); + static::registerPacket(new GuiDataPickItemPacket()); static::registerPacket(new AdventureSettingsPacket()); static::registerPacket(new BlockEntityDataPacket()); static::registerPacket(new PlayerInputPacket()); @@ -102,15 +102,14 @@ class PacketPool{ static::registerPacket(new RequestChunkRadiusPacket()); static::registerPacket(new ChunkRadiusUpdatedPacket()); static::registerPacket(new ItemFrameDropItemPacket()); - static::registerPacket(new ReplaceItemInSlotPacket()); static::registerPacket(new GameRulesChangedPacket()); static::registerPacket(new CameraPacket()); - static::registerPacket(new AddItemPacket()); static::registerPacket(new BossEventPacket()); static::registerPacket(new ShowCreditsPacket()); static::registerPacket(new AvailableCommandsPacket()); - static::registerPacket(new CommandStepPacket()); + static::registerPacket(new CommandRequestPacket()); static::registerPacket(new CommandBlockUpdatePacket()); + static::registerPacket(new CommandOutputPacket()); static::registerPacket(new UpdateTradePacket()); static::registerPacket(new UpdateEquipPacket()); static::registerPacket(new ResourcePackDataInfoPacket()); @@ -124,6 +123,17 @@ class PacketPool{ static::registerPacket(new StructureBlockUpdatePacket()); static::registerPacket(new ShowStoreOfferPacket()); static::registerPacket(new PurchaseReceiptPacket()); + static::registerPacket(new PlayerSkinPacket()); + static::registerPacket(new SubClientLoginPacket()); + static::registerPacket(new WSConnectPacket()); + static::registerPacket(new SetLastHurtByPacket()); + static::registerPacket(new BookEditPacket()); + static::registerPacket(new NpcRequestPacket()); + static::registerPacket(new PhotoTransferPacket()); + static::registerPacket(new ModalFormRequestPacket()); + static::registerPacket(new ModalFormResponsePacket()); + static::registerPacket(new ServerSettingsRequestPacket()); + static::registerPacket(new ServerSettingsResponsePacket()); static::registerPacket(new BatchPacket()); } diff --git a/src/pocketmine/network/mcpe/protocol/PhotoTransferPacket.php b/src/pocketmine/network/mcpe/protocol/PhotoTransferPacket.php new file mode 100644 index 000000000..5d2f975e3 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/PhotoTransferPacket.php @@ -0,0 +1,55 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class PhotoTransferPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::PHOTO_TRANSFER_PACKET; + + /** @var string */ + public $string1; + /** @var string */ + public $string2; + /** @var string */ + public $string3; + + public function decodePayload(){ + $this->string1 = $this->getString(); + $this->string2 = $this->getString(); + $this->string3 = $this->getString(); + } + + public function encodePayload(){ + $this->putString($this->string1); + $this->putString($this->string2); + $this->putString($this->string3); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handlePhotoTransfer($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php index a98a50f6b..b1996132b 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php @@ -34,22 +34,25 @@ class PlayerActionPacket extends DataPacket{ const ACTION_START_BREAK = 0; const ACTION_ABORT_BREAK = 1; const ACTION_STOP_BREAK = 2; + const ACTION_GET_UPDATED_BLOCK = 3; + const ACTION_DROP_ITEM = 4; + const ACTION_STOP_SLEEPING = 5; + const ACTION_RESPAWN = 6; + const ACTION_JUMP = 7; + const ACTION_START_SPRINT = 8; + const ACTION_STOP_SPRINT = 9; + const ACTION_START_SNEAK = 10; + const ACTION_STOP_SNEAK = 11; + const ACTION_DIMENSION_CHANGE_REQUEST = 12; //sent when dying in different dimension + const ACTION_DIMENSION_CHANGE_ACK = 13; //sent when spawning in a different dimension to tell the server we spawned + const ACTION_START_GLIDE = 14; + const ACTION_STOP_GLIDE = 15; + const ACTION_BUILD_DENIED = 16; + const ACTION_CONTINUE_BREAK = 17; + const ACTION_SET_ENCHANTMENT_SEED = 19; - const ACTION_RELEASE_ITEM = 5; - const ACTION_STOP_SLEEPING = 6; - const ACTION_RESPAWN = 7; - const ACTION_JUMP = 8; - const ACTION_START_SPRINT = 9; - const ACTION_STOP_SPRINT = 10; - const ACTION_START_SNEAK = 11; - const ACTION_STOP_SNEAK = 12; - const ACTION_DIMENSION_CHANGE = 13; //TODO: correct these - - const ACTION_START_GLIDE = 15; - const ACTION_STOP_GLIDE = 16; - const ACTION_BUILD_DENIED = 17; - const ACTION_CONTINUE_BREAK = 18; + const ACTION_RELEASE_ITEM = 99999; //TODO REMOVE public $entityRuntimeId; public $action; diff --git a/src/pocketmine/network/mcpe/protocol/ContainerSetContentPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerHotbarPacket.php similarity index 52% rename from src/pocketmine/network/mcpe/protocol/ContainerSetContentPacket.php rename to src/pocketmine/network/mcpe/protocol/PlayerHotbarPacket.php index bb47539b7..df9a86e74 100644 --- a/src/pocketmine/network/mcpe/protocol/ContainerSetContentPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerHotbarPacket.php @@ -25,57 +25,38 @@ namespace pocketmine\network\mcpe\protocol; #include - use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\protocol\types\ContainerIds; -class ContainerSetContentPacket extends DataPacket{ - const NETWORK_ID = ProtocolInfo::CONTAINER_SET_CONTENT_PACKET; +class PlayerHotbarPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::PLAYER_HOTBAR_PACKET; - public $windowid; - public $targetEid; + /** @var int */ + public $selectedSlot; + /** @var int */ + public $windowId = ContainerIds::INVENTORY; + /** @var int[] */ public $slots = []; - public $hotbar = []; - - public function clean(){ - $this->slots = []; - $this->hotbar = []; - return parent::clean(); - } public function decodePayload(){ - $this->windowid = $this->getUnsignedVarInt(); - $this->targetEid = $this->getEntityUniqueId(); + $this->selectedSlot = $this->getUnsignedVarInt(); + $this->windowId = $this->getByte(); $count = $this->getUnsignedVarInt(); - for($s = 0; $s < $count and !$this->feof(); ++$s){ - $this->slots[$s] = $this->getSlot(); - } - - $hotbarCount = $this->getUnsignedVarInt(); //MCPE always sends this, even when it's not a player inventory - for($s = 0; $s < $hotbarCount and !$this->feof(); ++$s){ - $this->hotbar[$s] = $this->getVarInt(); + for($i = 0; $i < $count; ++$i){ + $this->slots[$i] = $this->getUnsignedVarInt(); } } public function encodePayload(){ - $this->putUnsignedVarInt($this->windowid); - $this->putEntityUniqueId($this->targetEid); + $this->putUnsignedVarInt($this->selectedSlot); + $this->putByte($this->windowId); $this->putUnsignedVarInt(count($this->slots)); foreach($this->slots as $slot){ - $this->putSlot($slot); - } - if($this->windowid === ContainerIds::INVENTORY and count($this->hotbar) > 0){ - $this->putUnsignedVarInt(count($this->hotbar)); - foreach($this->hotbar as $slot){ - $this->putVarInt($slot); - } - }else{ - $this->putUnsignedVarInt(0); + $this->putUnsignedVarInt($slot); } } public function handle(NetworkSession $session) : bool{ - return $session->handleContainerSetContent($this); + return $session->handlePlayerHotbar($this); } - } \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php index 1c46ef083..329f2a908 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php @@ -34,7 +34,7 @@ class PlayerListPacket extends DataPacket{ const TYPE_ADD = 0; const TYPE_REMOVE = 1; - //REMOVE: UUID, ADD: UUID, entity id, name, skinId, skin + //REMOVE: UUID, ADD: UUID, entity id, name, skinId, skin, geometric model, geometry data /** @var array[] */ public $entries = []; public $type; @@ -51,9 +51,12 @@ class PlayerListPacket extends DataPacket{ if($this->type === self::TYPE_ADD){ $this->entries[$i][0] = $this->getUUID(); $this->entries[$i][1] = $this->getEntityUniqueId(); - $this->entries[$i][2] = $this->getString(); - $this->entries[$i][3] = $this->getString(); - $this->entries[$i][4] = $this->getString(); + $this->entries[$i][2] = $this->getString(); //name + $this->entries[$i][3] = $this->getString(); //skin id + $this->entries[$i][4] = $this->getString(); //skin data + $this->entries[$i][5] = $this->getString(); //geometric model + $this->entries[$i][6] = $this->getString(); //geometry data (json) + $this->entries[$i][7] = $this->getString(); //??? }else{ $this->entries[$i][0] = $this->getUUID(); } @@ -67,9 +70,12 @@ class PlayerListPacket extends DataPacket{ if($this->type === self::TYPE_ADD){ $this->putUUID($d[0]); $this->putEntityUniqueId($d[1]); - $this->putString($d[2]); - $this->putString($d[3]); - $this->putString($d[4]); + $this->putString($d[2]); //name + $this->putString($d[3]); //skin id + $this->putString($d[4]); //skin data + $this->putString($d[5] ?? ""); //geometric model + $this->putString($d[6] ?? ""); //geometry data (json) + $this->putString($d[7] ?? ""); //??? }else{ $this->putUUID($d[0]); } diff --git a/src/pocketmine/network/mcpe/protocol/PlayerSkinPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerSkinPacket.php new file mode 100644 index 000000000..151910ab5 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/PlayerSkinPacket.php @@ -0,0 +1,73 @@ + + +use pocketmine\network\mcpe\NetworkSession; +use pocketmine\utils\UUID; + +class PlayerSkinPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::PLAYER_SKIN_PACKET; + + /** @var UUID */ + public $uuid; + /** @var string */ + public $skinId; + /** @var string */ + public $skinName; + /** @var string */ + public $serializeName; + /** @var string */ + public $skinData; + /** @var string */ + public $geometryModel; + /** @var string */ + public $geometryData; + + + public function decodePayload(){ + $this->uuid = $this->getUUID(); + $this->skinId = $this->getString(); + $this->skinName = $this->getString(); + $this->serializeName = $this->getString(); + $this->skinData = $this->getString(); + $this->geometryModel = $this->getString(); + $this->geometryData = $this->getString(); + } + + public function encodePayload(){ + $this->putUUID($this->uuid); + $this->putString($this->skinId); + $this->putString($this->skinName); + $this->putString($this->serializeName); + $this->putString($this->skinData); + $this->putString($this->geometryModel); + $this->putString($this->geometryData); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handlePlayerSkin($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php index e399bb864..bd9f06017 100644 --- a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php +++ b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php @@ -39,15 +39,15 @@ interface ProtocolInfo{ /** * Actual Minecraft: PE protocol version */ - const CURRENT_PROTOCOL = 113; + const CURRENT_PROTOCOL = 130; /** * Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */ - const MINECRAFT_VERSION = 'v1.1.0.55'; + const MINECRAFT_VERSION = 'v1.2.0.2 beta'; /** * Version number sent to clients in ping responses. */ - const MINECRAFT_VERSION_NETWORK = '1.1.0.55'; + const MINECRAFT_VERSION_NETWORK = '1.2.0.2'; const LOGIN_PACKET = 0x01; const PLAY_STATUS_PACKET = 0x02; @@ -69,21 +69,21 @@ interface ProtocolInfo{ const MOVE_ENTITY_PACKET = 0x12; const MOVE_PLAYER_PACKET = 0x13; const RIDER_JUMP_PACKET = 0x14; - const REMOVE_BLOCK_PACKET = 0x15; - const UPDATE_BLOCK_PACKET = 0x16; - const ADD_PAINTING_PACKET = 0x17; - const EXPLODE_PACKET = 0x18; - const LEVEL_SOUND_EVENT_PACKET = 0x19; - const LEVEL_EVENT_PACKET = 0x1a; - const BLOCK_EVENT_PACKET = 0x1b; - const ENTITY_EVENT_PACKET = 0x1c; - const MOB_EFFECT_PACKET = 0x1d; - const UPDATE_ATTRIBUTES_PACKET = 0x1e; + const UPDATE_BLOCK_PACKET = 0x15; + const ADD_PAINTING_PACKET = 0x16; + const EXPLODE_PACKET = 0x17; + const LEVEL_SOUND_EVENT_PACKET = 0x18; + const LEVEL_EVENT_PACKET = 0x19; + const BLOCK_EVENT_PACKET = 0x1a; + const ENTITY_EVENT_PACKET = 0x1b; + const MOB_EFFECT_PACKET = 0x1c; + const UPDATE_ATTRIBUTES_PACKET = 0x1d; + const INVENTORY_TRANSACTION_PACKET = 0x1e; const MOB_EQUIPMENT_PACKET = 0x1f; const MOB_ARMOR_EQUIPMENT_PACKET = 0x20; const INTERACT_PACKET = 0x21; const BLOCK_PICK_REQUEST_PACKET = 0x22; - const USE_ITEM_PACKET = 0x23; + const ENTITY_PICK_REQUEST_PACKET = 0x23; const PLAYER_ACTION_PACKET = 0x24; const ENTITY_FALL_PACKET = 0x25; const HURT_ARMOR_PACKET = 0x26; @@ -94,15 +94,15 @@ interface ProtocolInfo{ const SET_SPAWN_POSITION_PACKET = 0x2b; const ANIMATE_PACKET = 0x2c; const RESPAWN_PACKET = 0x2d; - const DROP_ITEM_PACKET = 0x2e; - const INVENTORY_ACTION_PACKET = 0x2f; - const CONTAINER_OPEN_PACKET = 0x30; - const CONTAINER_CLOSE_PACKET = 0x31; - const CONTAINER_SET_SLOT_PACKET = 0x32; + const CONTAINER_OPEN_PACKET = 0x2e; + const CONTAINER_CLOSE_PACKET = 0x2f; + const PLAYER_HOTBAR_PACKET = 0x30; + const INVENTORY_CONTENT_PACKET = 0x31; + const INVENTORY_SLOT_PACKET = 0x32; const CONTAINER_SET_DATA_PACKET = 0x33; - const CONTAINER_SET_CONTENT_PACKET = 0x34; - const CRAFTING_DATA_PACKET = 0x35; - const CRAFTING_EVENT_PACKET = 0x36; + const CRAFTING_DATA_PACKET = 0x34; + const CRAFTING_EVENT_PACKET = 0x35; + const GUI_DATA_PICK_ITEM_PACKET = 0x36; const ADVENTURE_SETTINGS_PACKET = 0x37; const BLOCK_ENTITY_DATA_PACKET = 0x38; const PLAYER_INPUT_PACKET = 0x39; @@ -120,27 +120,37 @@ interface ProtocolInfo{ const REQUEST_CHUNK_RADIUS_PACKET = 0x45; const CHUNK_RADIUS_UPDATED_PACKET = 0x46; const ITEM_FRAME_DROP_ITEM_PACKET = 0x47; - const REPLACE_ITEM_IN_SLOT_PACKET = 0x48; - const GAME_RULES_CHANGED_PACKET = 0x49; - const CAMERA_PACKET = 0x4a; - const ADD_ITEM_PACKET = 0x4b; - const BOSS_EVENT_PACKET = 0x4c; - const SHOW_CREDITS_PACKET = 0x4d; - const AVAILABLE_COMMANDS_PACKET = 0x4e; - const COMMAND_STEP_PACKET = 0x4f; - const COMMAND_BLOCK_UPDATE_PACKET = 0x50; - const UPDATE_TRADE_PACKET = 0x51; - const UPDATE_EQUIP_PACKET = 0x52; - const RESOURCE_PACK_DATA_INFO_PACKET = 0x53; - const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x54; - const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x55; - const TRANSFER_PACKET = 0x56; - const PLAY_SOUND_PACKET = 0x57; - const STOP_SOUND_PACKET = 0x58; - const SET_TITLE_PACKET = 0x59; - const ADD_BEHAVIOR_TREE_PACKET = 0x5a; - const STRUCTURE_BLOCK_UPDATE_PACKET = 0x5b; - const SHOW_STORE_OFFER_PACKET = 0x5c; - const PURCHASE_RECEIPT_PACKET = 0x5d; + const GAME_RULES_CHANGED_PACKET = 0x48; + const CAMERA_PACKET = 0x49; + const BOSS_EVENT_PACKET = 0x4a; + const SHOW_CREDITS_PACKET = 0x4b; + const AVAILABLE_COMMANDS_PACKET = 0x4c; + const COMMAND_REQUEST_PACKET = 0x4d; + const COMMAND_BLOCK_UPDATE_PACKET = 0x4e; + const COMMAND_OUTPUT_PACKET = 0x4f; + const UPDATE_TRADE_PACKET = 0x50; + const UPDATE_EQUIP_PACKET = 0x51; + const RESOURCE_PACK_DATA_INFO_PACKET = 0x52; + const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x53; + const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x54; + const TRANSFER_PACKET = 0x55; + const PLAY_SOUND_PACKET = 0x56; + const STOP_SOUND_PACKET = 0x57; + const SET_TITLE_PACKET = 0x58; + const ADD_BEHAVIOR_TREE_PACKET = 0x59; + const STRUCTURE_BLOCK_UPDATE_PACKET = 0x5a; + const SHOW_STORE_OFFER_PACKET = 0x5b; + const PURCHASE_RECEIPT_PACKET = 0x5c; + const PLAYER_SKIN_PACKET = 0x5d; + const SUB_CLIENT_LOGIN_PACKET = 0x5e; + const W_S_CONNECT_PACKET = 0x5f; + const SET_LAST_HURT_BY_PACKET = 0x60; + const BOOK_EDIT_PACKET = 0x61; + const NPC_REQUEST_PACKET = 0x62; + const PHOTO_TRANSFER_PACKET = 0x63; + const MODAL_FORM_REQUEST_PACKET = 0x64; + const MODAL_FORM_RESPONSE_PACKET = 0x65; + const SERVER_SETTINGS_REQUEST_PACKET = 0x66; + const SERVER_SETTINGS_RESPONSE_PACKET = 0x67; } diff --git a/src/pocketmine/network/mcpe/protocol/RemoveBlockPacket.php b/src/pocketmine/network/mcpe/protocol/RemoveBlockPacket.php index 1c9e10c98..363856d1d 100644 --- a/src/pocketmine/network/mcpe/protocol/RemoveBlockPacket.php +++ b/src/pocketmine/network/mcpe/protocol/RemoveBlockPacket.php @@ -28,6 +28,9 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\NetworkSession; +/** + * @removed + */ class RemoveBlockPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::REMOVE_BLOCK_PACKET; diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php index 9860c9343..4f1856fe0 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php @@ -65,12 +65,14 @@ class ResourcePackStackPacket extends DataPacket{ foreach($this->behaviorPackStack as $entry){ $this->putString($entry->getPackId()); $this->putString($entry->getPackVersion()); + $this->putString(""); //TODO } $this->putUnsignedVarInt(count($this->resourcePackStack)); foreach($this->resourcePackStack as $entry){ $this->putString($entry->getPackId()); $this->putString($entry->getPackVersion()); + $this->putString(""); //TODO } } diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php index e79d15b9f..d4ee594c7 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php @@ -69,6 +69,7 @@ class ResourcePacksInfoPacket extends DataPacket{ $this->putString($entry->getPackVersion()); $this->putLLong($entry->getPackSize()); $this->putString(""); //TODO + $this->putString(""); //TODO } $this->putLShort(count($this->resourcePackEntries)); foreach($this->resourcePackEntries as $entry){ @@ -76,6 +77,7 @@ class ResourcePacksInfoPacket extends DataPacket{ $this->putString($entry->getPackVersion()); $this->putLLong($entry->getPackSize()); $this->putString(""); //TODO + $this->putString(""); //TODO } } diff --git a/src/pocketmine/network/mcpe/protocol/ServerSettingsRequestPacket.php b/src/pocketmine/network/mcpe/protocol/ServerSettingsRequestPacket.php new file mode 100644 index 000000000..7e1c74e66 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/ServerSettingsRequestPacket.php @@ -0,0 +1,44 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class ServerSettingsRequestPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::SERVER_SETTINGS_REQUEST_PACKET; + + public function decodePayload(){ + //TODO + } + + public function encodePayload(){ + //TODO + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleServerSettingsRequest($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/ServerSettingsResponsePacket.php b/src/pocketmine/network/mcpe/protocol/ServerSettingsResponsePacket.php new file mode 100644 index 000000000..f0034320c --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/ServerSettingsResponsePacket.php @@ -0,0 +1,44 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class ServerSettingsResponsePacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::SERVER_SETTINGS_RESPONSE_PACKET; + + public function decodePayload(){ + //TODO + } + + public function encodePayload(){ + //TODO + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleServerSettingsResponse($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/ServerToClientHandshakePacket.php b/src/pocketmine/network/mcpe/protocol/ServerToClientHandshakePacket.php index e1d7b6bef..fc9657d89 100644 --- a/src/pocketmine/network/mcpe/protocol/ServerToClientHandshakePacket.php +++ b/src/pocketmine/network/mcpe/protocol/ServerToClientHandshakePacket.php @@ -31,21 +31,22 @@ use pocketmine\network\mcpe\NetworkSession; class ServerToClientHandshakePacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SERVER_TO_CLIENT_HANDSHAKE_PACKET; - public $publicKey; - public $serverToken; + /** + * @var string + * Server pubkey and token is contained in the JWT. + */ + public $jwt; public function canBeSentBeforeLogin() : bool{ return true; } public function decodePayload(){ - $this->publicKey = $this->getString(); - $this->serverToken = $this->getString(); + $this->jwt = $this->getString(); } public function encodePayload(){ - $this->putString($this->publicKey); - $this->putString($this->serverToken); + $this->putString($this->jwt); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket.php b/src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket.php index 0a846cbe4..f545ae3b9 100644 --- a/src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket.php @@ -31,20 +31,15 @@ use pocketmine\network\mcpe\NetworkSession; class SetEntityLinkPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SET_ENTITY_LINK_PACKET; - public $from; - public $to; - public $type; + /** @var array [from, to, type, unknown byte] */ + public $link = []; public function decodePayload(){ - $this->from = $this->getEntityUniqueId(); - $this->to = $this->getEntityUniqueId(); - $this->type = $this->getByte(); + $this->link = $this->getEntityLink(); } public function encodePayload(){ - $this->putEntityUniqueId($this->from); - $this->putEntityUniqueId($this->to); - $this->putByte($this->type); + $this->putEntityLink($this->link); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/SetLastHurtByPacket.php b/src/pocketmine/network/mcpe/protocol/SetLastHurtByPacket.php new file mode 100644 index 000000000..6304b9c5e --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/SetLastHurtByPacket.php @@ -0,0 +1,46 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class SetLastHurtByPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::SET_LAST_HURT_BY_PACKET; + + public $entityTypeId; + + public function decodePayload(){ + $this->entityTypeId = $this->getVarInt(); + } + + public function encodePayload(){ + $this->putVarInt($this->entityTypeId); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleSetLastHurtBy($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php index 6cbf1a9d0..2c48b144d 100644 --- a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php +++ b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php @@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\network\mcpe\NetworkSession; +use pocketmine\network\mcpe\protocol\types\PlayerPermissions; class StartGamePacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::START_GAME_PACKET; @@ -34,11 +35,14 @@ class StartGamePacket extends DataPacket{ public $entityUniqueId; public $entityRuntimeId; public $playerGamemode; + public $x; public $y; public $z; + public $pitch; public $yaw; + public $seed; public $dimension; public $generator = 1; //default infinite - 0 old, 1 infinite, 2 flat @@ -48,26 +52,40 @@ class StartGamePacket extends DataPacket{ public $spawnY; public $spawnZ; public $hasAchievementsDisabled = true; - public $dayCycleStopTime = -1; //-1 = not stopped, any positive value = stopped at that time + public $time = -1; public $eduMode = false; public $rainLevel; public $lightningLevel; + public $isMultiplayerGame = true; + public $hasLANBroadcast = true; + public $hasXboxLiveBroadcast = false; public $commandsEnabled; public $isTexturePacksRequired = true; public $gameRules = []; //TODO: implement this + public $hasBonusChestEnabled = false; + public $hasTrustPlayersEnabled = false; + public $defaultPlayerPermission = PlayerPermissions::MEMBER; //TODO + public $xboxLiveBroadcastMode = 0; //TODO: find values + public $levelId = ""; //base64 string, usually the same as world folder name in vanilla public $worldName; public $premiumWorldTemplateId = ""; public $unknownBool = false; public $currentTick = 0; + public $unknownVarInt = 0; + public function decodePayload(){ $this->entityUniqueId = $this->getEntityUniqueId(); $this->entityRuntimeId = $this->getEntityRuntimeId(); $this->playerGamemode = $this->getVarInt(); + $this->getVector3f($this->x, $this->y, $this->z); + $this->pitch = $this->getLFloat(); $this->yaw = $this->getLFloat(); + + //Level settings $this->seed = $this->getVarInt(); $this->dimension = $this->getVarInt(); $this->generator = $this->getVarInt(); @@ -75,28 +93,41 @@ class StartGamePacket extends DataPacket{ $this->difficulty = $this->getVarInt(); $this->getBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ); $this->hasAchievementsDisabled = $this->getBool(); - $this->dayCycleStopTime = $this->getVarInt(); + $this->time = $this->getVarInt(); $this->eduMode = $this->getBool(); $this->rainLevel = $this->getLFloat(); $this->lightningLevel = $this->getLFloat(); + $this->isMultiplayerGame = $this->getBool(); + $this->hasLANBroadcast = $this->getBool(); + $this->hasXboxLiveBroadcast = $this->getBool(); $this->commandsEnabled = $this->getBool(); $this->isTexturePacksRequired = $this->getBool(); $this->gameRules = $this->getGameRules(); + $this->hasBonusChestEnabled = $this->getBool(); + $this->hasTrustPlayersEnabled = $this->getBool(); + $this->defaultPlayerPermission = $this->getVarInt(); + $this->xboxLiveBroadcastMode = $this->getVarInt(); + $this->levelId = $this->getString(); $this->worldName = $this->getString(); $this->premiumWorldTemplateId = $this->getString(); $this->unknownBool = $this->getBool(); $this->currentTick = $this->getLLong(); + $this->unknownVarInt = $this->getVarInt(); } public function encodePayload(){ $this->putEntityUniqueId($this->entityUniqueId); $this->putEntityRuntimeId($this->entityRuntimeId); $this->putVarInt($this->playerGamemode); + $this->putVector3f($this->x, $this->y, $this->z); + $this->putLFloat($this->pitch); $this->putLFloat($this->yaw); + + //Level settings $this->putVarInt($this->seed); $this->putVarInt($this->dimension); $this->putVarInt($this->generator); @@ -104,18 +135,28 @@ class StartGamePacket extends DataPacket{ $this->putVarInt($this->difficulty); $this->putBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ); $this->putBool($this->hasAchievementsDisabled); - $this->putVarInt($this->dayCycleStopTime); + $this->putVarInt($this->time); $this->putBool($this->eduMode); $this->putLFloat($this->rainLevel); $this->putLFloat($this->lightningLevel); + $this->putBool($this->isMultiplayerGame); + $this->putBool($this->hasLANBroadcast); + $this->putBool($this->hasXboxLiveBroadcast); $this->putBool($this->commandsEnabled); $this->putBool($this->isTexturePacksRequired); $this->putGameRules($this->gameRules); + $this->putBool($this->hasBonusChestEnabled); + $this->putBool($this->hasTrustPlayersEnabled); + $this->putVarInt($this->defaultPlayerPermission); + $this->putVarInt($this->xboxLiveBroadcastMode); + $this->putString($this->levelId); $this->putString($this->worldName); $this->putString($this->premiumWorldTemplateId); $this->putBool($this->unknownBool); $this->putLLong($this->currentTick); + + $this->putVarInt($this->unknownVarInt); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/SubClientLoginPacket.php b/src/pocketmine/network/mcpe/protocol/SubClientLoginPacket.php new file mode 100644 index 000000000..eaf1ceacc --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/SubClientLoginPacket.php @@ -0,0 +1,44 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class SubClientLoginPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::SUB_CLIENT_LOGIN_PACKET; + + public function decodePayload(){ + //TODO + } + + public function encodePayload(){ + //TODO + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleSubClientLogin($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/TextPacket.php b/src/pocketmine/network/mcpe/protocol/TextPacket.php index 7e751853c..77bf36b36 100644 --- a/src/pocketmine/network/mcpe/protocol/TextPacket.php +++ b/src/pocketmine/network/mcpe/protocol/TextPacket.php @@ -41,12 +41,14 @@ class TextPacket extends DataPacket{ const TYPE_ANNOUNCEMENT = 7; public $type; + public $unknownBool = false; public $source; public $message; public $parameters = []; public function decodePayload(){ $this->type = $this->getByte(); + $this->unknownBool = $this->getBool(); switch($this->type){ case self::TYPE_POPUP: case self::TYPE_CHAT: @@ -71,6 +73,7 @@ class TextPacket extends DataPacket{ public function encodePayload(){ $this->putByte($this->type); + $this->putBool($this->unknownBool); switch($this->type){ case self::TYPE_POPUP: case self::TYPE_CHAT: diff --git a/src/pocketmine/network/mcpe/protocol/UseItemPacket.php b/src/pocketmine/network/mcpe/protocol/UseItemPacket.php index 2f8ff56fe..0fb674a27 100644 --- a/src/pocketmine/network/mcpe/protocol/UseItemPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UseItemPacket.php @@ -29,6 +29,9 @@ namespace pocketmine\network\mcpe\protocol; use pocketmine\item\Item; use pocketmine\network\mcpe\NetworkSession; +/** + * @removed + */ class UseItemPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::USE_ITEM_PACKET; diff --git a/src/pocketmine/network/mcpe/protocol/WSConnectPacket.php b/src/pocketmine/network/mcpe/protocol/WSConnectPacket.php new file mode 100644 index 000000000..fe8f1c16c --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/WSConnectPacket.php @@ -0,0 +1,47 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class WSConnectPacket extends DataPacket{ + const NETWORK_ID = ProtocolInfo::W_S_CONNECT_PACKET; + + /** @var string */ + public $string1; + + public function decodePayload(){ + $this->string1 = $this->getString(); + } + + public function encodePayload(){ + $this->putString($this->string1); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleWSConnect($this); + } +} \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/types/PlayerPermissions.php b/src/pocketmine/network/mcpe/protocol/types/PlayerPermissions.php new file mode 100644 index 000000000..f4e89a683 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/types/PlayerPermissions.php @@ -0,0 +1,32 @@ +