Skip to content

Commit 9c341d5

Browse files
authored
Merge branch 'master' into fix/camera-target-instruction
2 parents 5922bb0 + 3a84e3e commit 9c341d5

23 files changed

+357
-185
lines changed

src/CameraAimAssistPacket.php

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/*
4+
* This file is part of BedrockProtocol.
5+
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6+
*
7+
* BedrockProtocol is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*/
12+
13+
declare(strict_types=1);
14+
15+
namespace pocketmine\network\mcpe\protocol;
16+
17+
use pocketmine\math\Vector2;
18+
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
19+
use pocketmine\network\mcpe\protocol\types\camera\CameraAimAssistActionType;
20+
use pocketmine\network\mcpe\protocol\types\camera\CameraAimAssistTargetMode;
21+
22+
class CameraAimAssistPacket extends DataPacket implements ClientboundPacket{
23+
public const NETWORK_ID = ProtocolInfo::CAMERA_AIM_ASSIST_PACKET;
24+
25+
private Vector2 $viewAngle;
26+
private float $distance;
27+
private CameraAimAssistTargetMode $targetMode;
28+
private CameraAimAssistActionType $actionType;
29+
30+
/**
31+
* @generate-create-func
32+
*/
33+
public static function create(Vector2 $viewAngle, float $distance, CameraAimAssistTargetMode $targetMode, CameraAimAssistActionType $actionType) : self{
34+
$result = new self;
35+
$result->viewAngle = $viewAngle;
36+
$result->distance = $distance;
37+
$result->targetMode = $targetMode;
38+
$result->actionType = $actionType;
39+
return $result;
40+
}
41+
42+
public function getViewAngle() : Vector2{ return $this->viewAngle; }
43+
44+
public function getDistance() : float{ return $this->distance; }
45+
46+
public function getTargetMode() : CameraAimAssistTargetMode{ return $this->targetMode; }
47+
48+
public function getActionType() : CameraAimAssistActionType{ return $this->actionType; }
49+
50+
protected function decodePayload(PacketSerializer $in) : void{
51+
$this->viewAngle = $in->getVector2();
52+
$this->distance = $in->getLFloat();
53+
$this->targetMode = CameraAimAssistTargetMode::fromPacket($in->getByte());
54+
$this->actionType = CameraAimAssistActionType::fromPacket($in->getByte());
55+
}
56+
57+
protected function encodePayload(PacketSerializer $out) : void{
58+
$out->putVector2($this->viewAngle);
59+
$out->putLFloat($this->distance);
60+
$out->putByte($this->targetMode->value);
61+
$out->putByte($this->actionType->value);
62+
}
63+
64+
public function handle(PacketHandlerInterface $handler) : bool{
65+
return $handler->handleCameraAimAssist($this);
66+
}
67+
}
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
/*
4+
* This file is part of BedrockProtocol.
5+
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6+
*
7+
* BedrockProtocol is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*/
12+
13+
declare(strict_types=1);
14+
15+
namespace pocketmine\network\mcpe\protocol;
16+
17+
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
18+
use pocketmine\network\mcpe\protocol\types\inventory\FullContainerName;
19+
use function count;
20+
21+
class ContainerRegistryCleanupPacket extends DataPacket implements ClientboundPacket{
22+
public const NETWORK_ID = ProtocolInfo::CONTAINER_REGISTRY_CLEANUP_PACKET;
23+
24+
/** @var FullContainerName[] */
25+
private array $removedContainers;
26+
27+
/**
28+
* @generate-create-func
29+
* @param FullContainerName[] $removedContainers
30+
*/
31+
public static function create(array $removedContainers) : self{
32+
$result = new self;
33+
$result->removedContainers = $removedContainers;
34+
return $result;
35+
}
36+
37+
/**
38+
* @return FullContainerName[]
39+
*/
40+
public function getRemovedContainers() : array{ return $this->removedContainers; }
41+
42+
protected function decodePayload(PacketSerializer $in) : void{
43+
$this->removedContainers = [];
44+
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
45+
$this->removedContainers[] = FullContainerName::read($in);
46+
}
47+
}
48+
49+
protected function encodePayload(PacketSerializer $out) : void{
50+
$out->putUnsignedVarInt(count($this->removedContainers));
51+
foreach($this->removedContainers as $container){
52+
$container->write($out);
53+
}
54+
}
55+
56+
public function handle(PacketHandlerInterface $handler) : bool{
57+
return $handler->handleContainerRegistryCleanup($this);
58+
}
59+
}

