Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol changes for 1.21.30 #270

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions src/CameraAimAssistPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/

declare(strict_types=1);

namespace pocketmine\network\mcpe\protocol;

use pocketmine\math\Vector2;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\camera\CameraAimAssistActionType;
use pocketmine\network\mcpe\protocol\types\camera\CameraAimAssistTargetMode;

class CameraAimAssistPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CAMERA_AIM_ASSIST_PACKET;

private Vector2 $viewAngle;
private float $distance;
private CameraAimAssistTargetMode $targetMode;
private CameraAimAssistActionType $actionType;

/**
* @generate-create-func
*/
public static function create(Vector2 $viewAngle, float $distance, CameraAimAssistTargetMode $targetMode, CameraAimAssistActionType $actionType) : self{
$result = new self;
$result->viewAngle = $viewAngle;
$result->distance = $distance;
$result->targetMode = $targetMode;
$result->actionType = $actionType;
return $result;
}

public function getViewAngle() : Vector2{ return $this->viewAngle; }

public function getDistance() : float{ return $this->distance; }

public function getTargetMode() : CameraAimAssistTargetMode{ return $this->targetMode; }

public function getActionType() : CameraAimAssistActionType{ return $this->actionType; }

protected function decodePayload(PacketSerializer $in) : void{
$this->viewAngle = $in->getVector2();
$this->distance = $in->getLFloat();
$this->targetMode = CameraAimAssistTargetMode::fromPacket($in->getByte());
$this->actionType = CameraAimAssistActionType::fromPacket($in->getByte());
}

protected function encodePayload(PacketSerializer $out) : void{
$out->putVector2($this->viewAngle);
$out->putLFloat($this->distance);
$out->putByte($this->targetMode->value);
$out->putByte($this->actionType->value);
}

public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleCameraAimAssist($this);
}
}
59 changes: 59 additions & 0 deletions src/ContainerRegistryCleanupPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/

declare(strict_types=1);

namespace pocketmine\network\mcpe\protocol;

use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\FullContainerName;
use function count;

class ContainerRegistryCleanupPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::CONTAINER_REGISTRY_CLEANUP_PACKET;

/** @var FullContainerName[] */
private array $removedContainers;

/**
* @generate-create-func
* @param FullContainerName[] $removedContainers
*/
public static function create(array $removedContainers) : self{
$result = new self;
$result->removedContainers = $removedContainers;
return $result;
}

/**
* @return FullContainerName[]
*/
public function getRemovedContainers() : array{ return $this->removedContainers; }

protected function decodePayload(PacketSerializer $in) : void{
$this->removedContainers = [];
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$this->removedContainers[] = FullContainerName::read($in);
}
}

protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt(count($this->removedContainers));
foreach($this->removedContainers as $container){
$container->write($out);
}
}

public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleContainerRegistryCleanup($this);
}
}
8 changes: 7 additions & 1 deletion src/EmotePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ class EmotePacket extends DataPacket implements ClientboundPacket, ServerboundPa

private int $actorRuntimeId;
private string $emoteId;
private int $emoteLengthTicks;
private string $xboxUserId;
private string $platformChatId;
private int $flags;

