Skip to content

Commit 5e88f0e

Browse files
committed
Bedrock 1.26.10
1 parent 34d9d61 commit 5e88f0e

69 files changed

Lines changed: 2424 additions & 105 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/BlockPickRequestPacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public static function create(BlockPosition $blockPosition, bool $addUserData, i
3939
}
4040

4141
protected function decodePayload(ByteBufferReader $in) : void{
42-
$this->blockPosition = CommonTypes::getSignedBlockPosition($in);
42+
$this->blockPosition = CommonTypes::getBlockPosition($in);
4343
$this->addUserData = CommonTypes::getBool($in);
4444
$this->hotbarSlot = Byte::readUnsigned($in);
4545
}
4646

4747
protected function encodePayload(ByteBufferWriter $out) : void{
48-
CommonTypes::putSignedBlockPosition($out, $this->blockPosition);
48+
CommonTypes::putBlockPosition($out, $this->blockPosition);
4949
CommonTypes::putBool($out, $this->addUserData);
5050
Byte::writeUnsigned($out, $this->hotbarSlot);
5151
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 pmmp\encoding\ByteBufferReader;
18+
use pmmp\encoding\ByteBufferWriter;
19+
use pmmp\encoding\VarInt;
20+
use pocketmine\network\mcpe\protocol\types\AttributeLayerSyncPayload;
21+
use pocketmine\network\mcpe\protocol\types\AttributesRemoveEnvironment;
22+
use pocketmine\network\mcpe\protocol\types\AttributesUpdateEnvironment;
23+
use pocketmine\network\mcpe\protocol\types\AttributeUpdateLayers;
24+
use pocketmine\network\mcpe\protocol\types\AttributeUpdateLayerSettings;
25+
26+
class ClientboundAttributeLayerSyncPacket extends DataPacket{
27+
public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_ATTRIBUTE_LAYER_SYNC_PACKET;
28+
29+
private AttributeLayerSyncPayload $payload;
30+
31+
/**
32+
* @generate-create-func
33+
*/
34+
public static function create(AttributeLayerSyncPayload $payload) : self{
35+
$result = new self;
36+
$result->payload = $payload;
37+
return $result;
38+
}
39+
40+
protected function decodePayload(ByteBufferReader $in) : void{
41+
$this->payload = match(VarInt::readUnsignedInt($in)){
42+
AttributeUpdateLayers::ID => AttributeUpdateLayers::read($in),
43+
AttributeUpdateLayerSettings::ID => AttributeUpdateLayerSettings::read($in),
44+
AttributesUpdateEnvironment::ID => AttributesUpdateEnvironment::read($in),
45+
AttributesRemoveEnvironment::ID => AttributesRemoveEnvironment::read($in),
46+
default => throw new PacketDecodeException("Unknown ClientboundAttributeLayerSync type"),
47+
};
48+
}
49+
50+
protected function encodePayload(ByteBufferWriter $out) : void{
51+
VarInt::writeUnsignedInt($out, $this->payload->getTypeId());
52+
$this->payload->write($out);
53+
}
54+
55+
public function handle(PacketHandlerInterface $handler) : bool{
56+
return $handler->handleClientboundAttributeLayerSync($this);
57+
}
58+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 pmmp\encoding\ByteBufferReader;
18+
use pmmp\encoding\ByteBufferWriter;
19+
use pmmp\encoding\LE;
20+
use pocketmine\network\mcpe\protocol\serializer\CommonTypes;
21+
22+
class ClientboundDataDrivenUICloseScreenPacket extends DataPacket implements ClientboundPacket{
23+
public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_DATA_DRIVEN_UI_CLOSE_SCREEN_PACKET;
24+
25+
private ?int $formId;
26+
27+
/**
28+
* @generate-create-func
29+
*/
30+
public static function create(?int $formId) : self{
31+
$result = new self;
32+
$result->formId = $formId;
33+
return $result;
34+
}
35+
36+
public function getFormId() : ?int{ return $this->formId; }
37+
38+
protected function decodePayload(ByteBufferReader $in) : void{
39+
$this->formId = CommonTypes::readOptional($in, LE::readUnsignedInt(...));
40+
}
41+
42+
protected function encodePayload(ByteBufferWriter $out) : void{
43+
CommonTypes::writeOptional($out, $this->formId, LE::writeUnsignedInt(...));
44+
}
45+
46+
public function handle(PacketHandlerInterface $handler) : bool{
47+
return $handler->handleClientboundDataDrivenUICloseScreen($this);
48+
}
49+
}

src/ClientboundDataDrivenUIShowScreenPacket.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,43 @@
1616

1717
use pmmp\encoding\ByteBufferReader;
1818
use pmmp\encoding\ByteBufferWriter;
19+
use pmmp\encoding\LE;
1920
use pocketmine\network\mcpe\protocol\serializer\CommonTypes;
2021

2122
class ClientboundDataDrivenUIShowScreenPacket extends DataPacket implements ClientboundPacket{
2223
public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_DATA_DRIVEN_UI_SHOW_SCREEN_PACKET;
2324

2425
private string $screenId;
26+
private int $formId;
27+
private ?int $dataInstanceId;
2528

2629
/**
2730
* @generate-create-func
2831
*/
29-
public static function create(string $screenId) : self{
32+
public static function create(string $screenId, int $formId, ?int $dataInstanceId) : self{
3033
$result = new self;
3134
$result->screenId = $screenId;
35+
$result->formId = $formId;
36+
$result->dataInstanceId = $dataInstanceId;
3237
return $result;
3338
}
3439

3540
public function getScreenId() : string{ return $this->screenId; }
3641

42+
public function getFormId() : int{ return $this->formId; }
43+
44+
public function getDataInstanceId() : ?int{ return $this->dataInstanceId; }
45+
3746
protected function decodePayload(ByteBufferReader $in) : void{
3847
$this->screenId = CommonTypes::getString($in);
48+
$this->formId = LE::readUnsignedInt($in);
49+
$this->dataInstanceId = CommonTypes::readOptional($in, LE::readUnsignedInt(...));
3950
}
4051

4152
protected function encodePayload(ByteBufferWriter $out) : void{
4253
CommonTypes::putString($out, $this->screenId);
54+
LE::writeUnsignedInt($out, $this->formId);
55+
CommonTypes::writeOptional($out, $this->dataInstanceId, LE::writeUnsignedInt(...));
4356
}
4457

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

src/ClientboundMapItemDataPacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected function decodePayload(ByteBufferReader $in) : void{
6060
$this->type = VarInt::readUnsignedInt($in);
6161
$this->dimensionId = Byte::readUnsigned($in);
6262
$this->isLocked = CommonTypes::getBool($in);
63-
$this->origin = CommonTypes::getSignedBlockPosition($in);
63+
$this->origin = CommonTypes::getBlockPosition($in);
6464

6565
if(($this->type & self::BITFLAG_MAP_CREATION) !== 0){
6666
$count = VarInt::readUnsignedInt($in);
@@ -130,7 +130,7 @@ protected function encodePayload(ByteBufferWriter $out) : void{
130130
VarInt::writeUnsignedInt($out, $type);
131131
Byte::writeUnsigned($out, $this->dimensionId);
132132
CommonTypes::putBool($out, $this->isLocked);
133-
CommonTypes::putSignedBlockPosition($out, $this->origin);
133+
CommonTypes::putBlockPosition($out, $this->origin);
134134

135135
if(($type & self::BITFLAG_MAP_CREATION) !== 0){
136136
VarInt::writeUnsignedInt($out, $parentMapIdsCount);

src/GameTestRequestPacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected function decodePayload(ByteBufferReader $in) : void{
8282
$this->repeatCount = VarInt::readSignedInt($in);
8383
$this->rotation = Byte::readUnsigned($in);
8484
$this->stopOnFailure = CommonTypes::getBool($in);
85-
$this->testPosition = CommonTypes::getSignedBlockPosition($in);
85+
$this->testPosition = CommonTypes::getBlockPosition($in);
8686
$this->testsPerRow = VarInt::readSignedInt($in);
8787
$this->testName = CommonTypes::getString($in);
8888
}
@@ -92,7 +92,7 @@ protected function encodePayload(ByteBufferWriter $out) : void{
9292
VarInt::writeSignedInt($out, $this->repeatCount);
9393
Byte::writeUnsigned($out, $this->rotation);
9494
CommonTypes::putBool($out, $this->stopOnFailure);
95-
CommonTypes::putSignedBlockPosition($out, $this->testPosition);
95+
CommonTypes::putBlockPosition($out, $this->testPosition);
9696
VarInt::writeSignedInt($out, $this->testsPerRow);
9797
CommonTypes::putString($out, $this->testName);
9898
}

src/GraphicsOverrideParameterPacket.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class GraphicsOverrideParameterPacket extends DataPacket implements ClientboundP
3030

3131
/** @var ParameterKeyframeValue[] */
3232
private array $values = [];
33-
private float $unknownFloat;
34-
private Vector3 $unknownVector3;
33+
private ?float $unknownFloat;
34+
private ?Vector3 $unknownVector3;
3535
private string $biomeIdentifier;
3636
private GraphicsOverrideParameterType $parameterType;
3737
private bool $reset;
@@ -40,7 +40,7 @@ class GraphicsOverrideParameterPacket extends DataPacket implements ClientboundP
4040
* @generate-create-func
4141
* @param ParameterKeyframeValue[] $values
4242
*/
43-
public static function create(array $values, float $unknownFloat, Vector3 $unknownVector3, string $biomeIdentifier, GraphicsOverrideParameterType $parameterType, bool $reset) : self{
43+
public static function create(array $values, ?float $unknownFloat, ?Vector3 $unknownVector3, string $biomeIdentifier, GraphicsOverrideParameterType $parameterType, bool $reset) : self{
4444
$result = new self;
4545
$result->values = $values;
4646
$result->unknownFloat = $unknownFloat;
@@ -56,9 +56,9 @@ public static function create(array $values, float $unknownFloat, Vector3 $unkno
5656
*/
5757
public function getValues() : array{ return $this->values; }
5858

59-
public function getUnknownFloat() : float{ return $this->unknownFloat; }
59+
public function getUnknownFloat() : ?float{ return $this->unknownFloat; }
6060

61-
public function getUnknownVector3() : Vector3{ return $this->unknownVector3; }
61+
public function getUnknownVector3() : ?Vector3{ return $this->unknownVector3; }
6262

6363
public function getBiomeIdentifier() : string{ return $this->biomeIdentifier; }
6464

@@ -71,8 +71,8 @@ protected function decodePayload(ByteBufferReader $in) : void{
7171
for($i = 0; $i < $count; ++$i){
7272
$this->values[] = ParameterKeyframeValue::read($in);
7373
}
74-
$this->unknownFloat = LE::readFloat($in);
75-
$this->unknownVector3 = CommonTypes::getVector3($in);
74+
$this->unknownFloat = CommonTypes::readOptional($in, LE::readFloat(...));
75+
$this->unknownVector3 = CommonTypes::readOptional($in, CommonTypes::getVector3(...));
7676
$this->biomeIdentifier = CommonTypes::getString($in);
7777
$this->parameterType = GraphicsOverrideParameterType::fromPacket(Byte::readUnsigned($in));
7878
$this->reset = CommonTypes::getBool($in);
@@ -83,8 +83,8 @@ protected function encodePayload(ByteBufferWriter $out) : void{
8383
foreach($this->values as $value){
8484
$value->write($out);
8585
}
86-
LE::writeFloat($out, $this->unknownFloat);
87-
CommonTypes::putVector3($out, $this->unknownVector3);
86+
CommonTypes::writeOptional($out, $this->unknownFloat, LE::writeFloat(...));
87+
CommonTypes::writeOptional($out, $this->unknownVector3, CommonTypes::putVector3(...));
8888
CommonTypes::putString($out, $this->biomeIdentifier);
8989
Byte::writeUnsigned($out, $this->parameterType->value);
9090
CommonTypes::putBool($out, $this->reset);

src/LabTablePacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ public static function create(int $actionType, BlockPosition $blockPosition, int
4444

4545
protected function decodePayload(ByteBufferReader $in) : void{
4646
$this->actionType = Byte::readUnsigned($in);
47-
$this->blockPosition = CommonTypes::getSignedBlockPosition($in);
47+
$this->blockPosition = CommonTypes::getBlockPosition($in);
4848
$this->reactionType = Byte::readUnsigned($in);
4949
}
5050

5151
protected function encodePayload(ByteBufferWriter $out) : void{
5252
Byte::writeUnsigned($out, $this->actionType);
53-
CommonTypes::putSignedBlockPosition($out, $this->blockPosition);
53+
CommonTypes::putBlockPosition($out, $this->blockPosition);
5454
Byte::writeUnsigned($out, $this->reactionType);
5555
}
5656

src/LocatorBarPacket.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 pmmp\encoding\ByteBufferReader;
18+
use pmmp\encoding\ByteBufferWriter;
19+
use pmmp\encoding\VarInt;
20+
use pocketmine\network\mcpe\protocol\types\LocatorBarWaypointPayload;
21+
use function count;
22+
23+
class LocatorBarPacket extends DataPacket{
24+
public const NETWORK_ID = ProtocolInfo::LOCATOR_BAR_PACKET;
25+
26+
/**
27+
* @var LocatorBarWaypointPayload[]
28+
* @phpstan-var list<LocatorBarWaypointPayload>
29+
*/
30+
private array $waypoints;
31+
32+
/**
33+
* @generate-create-func
34+
* @param LocatorBarWaypointPayload[] $waypoints
35+
* @phpstan-param list<LocatorBarWaypointPayload> $waypoints
36+
*/
37+
public static function create(array $waypoints) : self{
38+
$result = new self;
39+
$result->waypoints = $waypoints;
40+
return $result;
41+
}
42+
43+
protected function decodePayload(ByteBufferReader $in) : void{
44+
$this->waypoints = [];
45+
for($i = 0, $len = VarInt::readUnsignedInt($in); $i < $len; ++$i){
46+
$this->waypoints[] = LocatorBarWaypointPayload::read($in);
47+
}
48+
}
49+
50+
protected function encodePayload(ByteBufferWriter $out) : void{
51+
VarInt::writeUnsignedInt($out, count($this->waypoints));
52+
foreach($this->waypoints as $waypoint){
53+
$waypoint->write($out);
54+
}
55+
}
56+
57+
public function handle(PacketHandlerInterface $handler) : bool{
58+
return $handler->handleLocatorBar($this);
59+
}
60+
}

src/NetworkChunkPublisherUpdatePacket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static function create(BlockPosition $blockPosition, int $radius, array $
4646
}
4747

4848
protected function decodePayload(ByteBufferReader $in) : void{
49-
$this->blockPosition = CommonTypes::getSignedBlockPosition($in);
49+
$this->blockPosition = CommonTypes::getBlockPosition($in);
5050
$this->radius = VarInt::readUnsignedInt($in);
5151

5252
$count = LE::readUnsignedInt($in);
@@ -59,7 +59,7 @@ protected function decodePayload(ByteBufferReader $in) : void{
5959
}
6060

6161
protected function encodePayload(ByteBufferWriter $out) : void{
62-
CommonTypes::putSignedBlockPosition($out, $this->blockPosition);
62+
CommonTypes::putBlockPosition($out, $this->blockPosition);
6363
VarInt::writeUnsignedInt($out, $this->radius);
6464

6565
LE::writeUnsignedInt($out, count($this->savedChunks));

0 commit comments

Comments
 (0)