src/EmotePacket.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@ class EmotePacket extends DataPacket implements ClientboundPacket, ServerboundPa
2424

2525
private int $actorRuntimeId;
2626
private string $emoteId;
27+
private int $emoteLengthTicks;
2728
private string $xboxUserId;
2829
private string $platformChatId;
2930
private int $flags;
3031

3132
/**
3233
* @generate-create-func
3334
*/
34-
public static function create(int $actorRuntimeId, string $emoteId, string $xboxUserId, string $platformChatId, int $flags) : self{
35+
public static function create(int $actorRuntimeId, string $emoteId, int $emoteLengthTicks, string $xboxUserId, string $platformChatId, int $flags) : self{
3536
$result = new self;
3637
$result->actorRuntimeId = $actorRuntimeId;
3738
$result->emoteId = $emoteId;
39+
$result->emoteLengthTicks = $emoteLengthTicks;
3840
$result->xboxUserId = $xboxUserId;
3941
$result->platformChatId = $platformChatId;
4042
$result->flags = $flags;
@@ -49,6 +51,8 @@ public function getEmoteId() : string{
4951
return $this->emoteId;
5052
}
5153

54+
public function getEmoteLengthTicks() : int{ return $this->emoteLengthTicks; }
55+
5256
public function getXboxUserId() : string{ return $this->xboxUserId; }
5357

5458
public function getPlatformChatId() : string{ return $this->platformChatId; }
@@ -60,6 +64,7 @@ public function getFlags() : int{
6064
protected function decodePayload(PacketSerializer $in) : void{
6165
$this->actorRuntimeId = $in->getActorRuntimeId();
6266
$this->emoteId = $in->getString();
67+
$this->emoteLengthTicks = $in->getUnsignedVarInt();
6368
$this->xboxUserId = $in->getString();
6469
$this->platformChatId = $in->getString();
6570
$this->flags = $in->getByte();
@@ -68,6 +73,7 @@ protected function decodePayload(PacketSerializer $in) : void{
6873
protected function encodePayload(PacketSerializer $out) : void{
6974
$out->putActorRuntimeId($this->actorRuntimeId);
7075
$out->putString($this->emoteId);
76+
$out->putUnsignedVarInt($this->emoteLengthTicks);
7177
$out->putString($this->xboxUserId);
7278
$out->putString($this->platformChatId);
7379
$out->putByte($this->flags);

src/InventoryContentPacket.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace pocketmine\network\mcpe\protocol;
1616

1717
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
18+
use pocketmine\network\mcpe\protocol\types\inventory\FullContainerName;
1819
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
1920
use function count;
2021

@@ -24,17 +25,19 @@ class InventoryContentPacket extends DataPacket implements ClientboundPacket{
2425
public int $windowId;
2526
/** @var ItemStackWrapper[] */
2627
public array $items = [];
27-
public int $dynamicContainerId;
28+
public FullContainerName $containerName;
29+
public int $dynamicContainerSize;
2830

2931
/**
3032
* @generate-create-func
3133
* @param ItemStackWrapper[] $items
3234
*/
33-
public static function create(int $windowId, array $items, int $dynamicContainerId) : self{
35+
public static function create(int $windowId, array $items, FullContainerName $containerName, int $dynamicContainerSize) : self{
3436
$result = new self;
3537
$result->windowId = $windowId;
3638
$result->items = $items;
37-
$result->dynamicContainerId = $dynamicContainerId;
39+
$result->containerName = $containerName;
40+
$result->dynamicContainerSize = $dynamicContainerSize;
3841
return $result;
3942
}
4043

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

5054
protected function encodePayload(PacketSerializer $out) : void{
@@ -53,7 +57,8 @@ protected function encodePayload(PacketSerializer $out) : void{
5357
foreach($this->items as $item){
5458
$out->putItemStackWrapper($item);
5559
}
56-
$out->putUnsignedVarInt($this->dynamicContainerId);
60+
$this->containerName->write($out);
61+
$out->putUnsignedVarInt($this->dynamicContainerSize);
5762
}
5863

5964
public function handle(PacketHandlerInterface $handler) : bool{

src/InventorySlotPacket.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,44 @@
1515
namespace pocketmine\network\mcpe\protocol;
1616

1717
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
18+
use pocketmine\network\mcpe\protocol\types\inventory\FullContainerName;
1819
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
1920

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

2324
public int $windowId;
2425
public int $inventorySlot;
26+
public FullContainerName $containerName;
27+
public int $dynamicContainerSize;
2528
public ItemStackWrapper $item;
26-
public int $dynamicContainerId;
2729

2830
/**
2931
* @generate-create-func
3032
*/
31-
public static function create(int $windowId, int $inventorySlot, ItemStackWrapper $item, int $dynamicContainerId) : self{
33+
public static function create(int $windowId, int $inventorySlot, FullContainerName $containerName, int $dynamicContainerSize, ItemStackWrapper $item) : self{
3234
$result = new self;
3335
$result->windowId = $windowId;
3436
$result->inventorySlot = $inventorySlot;
37+
$result->containerName = $containerName;
38+
$result->dynamicContainerSize = $dynamicContainerSize;
3539
$result->item = $item;
36-
$result->dynamicContainerId = $dynamicContainerId;
3740
return $result;
3841
}
3942

4043
protected function decodePayload(PacketSerializer $in) : void{
4144
$this->windowId = $in->getUnsignedVarInt();
4245
$this->inventorySlot = $in->getUnsignedVarInt();
43-
$this->dynamicContainerId = $in->getUnsignedVarInt();
46+
$this->containerName = FullContainerName::read($in);
47+
$this->dynamicContainerSize = $in->getUnsignedVarInt();
4448
$this->item = $in->getItemStackWrapper();
4549
}
4650

4751
protected function encodePayload(PacketSerializer $out) : void{
4852
$out->putUnsignedVarInt($this->windowId);
4953
$out->putUnsignedVarInt($this->inventorySlot);
50-
$out->putUnsignedVarInt($this->dynamicContainerId);
54+
$this->containerName->write($out);
55+
$out->putUnsignedVarInt($this->dynamicContainerSize);
5156
$out->putItemStackWrapper($this->item);
5257
}
5358

src/PacketHandlerDefaultImplTrait.php

+8
Original file line numberDiff line numberDiff line change
@@ -821,4 +821,12 @@ public function handleCurrentStructureFeature(CurrentStructureFeaturePacket $pac
821821
public function handleServerboundDiagnostics(ServerboundDiagnosticsPacket $packet) : bool{
822822
return false;
823823
}
824+
825+
public function handleCameraAimAssist(CameraAimAssistPacket $packet) : bool{
826+
return false;
827+
}
828+
829+
public function handleContainerRegistryCleanup(ContainerRegistryCleanupPacket $packet) : bool{
830+
return false;
831+
}
824832
}

src/PacketHandlerInterface.php

+4
Original file line numberDiff line numberDiff line change
@@ -417,4 +417,8 @@ public function handleJigsawStructureData(JigsawStructureDataPacket $packet) : b
417417
public function handleCurrentStructureFeature(CurrentStructureFeaturePacket $packet) : bool;
418418

419419
public function handleServerboundDiagnostics(ServerboundDiagnosticsPacket $packet) : bool;
420+
421+
public function handleCameraAimAssist(CameraAimAssistPacket $packet) : bool;
422+
423+
public function handleContainerRegistryCleanup(ContainerRegistryCleanupPacket $packet) : bool;
420424
}

src/PacketPool.php

+2
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ public function __construct(){
233233
$this->registerPacket(new JigsawStructureDataPacket());
234234
$this->registerPacket(new CurrentStructureFeaturePacket());
235235
$this->registerPacket(new ServerboundDiagnosticsPacket());
236+
$this->registerPacket(new CameraAimAssistPacket());
237+
$this->registerPacket(new ContainerRegistryCleanupPacket());
236238
}
237239

238240
public function registerPacket(Packet $packet) : void{

src/ProtocolInfo.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ private function __construct(){
3232
*/
3333

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

4141
public const LOGIN_PACKET = 0x01;
4242
public const PLAY_STATUS_PACKET = 0x02;
@@ -251,4 +251,6 @@ private function __construct(){
251251
public const JIGSAW_STRUCTURE_DATA_PACKET = 0x139;
252252
public const CURRENT_STRUCTURE_FEATURE_PACKET = 0x13a;
253253
public const SERVERBOUND_DIAGNOSTICS_PACKET = 0x13b;
254+
public const CAMERA_AIM_ASSIST_PACKET = 0x13c;
255+
public const CONTAINER_REGISTRY_CLEANUP_PACKET = 0x13d;
254256
}

0 commit comments

Comments
 (0)