diff --git a/src/ProtocolInfo.php b/src/ProtocolInfo.php index afcfdf79..94cc1ad4 100644 --- a/src/ProtocolInfo.php +++ b/src/ProtocolInfo.php @@ -32,14 +32,15 @@ private function __construct(){ */ /** Actual Minecraft: PE protocol version */ - public const CURRENT_PROTOCOL = 662; + public const CURRENT_PROTOCOL = 671; /** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */ - public const MINECRAFT_VERSION = 'v1.20.70'; + public const MINECRAFT_VERSION = 'v1.20.80'; /** Version number sent to clients in ping responses. */ - public const MINECRAFT_VERSION_NETWORK = '1.20.70'; + public const MINECRAFT_VERSION_NETWORK = '1.20.80'; public const BASE_VERSION = '1.18.0'; + public const PROTOCOL_671 = 671; // 1.20.80 public const PROTOCOL_662 = 662; // 1.20.70 public const PROTOCOL_649 = 649; // 1.20.60 public const PROTOCOL_630 = 630; // 1.20.50 @@ -63,6 +64,7 @@ private function __construct(){ public const PROTOCOL_475 = 475; // v1.18.0 public const COMPATIBLE_PROTOCOL = [ + self::PROTOCOL_671, self::PROTOCOL_662, self::PROTOCOL_649, self::PROTOCOL_630, diff --git a/src/ResourcePackStackPacket.php b/src/ResourcePackStackPacket.php index 2bfbaf62..dc4a4a0e 100644 --- a/src/ResourcePackStackPacket.php +++ b/src/ResourcePackStackPacket.php @@ -29,19 +29,21 @@ class ResourcePackStackPacket extends DataPacket implements ClientboundPacket{ public bool $mustAccept = false; public string $baseGameVersion = ProtocolInfo::MINECRAFT_VERSION_NETWORK; public Experiments $experiments; + public bool $useVanillaEditorPacks = false; /** * @generate-create-func * @param ResourcePackStackEntry[] $resourcePackStack * @param ResourcePackStackEntry[] $behaviorPackStack */ - public static function create(array $resourcePackStack, array $behaviorPackStack, bool $mustAccept, string $baseGameVersion, Experiments $experiments) : self{ + public static function create(array $resourcePackStack, array $behaviorPackStack, bool $mustAccept, string $baseGameVersion, Experiments $experiments, bool $useVanillaEditorPacks = false) : self{ $result = new self; $result->resourcePackStack = $resourcePackStack; $result->behaviorPackStack = $behaviorPackStack; $result->mustAccept = $mustAccept; $result->baseGameVersion = $baseGameVersion; $result->experiments = $experiments; + $result->useVanillaEditorPacks = $useVanillaEditorPacks; return $result; } @@ -59,6 +61,9 @@ protected function decodePayload(PacketSerializer $in) : void{ $this->baseGameVersion = $in->getString(); $this->experiments = Experiments::read($in); + if($in->getProtocol() >= ProtocolInfo::PROTOCOL_671){ + $this->useVanillaEditorPacks = $in->getBool(); + } } protected function encodePayload(PacketSerializer $out) : void{ @@ -76,6 +81,9 @@ protected function encodePayload(PacketSerializer $out) : void{ $out->putString($this->baseGameVersion); $this->experiments->write($out); + if($out->getProtocol() >= ProtocolInfo::PROTOCOL_671){ + $out->putBool($this->useVanillaEditorPacks); + } } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/UpdatePlayerGameTypePacket.php b/src/UpdatePlayerGameTypePacket.php index c3b8928e..0b1b7073 100644 --- a/src/UpdatePlayerGameTypePacket.php +++ b/src/UpdatePlayerGameTypePacket.php @@ -23,14 +23,16 @@ class UpdatePlayerGameTypePacket extends DataPacket implements ClientboundPacket /** @see GameMode */ private int $gameMode; private int $playerActorUniqueId; + private int $tick = 0; /** * @generate-create-func */ - public static function create(int $gameMode, int $playerActorUniqueId) : self{ + public static function create(int $gameMode, int $playerActorUniqueId, int $tick = 0) : self{ $result = new self; $result->gameMode = $gameMode; $result->playerActorUniqueId = $playerActorUniqueId; + $result->tick = $tick; return $result; } @@ -38,14 +40,22 @@ public function getGameMode() : int{ return $this->gameMode; } public function getPlayerActorUniqueId() : int{ return $this->playerActorUniqueId; } + public function getTick(): int{ return $this->tick; } + protected function decodePayload(PacketSerializer $in) : void{ $this->gameMode = $in->getVarInt(); $this->playerActorUniqueId = $in->getActorUniqueId(); + if($in->getProtocol() >= ProtocolInfo::PROTOCOL_671){ + $this->tick = $in->getUnsignedVarInt(); + } } protected function encodePayload(PacketSerializer $out) : void{ $out->putVarInt($this->gameMode); $out->putActorUniqueId($this->playerActorUniqueId); + if($out->getProtocol() >= ProtocolInfo::PROTOCOL_671){ + $out->putUnsignedVarInt($this->tick); + } } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/types/LevelSettings.php b/src/types/LevelSettings.php index b916982f..49abed66 100644 --- a/src/types/LevelSettings.php +++ b/src/types/LevelSettings.php @@ -25,6 +25,7 @@ final class LevelSettings{ public SpawnSettings $spawnSettings; public int $generator = GeneratorType::OVERWORLD; public int $worldGamemode; + public bool $hardcore = false; public int $difficulty; public BlockPosition $spawnPosition; public bool $hasAchievementsDisabled = true; @@ -100,6 +101,9 @@ private function internalRead(PacketSerializer $in) : void{ $this->spawnSettings = SpawnSettings::read($in); $this->generator = $in->getVarInt(); $this->worldGamemode = $in->getVarInt(); + if($in->getProtocol() >= ProtocolInfo::PROTOCOL_671){ + $this->hardcore = $in->getBool(); + } $this->difficulty = $in->getVarInt(); $this->spawnPosition = $in->getBlockPosition(); $this->hasAchievementsDisabled = $in->getBool(); @@ -168,6 +172,9 @@ public function write(PacketSerializer $out) : void{ $this->spawnSettings->write($out); $out->putVarInt($this->generator); $out->putVarInt($this->worldGamemode); + if($out->getProtocol() >= ProtocolInfo::PROTOCOL_671){ + $out->putBool($this->hardcore); + } $out->putVarInt($this->difficulty); $out->putBlockPosition($this->spawnPosition); $out->putBool($this->hasAchievementsDisabled); diff --git a/src/types/recipe/ShapedRecipe.php b/src/types/recipe/ShapedRecipe.php index 4fe7a951..c14d5592 100644 --- a/src/types/recipe/ShapedRecipe.php +++ b/src/types/recipe/ShapedRecipe.php @@ -14,6 +14,7 @@ namespace pocketmine\network\mcpe\protocol\types\recipe; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; use pocketmine\network\mcpe\protocol\types\inventory\ItemStack; use Ramsey\Uuid\UuidInterface; @@ -34,7 +35,8 @@ public function __construct( private UuidInterface $uuid, string $blockType, //TODO: rename this private int $priority, - private int $recipeNetId + private int $recipeNetId, + private bool $symmetric = true, ){ parent::__construct($typeId); $rows = count($input); @@ -112,9 +114,10 @@ public static function decode(int $recipeType, PacketSerializer $in) : self{ $uuid = $in->getUUID(); $block = $in->getString(); $priority = $in->getVarInt(); + $symmetric = !($in->getProtocol() >= ProtocolInfo::PROTOCOL_671) || $in->getBool(); $recipeNetId = $in->readGenericTypeNetworkId(); - return new self($recipeType, $recipeId, $input, $output, $uuid, $block, $priority, $recipeNetId); + return new self($recipeType, $recipeId, $input, $output, $uuid, $block, $priority, $recipeNetId, $symmetric); } public function encode(PacketSerializer $out) : void{ @@ -135,6 +138,9 @@ public function encode(PacketSerializer $out) : void{ $out->putUUID($this->uuid); $out->putString($this->blockName); $out->putVarInt($this->priority); + if($out->getProtocol() >= ProtocolInfo::PROTOCOL_671){ + $out->putBool($this->symmetric); + } $out->writeGenericTypeNetworkId($this->recipeNetId); } }