diff --git a/src/CraftingDataPacket.php b/src/CraftingDataPacket.php index f04a1c6b..93d812e8 100644 --- a/src/CraftingDataPacket.php +++ b/src/CraftingDataPacket.php @@ -36,7 +36,7 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{ public const ENTRY_FURNACE = 2; public const ENTRY_FURNACE_DATA = 3; public const ENTRY_MULTI = 4; - public const ENTRY_SHULKER_BOX = 5; + public const ENTRY_USER_DATA_SHAPELESS = 5; public const ENTRY_SHAPELESS_CHEMISTRY = 6; public const ENTRY_SHAPED_CHEMISTRY = 7; public const ENTRY_SMITHING_TRANSFORM = 8; @@ -76,7 +76,7 @@ protected function decodePayload(PacketSerializer $in) : void{ $recipeType = $in->getVarInt(); $this->recipesWithTypeIds[] = match($recipeType){ - self::ENTRY_SHAPELESS, self::ENTRY_SHULKER_BOX, self::ENTRY_SHAPELESS_CHEMISTRY => ShapelessRecipe::decode($recipeType, $in), + self::ENTRY_SHAPELESS, self::ENTRY_USER_DATA_SHAPELESS, self::ENTRY_SHAPELESS_CHEMISTRY => ShapelessRecipe::decode($recipeType, $in), self::ENTRY_SHAPED, self::ENTRY_SHAPED_CHEMISTRY => ShapedRecipe::decode($recipeType, $in), self::ENTRY_FURNACE, self::ENTRY_FURNACE_DATA => FurnaceRecipe::decode($recipeType, $in), self::ENTRY_MULTI => MultiRecipe::decode($recipeType, $in), diff --git a/src/InventoryContentPacket.php b/src/InventoryContentPacket.php index 1e7e5f64..6e42e260 100644 --- a/src/InventoryContentPacket.php +++ b/src/InventoryContentPacket.php @@ -26,18 +26,18 @@ class InventoryContentPacket extends DataPacket implements ClientboundPacket{ /** @var ItemStackWrapper[] */ public array $items = []; public FullContainerName $containerName; - public int $dynamicContainerSize; + public ItemStackWrapper $storage; /** * @generate-create-func * @param ItemStackWrapper[] $items */ - public static function create(int $windowId, array $items, FullContainerName $containerName, int $dynamicContainerSize) : self{ + public static function create(int $windowId, array $items, FullContainerName $containerName, ItemStackWrapper $storage) : self{ $result = new self; $result->windowId = $windowId; $result->items = $items; $result->containerName = $containerName; - $result->dynamicContainerSize = $dynamicContainerSize; + $result->storage = $storage; return $result; } @@ -48,7 +48,7 @@ protected function decodePayload(PacketSerializer $in) : void{ $this->items[] = $in->getItemStackWrapper(); } $this->containerName = FullContainerName::read($in); - $this->dynamicContainerSize = $in->getUnsignedVarInt(); + $this->storage = $in->getItemStackWrapper(); } protected function encodePayload(PacketSerializer $out) : void{ @@ -58,7 +58,7 @@ protected function encodePayload(PacketSerializer $out) : void{ $out->putItemStackWrapper($item); } $this->containerName->write($out); - $out->putUnsignedVarInt($this->dynamicContainerSize); + $out->putItemStackWrapper($this->storage); } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/InventorySlotPacket.php b/src/InventorySlotPacket.php index b98af415..c75627fb 100644 --- a/src/InventorySlotPacket.php +++ b/src/InventorySlotPacket.php @@ -24,18 +24,18 @@ class InventorySlotPacket extends DataPacket implements ClientboundPacket{ public int $windowId; public int $inventorySlot; public FullContainerName $containerName; - public int $dynamicContainerSize; + public ItemStackWrapper $storage; public ItemStackWrapper $item; /** * @generate-create-func */ - public static function create(int $windowId, int $inventorySlot, FullContainerName $containerName, int $dynamicContainerSize, ItemStackWrapper $item) : self{ + public static function create(int $windowId, int $inventorySlot, FullContainerName $containerName, ItemStackWrapper $storage, ItemStackWrapper $item) : self{ $result = new self; $result->windowId = $windowId; $result->inventorySlot = $inventorySlot; $result->containerName = $containerName; - $result->dynamicContainerSize = $dynamicContainerSize; + $result->storage = $storage; $result->item = $item; return $result; } @@ -44,7 +44,7 @@ protected function decodePayload(PacketSerializer $in) : void{ $this->windowId = $in->getUnsignedVarInt(); $this->inventorySlot = $in->getUnsignedVarInt(); $this->containerName = FullContainerName::read($in); - $this->dynamicContainerSize = $in->getUnsignedVarInt(); + $this->storage = $in->getItemStackWrapper(); $this->item = $in->getItemStackWrapper(); } @@ -52,7 +52,7 @@ protected function encodePayload(PacketSerializer $out) : void{ $out->putUnsignedVarInt($this->windowId); $out->putUnsignedVarInt($this->inventorySlot); $this->containerName->write($out); - $out->putUnsignedVarInt($this->dynamicContainerSize); + $out->putItemStackWrapper($this->storage); $out->putItemStackWrapper($this->item); } diff --git a/src/MobEffectPacket.php b/src/MobEffectPacket.php index dcf3f864..b10485ef 100644 --- a/src/MobEffectPacket.php +++ b/src/MobEffectPacket.php @@ -69,7 +69,7 @@ protected function decodePayload(PacketSerializer $in) : void{ $this->amplifier = $in->getVarInt(); $this->particles = $in->getBool(); $this->duration = $in->getVarInt(); - $this->tick = $in->getLLong(); + $this->tick = $in->getUnsignedVarLong(); } protected function encodePayload(PacketSerializer $out) : void{ @@ -79,7 +79,7 @@ protected function encodePayload(PacketSerializer $out) : void{ $out->putVarInt($this->amplifier); $out->putBool($this->particles); $out->putVarInt($this->duration); - $out->putLLong($this->tick); + $out->putUnsignedVarLong($this->tick); } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/MovementEffectPacket.php b/src/MovementEffectPacket.php new file mode 100644 index 00000000..642015dc --- /dev/null +++ b/src/MovementEffectPacket.php @@ -0,0 +1,65 @@ + + * + * 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\MovementEffectType; + +class MovementEffectPacket extends DataPacket implements ClientboundPacket{ + public const NETWORK_ID = ProtocolInfo::MOVEMENT_EFFECT_PACKET; + + private int $actorRuntimeId; + private MovementEffectType $effectType; + private int $duration; + private int $tick; + + /** + * @generate-create-func + */ + public static function create(int $actorRuntimeId, MovementEffectType $effectType, int $duration, int $tick) : self{ + $result = new self; + $result->actorRuntimeId = $actorRuntimeId; + $result->effectType = $effectType; + $result->duration = $duration; + $result->tick = $tick; + return $result; + } + + public function getActorRuntimeId() : int{ return $this->actorRuntimeId; } + + public function getEffectType() : MovementEffectType{ return $this->effectType; } + + public function getDuration() : int{ return $this->duration; } + + public function getTick() : int{ return $this->tick; } + + protected function decodePayload(PacketSerializer $in) : void{ + $this->actorRuntimeId = $in->getActorRuntimeId(); + $this->effectType = MovementEffectType::fromPacket($in->getUnsignedVarInt()); + $this->duration = $in->getUnsignedVarInt(); + $this->tick = $in->getUnsignedVarLong(); + } + + protected function encodePayload(PacketSerializer $out) : void{ + $out->putActorRuntimeId($this->actorRuntimeId); + $out->putUnsignedVarInt($this->effectType->value); + $out->putUnsignedVarInt($this->duration); + $out->putUnsignedVarLong($this->tick); + } + + public function handle(PacketHandlerInterface $handler) : bool{ + return $handler->handleMovementEffect($this); + } +} diff --git a/src/PacketHandlerDefaultImplTrait.php b/src/PacketHandlerDefaultImplTrait.php index 4f658842..9523649c 100644 --- a/src/PacketHandlerDefaultImplTrait.php +++ b/src/PacketHandlerDefaultImplTrait.php @@ -829,4 +829,12 @@ public function handleCameraAimAssist(CameraAimAssistPacket $packet) : bool{ public function handleContainerRegistryCleanup(ContainerRegistryCleanupPacket $packet) : bool{ return false; } + + public function handleMovementEffect(MovementEffectPacket $packet) : bool{ + return false; + } + + public function handleSetMovementAuthority(SetMovementAuthorityPacket $packet) : bool{ + return false; + } } diff --git a/src/PacketHandlerInterface.php b/src/PacketHandlerInterface.php index 0a606333..ca966659 100644 --- a/src/PacketHandlerInterface.php +++ b/src/PacketHandlerInterface.php @@ -421,4 +421,8 @@ public function handleServerboundDiagnostics(ServerboundDiagnosticsPacket $packe public function handleCameraAimAssist(CameraAimAssistPacket $packet) : bool; public function handleContainerRegistryCleanup(ContainerRegistryCleanupPacket $packet) : bool; + + public function handleMovementEffect(MovementEffectPacket $packet) : bool; + + public function handleSetMovementAuthority(SetMovementAuthorityPacket $packet) : bool; } diff --git a/src/PacketPool.php b/src/PacketPool.php index ab095cc2..e9a4be85 100644 --- a/src/PacketPool.php +++ b/src/PacketPool.php @@ -235,6 +235,8 @@ public function __construct(){ $this->registerPacket(new ServerboundDiagnosticsPacket()); $this->registerPacket(new CameraAimAssistPacket()); $this->registerPacket(new ContainerRegistryCleanupPacket()); + $this->registerPacket(new MovementEffectPacket()); + $this->registerPacket(new SetMovementAuthorityPacket()); } public function registerPacket(Packet $packet) : void{ diff --git a/src/PlayerAuthInputPacket.php b/src/PlayerAuthInputPacket.php index 28cd658a..0a7a0cf3 100644 --- a/src/PlayerAuthInputPacket.php +++ b/src/PlayerAuthInputPacket.php @@ -14,6 +14,7 @@ namespace pocketmine\network\mcpe\protocol; +use pocketmine\math\Vector2; use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; use pocketmine\network\mcpe\protocol\types\InputMode; @@ -26,7 +27,6 @@ use pocketmine\network\mcpe\protocol\types\PlayerBlockActionStopBreak; use pocketmine\network\mcpe\protocol\types\PlayerBlockActionWithBlockInfo; use pocketmine\network\mcpe\protocol\types\PlayMode; -use function assert; use function count; class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{ @@ -42,7 +42,7 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{ private int $inputMode; private int $playMode; private int $interactionMode; - private ?Vector3 $vrGazeDirection = null; + private Vector2 $interactRotation; private int $tick; private Vector3 $delta; private ?ItemInteractionData $itemInteractionData = null; @@ -52,6 +52,7 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{ private ?PlayerAuthInputVehicleInfo $vehicleInfo = null; private float $analogMoveVecX; private float $analogMoveVecZ; + private Vector3 $cameraOrientation; /** * @generate-create-func @@ -68,7 +69,7 @@ private static function internalCreate( int $inputMode, int $playMode, int $interactionMode, - ?Vector3 $vrGazeDirection, + Vector2 $interactRotation, int $tick, Vector3 $delta, ?ItemInteractionData $itemInteractionData, @@ -77,6 +78,7 @@ private static function internalCreate( ?PlayerAuthInputVehicleInfo $vehicleInfo, float $analogMoveVecX, float $analogMoveVecZ, + Vector3 $cameraOrientation, ) : self{ $result = new self; $result->position = $position; @@ -89,7 +91,7 @@ private static function internalCreate( $result->inputMode = $inputMode; $result->playMode = $playMode; $result->interactionMode = $interactionMode; - $result->vrGazeDirection = $vrGazeDirection; + $result->interactRotation = $interactRotation; $result->tick = $tick; $result->delta = $delta; $result->itemInteractionData = $itemInteractionData; @@ -98,6 +100,7 @@ private static function internalCreate( $result->vehicleInfo = $vehicleInfo; $result->analogMoveVecX = $analogMoveVecX; $result->analogMoveVecZ = $analogMoveVecZ; + $result->cameraOrientation = $cameraOrientation; return $result; } @@ -106,7 +109,6 @@ private static function internalCreate( * @param int $inputMode @see InputMode * @param int $playMode @see PlayMode * @param int $interactionMode @see InteractionMode - * @param Vector3|null $vrGazeDirection only used when PlayMode::VR * @param PlayerBlockAction[]|null $blockActions Blocks that the client has interacted with */ public static function create( @@ -120,7 +122,7 @@ public static function create( int $inputMode, int $playMode, int $interactionMode, - ?Vector3 $vrGazeDirection, + Vector2 $interactRotation, int $tick, Vector3 $delta, ?ItemInteractionData $itemInteractionData, @@ -128,13 +130,9 @@ public static function create( ?array $blockActions, ?PlayerAuthInputVehicleInfo $vehicleInfo, float $analogMoveVecX, - float $analogMoveVecZ + float $analogMoveVecZ, + Vector3 $cameraOrientation ) : self{ - if($playMode === PlayMode::VR and $vrGazeDirection === null){ - //yuck, can we get a properly written packet just once? ... - throw new \InvalidArgumentException("Gaze direction must be provided for VR play mode"); - } - $realInputFlags = $inputFlags & ~((1 << PlayerAuthInputFlags::PERFORM_ITEM_STACK_REQUEST) | (1 << PlayerAuthInputFlags::PERFORM_ITEM_INTERACTION) | (1 << PlayerAuthInputFlags::PERFORM_BLOCK_ACTIONS)); if($itemStackRequest !== null){ $realInputFlags |= 1 << PlayerAuthInputFlags::PERFORM_ITEM_STACK_REQUEST; @@ -160,7 +158,7 @@ public static function create( $inputMode, $playMode, $interactionMode, - $vrGazeDirection?->asVector3(), + $interactRotation, $tick, $delta, $itemInteractionData, @@ -168,7 +166,8 @@ public static function create( $blockActions, $vehicleInfo, $analogMoveVecX, - $analogMoveVecZ + $analogMoveVecZ, + $cameraOrientation ); } @@ -224,9 +223,7 @@ public function getInteractionMode() : int{ return $this->interactionMode; } - public function getVrGazeDirection() : ?Vector3{ - return $this->vrGazeDirection; - } + public function getInteractRotation() : Vector2{ return $this->interactRotation; } public function getTick() : int{ return $this->tick; @@ -257,6 +254,8 @@ public function getAnalogMoveVecX() : float{ return $this->analogMoveVecX; } public function getAnalogMoveVecZ() : float{ return $this->analogMoveVecZ; } + public function getCameraOrientation() : Vector3{ return $this->cameraOrientation; } + public function hasFlag(int $flag) : bool{ return ($this->inputFlags & (1 << $flag)) !== 0; } @@ -272,9 +271,7 @@ protected function decodePayload(PacketSerializer $in) : void{ $this->inputMode = $in->getUnsignedVarInt(); $this->playMode = $in->getUnsignedVarInt(); $this->interactionMode = $in->getUnsignedVarInt(); - if($this->playMode === PlayMode::VR){ - $this->vrGazeDirection = $in->getVector3(); - } + $this->interactRotation = $in->getVector2(); $this->tick = $in->getUnsignedVarLong(); $this->delta = $in->getVector3(); if($this->hasFlag(PlayerAuthInputFlags::PERFORM_ITEM_INTERACTION)){ @@ -300,6 +297,7 @@ protected function decodePayload(PacketSerializer $in) : void{ } $this->analogMoveVecX = $in->getLFloat(); $this->analogMoveVecZ = $in->getLFloat(); + $this->cameraOrientation = $in->getVector3(); } protected function encodePayload(PacketSerializer $out) : void{ @@ -313,10 +311,7 @@ protected function encodePayload(PacketSerializer $out) : void{ $out->putUnsignedVarInt($this->inputMode); $out->putUnsignedVarInt($this->playMode); $out->putUnsignedVarInt($this->interactionMode); - if($this->playMode === PlayMode::VR){ - assert($this->vrGazeDirection !== null); - $out->putVector3($this->vrGazeDirection); - } + $out->putVector2($this->interactRotation); $out->putUnsignedVarLong($this->tick); $out->putVector3($this->delta); if($this->itemInteractionData !== null){ @@ -337,6 +332,7 @@ protected function encodePayload(PacketSerializer $out) : void{ } $out->putLFloat($this->analogMoveVecX); $out->putLFloat($this->analogMoveVecZ); + $out->putVector3($this->cameraOrientation); } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/ProtocolInfo.php b/src/ProtocolInfo.php index 97a42c84..177a8cb0 100644 --- a/src/ProtocolInfo.php +++ b/src/ProtocolInfo.php @@ -32,11 +32,11 @@ private function __construct(){ */ /** Actual Minecraft: PE protocol version */ - public const CURRENT_PROTOCOL = 729; + public const CURRENT_PROTOCOL = 748; /** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */ - public const MINECRAFT_VERSION = 'v1.21.30'; + public const MINECRAFT_VERSION = 'v1.21.40'; /** Version number sent to clients in ping responses. */ - public const MINECRAFT_VERSION_NETWORK = '1.21.30'; + public const MINECRAFT_VERSION_NETWORK = '1.21.40'; public const LOGIN_PACKET = 0x01; public const PLAY_STATUS_PACKET = 0x02; @@ -253,4 +253,6 @@ private function __construct(){ public const SERVERBOUND_DIAGNOSTICS_PACKET = 0x13b; public const CAMERA_AIM_ASSIST_PACKET = 0x13c; public const CONTAINER_REGISTRY_CLEANUP_PACKET = 0x13d; + public const MOVEMENT_EFFECT_PACKET = 0x13e; + public const SET_MOVEMENT_AUTHORITY_PACKET = 0x13f; } diff --git a/src/ResourcePacksInfoPacket.php b/src/ResourcePacksInfoPacket.php index dfdbffa4..f8a40ff8 100644 --- a/src/ResourcePacksInfoPacket.php +++ b/src/ResourcePacksInfoPacket.php @@ -26,25 +26,17 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{ public bool $mustAccept = false; //if true, forces client to choose between accepting packs or being disconnected public bool $hasAddons = false; public bool $hasScripts = false; //if true, causes disconnect for any platform that doesn't support scripts yet - /** - * @var string[] - * @phpstan-var array - */ - public array $cdnUrls = []; /** * @generate-create-func * @param ResourcePackInfoEntry[] $resourcePackEntries - * @param string[] $cdnUrls - * @phpstan-param array $cdnUrls */ - public static function create(array $resourcePackEntries, bool $mustAccept, bool $hasAddons, bool $hasScripts, array $cdnUrls) : self{ + public static function create(array $resourcePackEntries, bool $mustAccept, bool $hasAddons, bool $hasScripts) : self{ $result = new self; $result->resourcePackEntries = $resourcePackEntries; $result->mustAccept = $mustAccept; $result->hasAddons = $hasAddons; $result->hasScripts = $hasScripts; - $result->cdnUrls = $cdnUrls; return $result; } @@ -57,13 +49,6 @@ protected function decodePayload(PacketSerializer $in) : void{ while($resourcePackCount-- > 0){ $this->resourcePackEntries[] = ResourcePackInfoEntry::read($in); } - - $this->cdnUrls = []; - for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; $i++){ - $packId = $in->getString(); - $cdnUrl = $in->getString(); - $this->cdnUrls[$packId] = $cdnUrl; - } } protected function encodePayload(PacketSerializer $out) : void{ @@ -74,11 +59,6 @@ protected function encodePayload(PacketSerializer $out) : void{ foreach($this->resourcePackEntries as $entry){ $entry->write($out); } - $out->putUnsignedVarInt(count($this->cdnUrls)); - foreach($this->cdnUrls as $packId => $cdnUrl){ - $out->putString($packId); - $out->putString($cdnUrl); - } } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/SetMovementAuthorityPacket.php b/src/SetMovementAuthorityPacket.php new file mode 100644 index 00000000..647954cc --- /dev/null +++ b/src/SetMovementAuthorityPacket.php @@ -0,0 +1,47 @@ + + * + * 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\ServerAuthMovementMode; + +class SetMovementAuthorityPacket extends DataPacket implements ClientboundPacket{ + public const NETWORK_ID = ProtocolInfo::SET_MOVEMENT_AUTHORITY_PACKET; + + private ServerAuthMovementMode $mode; + + /** + * @generate-create-func + */ + public static function create(ServerAuthMovementMode $mode) : self{ + $result = new self; + $result->mode = $mode; + return $result; + } + + public function getMode() : ServerAuthMovementMode{ return $this->mode; } + + protected function decodePayload(PacketSerializer $in) : void{ + $this->mode = ServerAuthMovementMode::fromPacket($in->getByte()); + } + + protected function encodePayload(PacketSerializer $out) : void{ + $out->putByte($this->mode->value); + } + + public function handle(PacketHandlerInterface $handler) : bool{ + return $handler->handleSetMovementAuthority($this); + } +} diff --git a/src/UpdatePlayerGameTypePacket.php b/src/UpdatePlayerGameTypePacket.php index 770d8fa2..92651818 100644 --- a/src/UpdatePlayerGameTypePacket.php +++ b/src/UpdatePlayerGameTypePacket.php @@ -45,13 +45,13 @@ public function getTick() : int{ return $this->tick; } protected function decodePayload(PacketSerializer $in) : void{ $this->gameMode = $in->getVarInt(); $this->playerActorUniqueId = $in->getActorUniqueId(); - $this->tick = $in->getUnsignedVarInt(); + $this->tick = $in->getUnsignedVarLong(); } protected function encodePayload(PacketSerializer $out) : void{ $out->putVarInt($this->gameMode); $out->putActorUniqueId($this->playerActorUniqueId); - $out->putUnsignedVarInt($this->tick); + $out->putUnsignedVarLong($this->tick); } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/types/PlayerMovementType.php b/src/types/MovementEffectType.php similarity index 63% rename from src/types/PlayerMovementType.php rename to src/types/MovementEffectType.php index 0c527822..0b1d35b6 100644 --- a/src/types/PlayerMovementType.php +++ b/src/types/MovementEffectType.php @@ -14,9 +14,9 @@ namespace pocketmine\network\mcpe\protocol\types; -final class PlayerMovementType{ +enum MovementEffectType : int{ + use PacketIntEnumTrait; - public const LEGACY = 0; //MovePlayerPacket - public const SERVER_AUTHORITATIVE_V1 = 1; //PlayerAuthInputPacket - public const SERVER_AUTHORITATIVE_V2_REWIND = 2; //PlayerAuthInputPacket + movement replay (used for server authoritative knockback) + case INVALID = -1; + case GLIDE_BOOST = 0; } diff --git a/src/types/PlayerAction.php b/src/types/PlayerAction.php index 30060a6a..ce4caca8 100644 --- a/src/types/PlayerAction.php +++ b/src/types/PlayerAction.php @@ -42,7 +42,7 @@ private function __construct(){ public const SET_ENCHANTMENT_SEED = 20; //no longer used public const START_SWIMMING = 21; public const STOP_SWIMMING = 22; - public const START_SPIN_ATTACK = 23; //no longer used + public const START_SPIN_ATTACK = 23; public const STOP_SPIN_ATTACK = 24; public const INTERACT_BLOCK = 25; public const PREDICT_DESTROY_BLOCK = 26; @@ -56,6 +56,7 @@ private function __construct(){ public const START_FLYING = 34; public const STOP_FLYING = 35; public const ACK_ACTOR_DATA = 36; + public const START_USING_ITEM = 37; //Backwards compatibility (blame @dktapps) public const CRACK_BREAK = 18; diff --git a/src/types/PlayerAuthInputFlags.php b/src/types/PlayerAuthInputFlags.php index 77ea7259..60809451 100644 --- a/src/types/PlayerAuthInputFlags.php +++ b/src/types/PlayerAuthInputFlags.php @@ -106,5 +106,10 @@ final class PlayerAuthInputFlags{ public const VERTICAL_COLLISION = 50; public const DOWN_LEFT = 51; public const DOWN_RIGHT = 52; + public const START_USING_ITEM = 53; + public const IS_CAMERA_RELATIVE_MOVEMENT_ENABLED = 54; + public const IS_ROT_CONTROLLED_BY_MOVE_DIRECTION = 55; + public const START_SPIN_ATTACK = 56; + public const STOP_SPIN_ATTACK = 57; } diff --git a/src/types/PlayerMovementSettings.php b/src/types/PlayerMovementSettings.php index f1948418..e073b6fc 100644 --- a/src/types/PlayerMovementSettings.php +++ b/src/types/PlayerMovementSettings.php @@ -18,26 +18,26 @@ final class PlayerMovementSettings{ public function __construct( - private int $movementType, + private ServerAuthMovementMode $movementType, private int $rewindHistorySize, private bool $serverAuthoritativeBlockBreaking ){} - public function getMovementType() : int{ return $this->movementType; } + public function getMovementType() : ServerAuthMovementMode{ return $this->movementType; } public function getRewindHistorySize() : int{ return $this->rewindHistorySize; } public function isServerAuthoritativeBlockBreaking() : bool{ return $this->serverAuthoritativeBlockBreaking; } public static function read(PacketSerializer $in) : self{ - $movementType = $in->getVarInt(); + $movementType = ServerAuthMovementMode::fromPacket($in->getVarInt()); $rewindHistorySize = $in->getVarInt(); $serverAuthBlockBreaking = $in->getBool(); return new self($movementType, $rewindHistorySize, $serverAuthBlockBreaking); } public function write(PacketSerializer $out) : void{ - $out->putVarInt($this->movementType); + $out->putVarInt($this->movementType->value); $out->putVarInt($this->rewindHistorySize); $out->putBool($this->serverAuthoritativeBlockBreaking); } diff --git a/src/types/ServerAuthMovementMode.php b/src/types/ServerAuthMovementMode.php new file mode 100644 index 00000000..dcd5b85d --- /dev/null +++ b/src/types/ServerAuthMovementMode.php @@ -0,0 +1,23 @@ + + * + * 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\types; + +enum ServerAuthMovementMode : int{ + use PacketIntEnumTrait; + + case LEGACY_CLIENT_AUTHORITATIVE_V1 = 0; + case SERVER_AUTHORITATIVE_V2 = 1; + case SERVER_AUTHORITATIVE_V3 = 2; +} diff --git a/src/types/camera/CameraPreset.php b/src/types/camera/CameraPreset.php index b1642329..fe8aec91 100644 --- a/src/types/camera/CameraPreset.php +++ b/src/types/camera/CameraPreset.php @@ -32,11 +32,15 @@ public function __construct( private ?float $yaw, private ?float $rotationSpeed, private ?bool $snapToTarget, + private ?Vector2 $horizontalRotationLimit, + private ?Vector2 $verticalRotationLimit, + private ?bool $continueTargeting, private ?Vector2 $viewOffset, private ?Vector3 $entityOffset, private ?float $radius, private ?int $audioListenerType, - private ?bool $playerEffects + private ?bool $playerEffects, + private ?bool $alignTargetAndCameraForward ){} public function getName() : string{ return $this->name; } @@ -57,6 +61,12 @@ public function getRotationSpeed() : ?float { return $this->rotationSpeed; } public function getSnapToTarget() : ?bool { return $this->snapToTarget; } + public function getHorizontalRotationLimit() : ?Vector2{ return $this->horizontalRotationLimit; } + + public function getVerticalRotationLimit() : ?Vector2{ return $this->verticalRotationLimit; } + + public function getContinueTargeting() : ?bool{ return $this->continueTargeting; } + public function getViewOffset() : ?Vector2{ return $this->viewOffset; } public function getEntityOffset() : ?Vector3{ return $this->entityOffset; } @@ -67,6 +77,8 @@ public function getAudioListenerType() : ?int{ return $this->audioListenerType; public function getPlayerEffects() : ?bool{ return $this->playerEffects; } + public function getAlignTargetAndCameraForward() : ?bool{ return $this->alignTargetAndCameraForward; } + public static function read(PacketSerializer $in) : self{ $name = $in->getString(); $parent = $in->getString(); @@ -77,11 +89,15 @@ public static function read(PacketSerializer $in) : self{ $yaw = $in->readOptional($in->getLFloat(...)); $rotationSpeed = $in->readOptional($in->getLFloat(...)); $snapToTarget = $in->readOptional($in->getBool(...)); + $horizontalRotationLimit = $in->readOptional($in->getVector2(...)); + $verticalRotationLimit = $in->readOptional($in->getVector2(...)); + $continueTargeting = $in->readOptional($in->getBool(...)); $viewOffset = $in->readOptional($in->getVector2(...)); $entityOffset = $in->readOptional($in->getVector3(...)); $radius = $in->readOptional($in->getLFloat(...)); $audioListenerType = $in->readOptional($in->getByte(...)); $playerEffects = $in->readOptional($in->getBool(...)); + $alignTargetAndCameraForward = $in->readOptional($in->getBool(...)); return new self( $name, @@ -93,11 +109,15 @@ public static function read(PacketSerializer $in) : self{ $yaw, $rotationSpeed, $snapToTarget, + $horizontalRotationLimit, + $verticalRotationLimit, + $continueTargeting, $viewOffset, $entityOffset, $radius, $audioListenerType, - $playerEffects + $playerEffects, + $alignTargetAndCameraForward ); } @@ -111,10 +131,14 @@ public function write(PacketSerializer $out) : void{ $out->writeOptional($this->yaw, $out->putLFloat(...)); $out->writeOptional($this->rotationSpeed, $out->putLFloat(...)); $out->writeOptional($this->snapToTarget, $out->putBool(...)); + $out->writeOptional($this->horizontalRotationLimit, $out->putVector2(...)); + $out->writeOptional($this->verticalRotationLimit, $out->putVector2(...)); + $out->writeOptional($this->continueTargeting, $out->putBool(...)); $out->writeOptional($this->viewOffset, $out->putVector2(...)); $out->writeOptional($this->entityOffset, $out->putVector3(...)); $out->writeOptional($this->radius, $out->putLFloat(...)); $out->writeOptional($this->audioListenerType, $out->putByte(...)); $out->writeOptional($this->playerEffects, $out->putBool(...)); + $out->writeOptional($this->alignTargetAndCameraForward, $out->putBool(...)); } } diff --git a/src/types/camera/CameraSetInstruction.php b/src/types/camera/CameraSetInstruction.php index b8512d10..6c8e9918 100644 --- a/src/types/camera/CameraSetInstruction.php +++ b/src/types/camera/CameraSetInstruction.php @@ -27,6 +27,7 @@ public function __construct( private ?CameraSetInstructionRotation $rotation, private ?Vector3 $facingPosition, private ?Vector2 $viewOffset, + private ?Vector3 $entityOffset, private ?bool $default ){} @@ -42,6 +43,8 @@ public function getFacingPosition() : ?Vector3{ return $this->facingPosition; } public function getViewOffset() : ?Vector2{ return $this->viewOffset; } + public function getEntityOffset() : ?Vector3{ return $this->entityOffset; } + public function getDefault() : ?bool{ return $this->default; } public static function read(PacketSerializer $in) : self{ @@ -51,6 +54,7 @@ public static function read(PacketSerializer $in) : self{ $rotation = $in->readOptional(fn() => CameraSetInstructionRotation::read($in)); $facingPosition = $in->readOptional($in->getVector3(...)); $viewOffset = $in->readOptional($in->getVector2(...)); + $entityOffset = $in->readOptional($in->getVector3(...)); $default = $in->readOptional($in->getBool(...)); return new self( @@ -60,6 +64,7 @@ public static function read(PacketSerializer $in) : self{ $rotation, $facingPosition, $viewOffset, + $entityOffset, $default ); } @@ -71,6 +76,7 @@ public function write(PacketSerializer $out) : void{ $out->writeOptional($this->rotation, fn(CameraSetInstructionRotation $v) => $v->write($out)); $out->writeOptional($this->facingPosition, $out->putVector3(...)); $out->writeOptional($this->viewOffset, $out->putVector2(...)); + $out->writeOptional($this->entityOffset, $out->putVector3(...)); $out->writeOptional($this->default, $out->putBool(...)); } } diff --git a/src/types/inventory/ContainerIds.php b/src/types/inventory/ContainerIds.php index fa36c231..a1486dee 100644 --- a/src/types/inventory/ContainerIds.php +++ b/src/types/inventory/ContainerIds.php @@ -31,6 +31,5 @@ private function __construct(){ public const FIXED_INVENTORY = 123; public const UI = 124; public const CONTAINER_ID_REGISTRY = 125; - public const CONTAINER_ID_REGISTRY_INVENTORY = 126; } diff --git a/src/types/login/ClientData.php b/src/types/login/ClientData.php index 2a87601a..45877bdf 100644 --- a/src/types/login/ClientData.php +++ b/src/types/login/ClientData.php @@ -76,6 +76,12 @@ final class ClientData{ /** @required */ public string $LanguageCode; + /** @required */ + public int $MaxViewDistance; + + /** @required */ + public int $MemoryTier; + public bool $OverrideSkin; /** @@ -99,6 +105,9 @@ final class ClientData{ /** @required */ public string $PlatformOnlineId; + /** @required */ + public int $PlatformType; + public string $PlatformUserId = ""; //xbox-only, apparently /** @required */ diff --git a/src/types/resourcepacks/ResourcePackInfoEntry.php b/src/types/resourcepacks/ResourcePackInfoEntry.php index d673e031..0bb7b4c0 100644 --- a/src/types/resourcepacks/ResourcePackInfoEntry.php +++ b/src/types/resourcepacks/ResourcePackInfoEntry.php @@ -26,7 +26,8 @@ public function __construct( private string $contentId = "", private bool $hasScripts = false, private bool $isAddonPack = false, - private bool $isRtxCapable = false + private bool $isRtxCapable = false, + private string $cdnUrl = "" ){} public function getPackId() : string{ @@ -61,6 +62,8 @@ public function isAddonPack() : bool{ return $this->isAddonPack; } public function isRtxCapable() : bool{ return $this->isRtxCapable; } + public function getCdnUrl() : string{ return $this->cdnUrl; } + public function write(PacketSerializer $out) : void{ $out->putString($this->packId); $out->putString($this->version); @@ -71,6 +74,7 @@ public function write(PacketSerializer $out) : void{ $out->putBool($this->hasScripts); $out->putBool($this->isAddonPack); $out->putBool($this->isRtxCapable); + $out->putString($this->cdnUrl); } public static function read(PacketSerializer $in) : self{ @@ -83,6 +87,7 @@ public static function read(PacketSerializer $in) : self{ $hasScripts = $in->getBool(); $isAddonPack = $in->getBool(); $rtxCapable = $in->getBool(); - return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts, $isAddonPack, $rtxCapable); + $cdnUrl = $in->getString(); + return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts, $isAddonPack, $rtxCapable, $cdnUrl); } }