/**
* @generate-create-func
*/
public static function create(int $actorRuntimeId, string $emoteId, string $xboxUserId, string $platformChatId, int $flags) : self{
public static function create(int $actorRuntimeId, string $emoteId, int $emoteLengthTicks, string $xboxUserId, string $platformChatId, int $flags) : self{
$result = new self;
$result->actorRuntimeId = $actorRuntimeId;
$result->emoteId = $emoteId;
$result->emoteLengthTicks = $emoteLengthTicks;
$result->xboxUserId = $xboxUserId;
$result->platformChatId = $platformChatId;
$result->flags = $flags;
Expand All @@ -49,6 +51,8 @@ public function getEmoteId() : string{
return $this->emoteId;
}

public function getEmoteLengthTicks() : int{ return $this->emoteLengthTicks; }

public function getXboxUserId() : string{ return $this->xboxUserId; }

public function getPlatformChatId() : string{ return $this->platformChatId; }
Expand All @@ -60,6 +64,7 @@ public function getFlags() : int{
protected function decodePayload(PacketSerializer $in) : void{
$this->actorRuntimeId = $in->getActorRuntimeId();
$this->emoteId = $in->getString();
$this->emoteLengthTicks = $in->getUnsignedVarInt();
$this->xboxUserId = $in->getString();
$this->platformChatId = $in->getString();
$this->flags = $in->getByte();
Expand All @@ -68,6 +73,7 @@ protected function decodePayload(PacketSerializer $in) : void{
protected function encodePayload(PacketSerializer $out) : void{
$out->putActorRuntimeId($this->actorRuntimeId);
$out->putString($this->emoteId);
$out->putUnsignedVarInt($this->emoteLengthTicks);
$out->putString($this->xboxUserId);
$out->putString($this->platformChatId);
$out->putByte($this->flags);
Expand Down
15 changes: 10 additions & 5 deletions src/InventoryContentPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace pocketmine\network\mcpe\protocol;

use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\FullContainerName;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
use function count;

Expand All @@ -24,17 +25,19 @@ class InventoryContentPacket extends DataPacket implements ClientboundPacket{
public int $windowId;
/** @var ItemStackWrapper[] */
public array $items = [];
public int $dynamicContainerId;
public FullContainerName $containerName;
public int $dynamicContainerSize;

/**
* @generate-create-func
* @param ItemStackWrapper[] $items
*/
public static function create(int $windowId, array $items, int $dynamicContainerId) : self{
public static function create(int $windowId, array $items, FullContainerName $containerName, int $dynamicContainerSize) : self{
$result = new self;
$result->windowId = $windowId;
$result->items = $items;
$result->dynamicContainerId = $dynamicContainerId;
$result->containerName = $containerName;
$result->dynamicContainerSize = $dynamicContainerSize;
return $result;
}

Expand All @@ -44,7 +47,8 @@ protected function decodePayload(PacketSerializer $in) : void{
for($i = 0; $i < $count; ++$i){
$this->items[] = $in->getItemStackWrapper();
}
$this->dynamicContainerId = $in->getUnsignedVarInt();
$this->containerName = FullContainerName::read($in);
$this->dynamicContainerSize = $in->getUnsignedVarInt();
}

protected function encodePayload(PacketSerializer $out) : void{
Expand All @@ -53,7 +57,8 @@ protected function encodePayload(PacketSerializer $out) : void{
foreach($this->items as $item){
$out->putItemStackWrapper($item);
}
$out->putUnsignedVarInt($this->dynamicContainerId);
$this->containerName->write($out);
$out->putUnsignedVarInt($this->dynamicContainerSize);
}

public function handle(PacketHandlerInterface $handler) : bool{
Expand Down
15 changes: 10 additions & 5 deletions src/InventorySlotPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,44 @@
namespace pocketmine\network\mcpe\protocol;

use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\FullContainerName;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;

class InventorySlotPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::INVENTORY_SLOT_PACKET;

public int $windowId;
public int $inventorySlot;
public FullContainerName $containerName;
public int $dynamicContainerSize;
public ItemStackWrapper $item;
public int $dynamicContainerId;

/**
* @generate-create-func
*/
public static function create(int $windowId, int $inventorySlot, ItemStackWrapper $item, int $dynamicContainerId) : self{
public static function create(int $windowId, int $inventorySlot, FullContainerName $containerName, int $dynamicContainerSize, ItemStackWrapper $item) : self{
$result = new self;
$result->windowId = $windowId;
$result->inventorySlot = $inventorySlot;
$result->containerName = $containerName;
$result->dynamicContainerSize = $dynamicContainerSize;
$result->item = $item;
$result->dynamicContainerId = $dynamicContainerId;
return $result;
}

protected function decodePayload(PacketSerializer $in) : void{
$this->windowId = $in->getUnsignedVarInt();
$this->inventorySlot = $in->getUnsignedVarInt();
$this->dynamicContainerId = $in->getUnsignedVarInt();
$this->containerName = FullContainerName::read($in);
$this->dynamicContainerSize = $in->getUnsignedVarInt();
$this->item = $in->getItemStackWrapper();
}

protected function encodePayload(PacketSerializer $out) : void{
$out->putUnsignedVarInt($this->windowId);
$out->putUnsignedVarInt($this->inventorySlot);
$out->putUnsignedVarInt($this->dynamicContainerId);
$this->containerName->write($out);
$out->putUnsignedVarInt($this->dynamicContainerSize);
$out->putItemStackWrapper($this->item);
}

Expand Down
8 changes: 8 additions & 0 deletions src/PacketHandlerDefaultImplTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -821,4 +821,12 @@ public function handleCurrentStructureFeature(CurrentStructureFeaturePacket $pac
public function handleServerboundDiagnostics(ServerboundDiagnosticsPacket $packet) : bool{
return false;
}

public function handleCameraAimAssist(CameraAimAssistPacket $packet) : bool{
return false;
}

public function handleContainerRegistryCleanup(ContainerRegistryCleanupPacket $packet) : bool{
return false;
}
}
4 changes: 4 additions & 0 deletions src/PacketHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,8 @@ public function handleJigsawStructureData(JigsawStructureDataPacket $packet) : b
public function handleCurrentStructureFeature(CurrentStructureFeaturePacket $packet) : bool;

public function handleServerboundDiagnostics(ServerboundDiagnosticsPacket $packet) : bool;

public function handleCameraAimAssist(CameraAimAssistPacket $packet) : bool;

public function handleContainerRegistryCleanup(ContainerRegistryCleanupPacket $packet) : bool;
}
2 changes: 2 additions & 0 deletions src/PacketPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ public function __construct(){
$this->registerPacket(new JigsawStructureDataPacket());
$this->registerPacket(new CurrentStructureFeaturePacket());
$this->registerPacket(new ServerboundDiagnosticsPacket());
$this->registerPacket(new CameraAimAssistPacket());
$this->registerPacket(new ContainerRegistryCleanupPacket());
}

public function registerPacket(Packet $packet) : void{
Expand Down
8 changes: 5 additions & 3 deletions src/ProtocolInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ private function __construct(){
*/

/** Actual Minecraft: PE protocol version */
public const CURRENT_PROTOCOL = 712;
public const CURRENT_PROTOCOL = 729;
/** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */
public const MINECRAFT_VERSION = 'v1.21.20';
public const MINECRAFT_VERSION = 'v1.21.30';
/** Version number sent to clients in ping responses. */
public const MINECRAFT_VERSION_NETWORK = '1.21.20';
public const MINECRAFT_VERSION_NETWORK = '1.21.30';

public const LOGIN_PACKET = 0x01;
public const PLAY_STATUS_PACKET = 0x02;
Expand Down Expand Up @@ -251,4 +251,6 @@ private function __construct(){
public const JIGSAW_STRUCTURE_DATA_PACKET = 0x139;
public const CURRENT_STRUCTURE_FEATURE_PACKET = 0x13a;
public const SERVERBOUND_DIAGNOSTICS_PACKET = 0x13b;
public const CAMERA_AIM_ASSIST_PACKET = 0x13c;
public const CONTAINER_REGISTRY_CLEANUP_PACKET = 0x13d;
}
Loading