diff --git a/resources/vanilla b/resources/vanilla index 04c846c5f..21ec07f14 160000 --- a/resources/vanilla +++ b/resources/vanilla @@ -1 +1 @@ -Subproject commit 04c846c5f95a7bb9ae111f699f2ba08c9ec838aa +Subproject commit 21ec07f14e258d10475a714d77cbdcb7284745ec diff --git a/src/network/mcpe/handler/PacketHandler.php b/src/network/mcpe/handler/PacketHandler.php index b1f5d162b..156762467 100644 --- a/src/network/mcpe/handler/PacketHandler.php +++ b/src/network/mcpe/handler/PacketHandler.php @@ -109,6 +109,7 @@ use pocketmine\network\mcpe\protocol\MultiplayerSettingsPacket; use pocketmine\network\mcpe\protocol\NetworkChunkPublisherUpdatePacket; use pocketmine\network\mcpe\protocol\NetworkSettingsPacket; use pocketmine\network\mcpe\protocol\NetworkStackLatencyPacket; +use pocketmine\network\mcpe\protocol\NpcDialoguePacket; use pocketmine\network\mcpe\protocol\NpcRequestPacket; use pocketmine\network\mcpe\protocol\OnScreenTextureAnimationPacket; use pocketmine\network\mcpe\protocol\PacketHandlerInterface; @@ -166,6 +167,7 @@ use pocketmine\network\mcpe\protocol\ShowCreditsPacket; use pocketmine\network\mcpe\protocol\ShowProfilePacket; use pocketmine\network\mcpe\protocol\ShowStoreOfferPacket; use pocketmine\network\mcpe\protocol\SimpleEventPacket; +use pocketmine\network\mcpe\protocol\SimulationTypePacket; use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket; use pocketmine\network\mcpe\protocol\SpawnParticleEffectPacket; use pocketmine\network\mcpe\protocol\StartGamePacket; @@ -846,4 +848,12 @@ abstract class PacketHandler implements PacketHandlerInterface{ public function handleRemoveVolumeEntity(RemoveVolumeEntityPacket $packet) : bool{ return false; } + + public function handleSimulationType(SimulationTypePacket $packet) : bool{ + return false; + } + + public function handleNpcDialogue(NpcDialoguePacket $packet) : bool{ + return false; + } } diff --git a/src/network/mcpe/handler/ResourcePacksPacketHandler.php b/src/network/mcpe/handler/ResourcePacksPacketHandler.php index 125fea85b..23676b436 100644 --- a/src/network/mcpe/handler/ResourcePacksPacketHandler.php +++ b/src/network/mcpe/handler/ResourcePacksPacketHandler.php @@ -76,7 +76,8 @@ class ResourcePacksPacketHandler extends PacketHandler{ //TODO: more stuff return new ResourcePackInfoEntry($pack->getPackId(), $pack->getPackVersion(), $pack->getPackSize(), "", "", "", false); }, $this->resourcePackManager->getResourceStack()); - $this->session->sendDataPacket(ResourcePacksInfoPacket::create($resourcePackEntries, [], $this->resourcePackManager->resourcePacksRequired(), false)); + //TODO: support forcing server packs + $this->session->sendDataPacket(ResourcePacksInfoPacket::create($resourcePackEntries, [], $this->resourcePackManager->resourcePacksRequired(), false, false)); $this->session->getLogger()->debug("Waiting for client to accept resource packs"); } diff --git a/src/network/mcpe/protocol/AvailableCommandsPacket.php b/src/network/mcpe/protocol/AvailableCommandsPacket.php index f9ad2186c..4ad40a69f 100644 --- a/src/network/mcpe/protocol/AvailableCommandsPacket.php +++ b/src/network/mcpe/protocol/AvailableCommandsPacket.php @@ -288,7 +288,7 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ protected function getCommandData(array $enums, array $postfixes, PacketSerializer $in) : CommandData{ $name = $in->getString(); $description = $in->getString(); - $flags = $in->getByte(); + $flags = $in->getLShort(); $permission = $in->getByte(); $aliases = $enums[$in->getLInt()] ?? null; $overloads = []; @@ -332,7 +332,7 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{ protected function putCommandData(CommandData $data, array $enumIndexes, array $postfixIndexes, PacketSerializer $out) : void{ $out->putString($data->name); $out->putString($data->description); - $out->putByte($data->flags); + $out->putLShort($data->flags); $out->putByte($data->permission); if($data->aliases !== null){ diff --git a/src/network/mcpe/protocol/NpcDialoguePacket.php b/src/network/mcpe/protocol/NpcDialoguePacket.php new file mode 100644 index 000000000..87beb4915 --- /dev/null +++ b/src/network/mcpe/protocol/NpcDialoguePacket.php @@ -0,0 +1,87 @@ + + +use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; + +class NpcDialoguePacket extends DataPacket implements ClientboundPacket{ + public const NETWORK_ID = ProtocolInfo::NPC_DIALOGUE_PACKET; + + public const ACTION_OPEN = 0; + public const ACTION_CLOSE = 1; + + private int $npcActorUniqueId; + private int $actionType; + private string $dialogue; + private string $sceneName; + private string $npcName; + private string $actionJson; + + public static function create(int $npcActorUniqueId, int $actionType, string $dialogue, string $sceneName, string $npcName, string $actionJson) : self{ + $result = new self; + $result->npcActorUniqueId = $npcActorUniqueId; + $result->actionType = $actionType; + $result->dialogue = $dialogue; + $result->sceneName = $sceneName; + $result->npcName = $npcName; + $result->actionJson = $actionJson; + return $result; + } + + public function getNpcActorUniqueId() : int{ return $this->npcActorUniqueId; } + + public function getActionType() : int{ return $this->actionType; } + + public function getDialogue() : string{ return $this->dialogue; } + + public function getSceneName() : string{ return $this->sceneName; } + + public function getNpcName() : string{ return $this->npcName; } + + public function getActionJson() : string{ return $this->actionJson; } + + protected function decodePayload(PacketSerializer $in) : void{ + $this->npcActorUniqueId = $in->getEntityUniqueId(); + $this->actionType = $in->getVarInt(); + $this->dialogue = $in->getString(); + $this->sceneName = $in->getString(); + $this->npcName = $in->getString(); + $this->actionJson = $in->getString(); + } + + protected function encodePayload(PacketSerializer $out) : void{ + $out->putEntityUniqueId($this->npcActorUniqueId); + $out->putVarInt($this->actionType); + $out->putString($this->dialogue); + $out->putString($this->sceneName); + $out->putString($this->npcName); + $out->putString($this->actionJson); + } + + public function handle(PacketHandlerInterface $handler) : bool{ + return $handler->handleNpcDialogue($this); + } +} diff --git a/src/network/mcpe/protocol/NpcRequestPacket.php b/src/network/mcpe/protocol/NpcRequestPacket.php index fb007fce2..674bfb842 100644 --- a/src/network/mcpe/protocol/NpcRequestPacket.php +++ b/src/network/mcpe/protocol/NpcRequestPacket.php @@ -36,6 +36,7 @@ class NpcRequestPacket extends DataPacket implements ServerboundPacket{ public const REQUEST_SET_NAME = 3; public const REQUEST_SET_SKIN = 4; public const REQUEST_SET_INTERACTION_TEXT = 5; + public const REQUEST_EXECUTE_OPENING_COMMANDS = 6; /** @var int */ public $entityRuntimeId; @@ -45,12 +46,14 @@ class NpcRequestPacket extends DataPacket implements ServerboundPacket{ public $commandString; /** @var int */ public $actionType; + public string $sceneName; protected function decodePayload(PacketSerializer $in) : void{ $this->entityRuntimeId = $in->getEntityRuntimeId(); $this->requestType = $in->getByte(); $this->commandString = $in->getString(); $this->actionType = $in->getByte(); + $this->sceneName = $in->getString(); } protected function encodePayload(PacketSerializer $out) : void{ @@ -58,6 +61,7 @@ class NpcRequestPacket extends DataPacket implements ServerboundPacket{ $out->putByte($this->requestType); $out->putString($this->commandString); $out->putByte($this->actionType); + $out->putString($this->sceneName); } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/network/mcpe/protocol/PacketHandlerInterface.php b/src/network/mcpe/protocol/PacketHandlerInterface.php index 5a27d0a54..1dc610952 100644 --- a/src/network/mcpe/protocol/PacketHandlerInterface.php +++ b/src/network/mcpe/protocol/PacketHandlerInterface.php @@ -350,4 +350,8 @@ interface PacketHandlerInterface{ public function handleAddVolumeEntity(AddVolumeEntityPacket $packet) : bool; public function handleRemoveVolumeEntity(RemoveVolumeEntityPacket $packet) : bool; + + public function handleSimulationType(SimulationTypePacket $packet) : bool; + + public function handleNpcDialogue(NpcDialoguePacket $packet) : bool; } diff --git a/src/network/mcpe/protocol/PacketPool.php b/src/network/mcpe/protocol/PacketPool.php index b7d750079..2e456701c 100644 --- a/src/network/mcpe/protocol/PacketPool.php +++ b/src/network/mcpe/protocol/PacketPool.php @@ -205,6 +205,8 @@ class PacketPool{ $this->registerPacket(new SyncActorPropertyPacket()); $this->registerPacket(new AddVolumeEntityPacket()); $this->registerPacket(new RemoveVolumeEntityPacket()); + $this->registerPacket(new SimulationTypePacket()); + $this->registerPacket(new NpcDialoguePacket()); } public function registerPacket(Packet $packet) : void{ diff --git a/src/network/mcpe/protocol/ProtocolInfo.php b/src/network/mcpe/protocol/ProtocolInfo.php index c902b5214..9d5b94b2e 100644 --- a/src/network/mcpe/protocol/ProtocolInfo.php +++ b/src/network/mcpe/protocol/ProtocolInfo.php @@ -41,11 +41,11 @@ final class ProtocolInfo{ */ /** Actual Minecraft: PE protocol version */ - public const CURRENT_PROTOCOL = 440; + public const CURRENT_PROTOCOL = 448; /** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */ - public const MINECRAFT_VERSION = 'v1.17.0'; + public const MINECRAFT_VERSION = 'v1.17.10'; /** Version number sent to clients in ping responses. */ - public const MINECRAFT_VERSION_NETWORK = '1.17.0'; + public const MINECRAFT_VERSION_NETWORK = '1.17.10'; public const LOGIN_PACKET = 0x01; public const PLAY_STATUS_PACKET = 0x02; @@ -214,5 +214,7 @@ final class ProtocolInfo{ public const SYNC_ACTOR_PROPERTY_PACKET = 0xa5; public const ADD_VOLUME_ENTITY_PACKET = 0xa6; public const REMOVE_VOLUME_ENTITY_PACKET = 0xa7; + public const SIMULATION_TYPE_PACKET = 0xa8; + public const NPC_DIALOGUE_PACKET = 0xa9; } diff --git a/src/network/mcpe/protocol/ResourcePacksInfoPacket.php b/src/network/mcpe/protocol/ResourcePacksInfoPacket.php index ff7586bcb..20093d5d7 100644 --- a/src/network/mcpe/protocol/ResourcePacksInfoPacket.php +++ b/src/network/mcpe/protocol/ResourcePacksInfoPacket.php @@ -34,32 +34,37 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{ public const NETWORK_ID = ProtocolInfo::RESOURCE_PACKS_INFO_PACKET; /** @var bool */ - public $mustAccept = false; //if true, forces client to use selected resource packs + public $mustAccept = false; //if true, forces client to choose between accepting packs or being disconnected /** @var bool */ public $hasScripts = false; //if true, causes disconnect for any platform that doesn't support scripts yet + + public bool $forceServerPacks = false; /** @var BehaviorPackInfoEntry[] */ public $behaviorPackEntries = []; /** @var ResourcePackInfoEntry[] */ public $resourcePackEntries = []; /** + * @param bool $forceServerPacks * @param ResourcePackInfoEntry[] $resourcePacks * @param BehaviorPackInfoEntry[] $behaviorPacks * * @return ResourcePacksInfoPacket */ - public static function create(array $resourcePacks, array $behaviorPacks, bool $mustAccept, bool $hasScripts = false) : self{ + public static function create(array $resourcePacks, array $behaviorPacks, bool $mustAccept, bool $hasScripts, bool $forceServerPacks) : self{ $result = new self; $result->mustAccept = $mustAccept; $result->hasScripts = $hasScripts; $result->resourcePackEntries = $resourcePacks; $result->behaviorPackEntries = $behaviorPacks; + $result->forceServerPacks = $forceServerPacks; return $result; } protected function decodePayload(PacketSerializer $in) : void{ $this->mustAccept = $in->getBool(); $this->hasScripts = $in->getBool(); + $this->forceServerPacks = $in->getBool(); $behaviorPackCount = $in->getLShort(); while($behaviorPackCount-- > 0){ $this->behaviorPackEntries[] = BehaviorPackInfoEntry::read($in); @@ -74,6 +79,7 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{ protected function encodePayload(PacketSerializer $out) : void{ $out->putBool($this->mustAccept); $out->putBool($this->hasScripts); + $out->putBool($this->forceServerPacks); $out->putLShort(count($this->behaviorPackEntries)); foreach($this->behaviorPackEntries as $entry){ $entry->write($out); diff --git a/src/network/mcpe/protocol/SetTitlePacket.php b/src/network/mcpe/protocol/SetTitlePacket.php index 989b9e9c5..da5e6ced9 100644 --- a/src/network/mcpe/protocol/SetTitlePacket.php +++ b/src/network/mcpe/protocol/SetTitlePacket.php @@ -50,6 +50,8 @@ class SetTitlePacket extends DataPacket implements ClientboundPacket{ public $stayTime = 0; /** @var int */ public $fadeOutTime = 0; + public string $xuid = ""; + public string $platformOnlineId = ""; protected function decodePayload(PacketSerializer $in) : void{ $this->type = $in->getVarInt(); @@ -57,6 +59,8 @@ class SetTitlePacket extends DataPacket implements ClientboundPacket{ $this->fadeInTime = $in->getVarInt(); $this->stayTime = $in->getVarInt(); $this->fadeOutTime = $in->getVarInt(); + $this->xuid = $in->getString(); + $this->platformOnlineId = $in->getString(); } protected function encodePayload(PacketSerializer $out) : void{ @@ -65,6 +69,8 @@ class SetTitlePacket extends DataPacket implements ClientboundPacket{ $out->putVarInt($this->fadeInTime); $out->putVarInt($this->stayTime); $out->putVarInt($this->fadeOutTime); + $out->putString($this->xuid); + $out->putString($this->platformOnlineId); } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/network/mcpe/protocol/SimulationTypePacket.php b/src/network/mcpe/protocol/SimulationTypePacket.php new file mode 100644 index 000000000..28f662b63 --- /dev/null +++ b/src/network/mcpe/protocol/SimulationTypePacket.php @@ -0,0 +1,58 @@ + + +use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; + +class SimulationTypePacket extends DataPacket implements ClientboundPacket{ + public const NETWORK_ID = ProtocolInfo::SIMULATION_TYPE_PACKET; + + public const GAME = 0; + public const EDITOR = 1; + public const TEST = 2; + + private int $type; + + public static function create(int $type) : self{ + $result = new self; + $result->type = $type; + return $result; + } + + public function getType() : int{ return $this->type; } + + protected function decodePayload(PacketSerializer $in) : void{ + $this->type = $in->getByte(); + } + + protected function encodePayload(PacketSerializer $out) : void{ + $out->putByte($this->type); + } + + public function handle(PacketHandlerInterface $handler) : bool{ + return $handler->handleSimulationType($this); + } +} diff --git a/src/network/mcpe/protocol/types/PlayerAuthInputFlags.php b/src/network/mcpe/protocol/types/PlayerAuthInputFlags.php index 83104c88e..51d8557ca 100644 --- a/src/network/mcpe/protocol/types/PlayerAuthInputFlags.php +++ b/src/network/mcpe/protocol/types/PlayerAuthInputFlags.php @@ -56,8 +56,8 @@ final class PlayerAuthInputFlags{ public const WANT_DOWN_SLOW = 18; public const WANT_UP_SLOW = 19; public const SPRINTING = 20; - public const ASCEND_SCAFFOLDING = 21; - public const DESCEND_SCAFFOLDING = 22; + public const ASCEND_BLOCK = 21; + public const DESCEND_BLOCK = 22; public const SNEAK_TOGGLE_DOWN = 23; public const PERSIST_SNEAK = 24; public const START_SPRINTING = 25;