Skip to content

Commit b455a74

Browse files
committed
Protocol changes for 1.19.40
1 parent 8da4c73 commit b455a74

6 files changed

+98
-4
lines changed

Diff for: src/AddActorPacket.php

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use pocketmine\network\mcpe\protocol\types\entity\Attribute;
2020
use pocketmine\network\mcpe\protocol\types\entity\EntityLink;
2121
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
22+
use pocketmine\network\mcpe\protocol\types\entity\PropertySyncData;
2223
use function count;
2324

2425
class AddActorPacket extends DataPacket implements ClientboundPacket{
@@ -41,6 +42,7 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{
4142
* @phpstan-var array<int, MetadataProperty>
4243
*/
4344
public array $metadata = [];
45+
public PropertySyncData $syncedProperties;
4446
/** @var EntityLink[] */
4547
public array $links = [];
4648

@@ -63,6 +65,7 @@ public static function create(
6365
float $bodyYaw,
6466
array $attributes,
6567
array $metadata,
68+
PropertySyncData $syncedProperties,
6669
array $links,
6770
) : self{
6871
$result = new self;
@@ -77,6 +80,7 @@ public static function create(
7780
$result->bodyYaw = $bodyYaw;
7881
$result->attributes = $attributes;
7982
$result->metadata = $metadata;
83+
$result->syncedProperties = $syncedProperties;
8084
$result->links = $links;
8185
return $result;
8286
}
@@ -102,6 +106,8 @@ protected function decodePayload(PacketSerializer $in) : void{
102106
}
103107

104108
$this->metadata = $in->getEntityMetadata();
109+
$this->syncedProperties = PropertySyncData::read($in);
110+
105111
$linkCount = $in->getUnsignedVarInt();
106112
for($i = 0; $i < $linkCount; ++$i){
107113
$this->links[] = $in->getEntityLink();
@@ -128,6 +134,8 @@ protected function encodePayload(PacketSerializer $out) : void{
128134
}
129135

130136
$out->putEntityMetadata($this->metadata);
137+
$this->syncedProperties->write($out);
138+
131139
$out->putUnsignedVarInt(count($this->links));
132140
foreach($this->links as $link){
133141
$out->putEntityLink($link);

Diff for: src/AddPlayerPacket.php

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use pocketmine\network\mcpe\protocol\types\DeviceOS;
2020
use pocketmine\network\mcpe\protocol\types\entity\EntityLink;
2121
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
22+
use pocketmine\network\mcpe\protocol\types\entity\PropertySyncData;
2223
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
2324
use Ramsey\Uuid\UuidInterface;
2425
use function count;
@@ -42,6 +43,7 @@ class AddPlayerPacket extends DataPacket implements ClientboundPacket{
4243
* @phpstan-var array<int, MetadataProperty>
4344
*/
4445
public array $metadata = [];
46+
public PropertySyncData $syncedProperties;
4547

4648
public UpdateAbilitiesPacket $abilitiesPacket;
4749

@@ -69,6 +71,7 @@ public static function create(
6971
ItemStackWrapper $item,
7072
int $gameMode,
7173
array $metadata,
74+
PropertySyncData $syncedProperties,
7275
UpdateAbilitiesPacket $abilitiesPacket,
7376
array $links,
7477
string $deviceId,
@@ -87,6 +90,7 @@ public static function create(
8790
$result->item = $item;
8891
$result->gameMode = $gameMode;
8992
$result->metadata = $metadata;
93+
$result->syncedProperties = $syncedProperties;
9094
$result->abilitiesPacket = $abilitiesPacket;
9195
$result->links = $links;
9296
$result->deviceId = $deviceId;
@@ -107,6 +111,7 @@ protected function decodePayload(PacketSerializer $in) : void{
107111
$this->item = ItemStackWrapper::read($in);
108112
$this->gameMode = $in->getVarInt();
109113
$this->metadata = $in->getEntityMetadata();
114+
$this->syncedProperties = PropertySyncData::read($in);
110115

111116
$this->abilitiesPacket = new UpdateAbilitiesPacket();
112117
$this->abilitiesPacket->decodePayload($in);
@@ -133,6 +138,7 @@ protected function encodePayload(PacketSerializer $out) : void{
133138
$this->item->write($out);
134139
$out->putVarInt($this->gameMode);
135140
$out->putEntityMetadata($this->metadata);
141+
$this->syncedProperties->write($out);
136142

137143
$this->abilitiesPacket->encodePayload($out);
138144

Diff for: src/ProtocolInfo.php

+3-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 = 554;
35+
public const CURRENT_PROTOCOL = 557;
3636
/** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */
37-
public const MINECRAFT_VERSION = 'v1.19.30';
37+
public const MINECRAFT_VERSION = 'v1.19.40';
3838
/** Version number sent to clients in ping responses. */
39-
public const MINECRAFT_VERSION_NETWORK = '1.19.30';
39+
public const MINECRAFT_VERSION_NETWORK = '1.19.40';
4040

4141
public const LOGIN_PACKET = 0x01;
4242
public const PLAY_STATUS_PACKET = 0x02;

Diff for: src/SetActorDataPacket.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
1818
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
19+
use pocketmine\network\mcpe\protocol\types\entity\PropertySyncData;
1920

2021
class SetActorDataPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{ //TODO: check why this is serverbound
2122
public const NETWORK_ID = ProtocolInfo::SET_ACTOR_DATA_PACKET;
@@ -26,30 +27,34 @@ class SetActorDataPacket extends DataPacket implements ClientboundPacket, Server
2627
* @phpstan-var array<int, MetadataProperty>
2728
*/
2829
public array $metadata;
30+
public PropertySyncData $syncedProperties;
2931
public int $tick = 0;
3032

3133
/**
3234
* @generate-create-func
3335
* @param MetadataProperty[] $metadata
3436
* @phpstan-param array<int, MetadataProperty> $metadata
3537
*/
36-
public static function create(int $actorRuntimeId, array $metadata, int $tick) : self{
38+
public static function create(int $actorRuntimeId, array $metadata, PropertySyncData $syncedProperties, int $tick) : self{
3739
$result = new self;
3840
$result->actorRuntimeId = $actorRuntimeId;
3941
$result->metadata = $metadata;
42+
$result->syncedProperties = $syncedProperties;
4043
$result->tick = $tick;
4144
return $result;
4245
}
4346

4447
protected function decodePayload(PacketSerializer $in) : void{
4548
$this->actorRuntimeId = $in->getActorRuntimeId();
4649
$this->metadata = $in->getEntityMetadata();
50+
$this->syncedProperties = PropertySyncData::read($in);
4751
$this->tick = $in->getUnsignedVarLong();
4852
}
4953

5054
protected function encodePayload(PacketSerializer $out) : void{
5155
$out->putActorRuntimeId($this->actorRuntimeId);
5256
$out->putEntityMetadata($this->metadata);
57+
$this->syncedProperties->write($out);
5358
$out->putUnsignedVarLong($this->tick);
5459
}
5560

Diff for: src/types/UpdateAbilitiesPacketLayer.php

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ final class UpdateAbilitiesPacketLayer{
2323
public const LAYER_BASE = 1;
2424
public const LAYER_SPECTATOR = 2;
2525
public const LAYER_COMMANDS = 3;
26+
public const LAYER_EDITOR = 4;
2627

2728
public const ABILITY_BUILD = 0;
2829
public const ABILITY_MINE = 1;

Diff for: src/types/entity/PropertySyncData.php

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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\types\entity;
16+
17+
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
18+
use function count;
19+
20+
final class PropertySyncData{
21+
/**
22+
* @param int[] $intProperties
23+
* @param float[] $floatProperties
24+
* @phpstan-param array<int, int> $intProperties
25+
* @phpstan-param array<int, float> $floatProperties
26+
*/
27+
public function __construct(
28+
private array $intProperties,
29+
private array $floatProperties,
30+
){}
31+
32+
/**
33+
* @return int[]
34+
* @phpstan-return array<int, int>
35+
*/
36+
public function getIntProperties() : array{
37+
return $this->intProperties;
38+
}
39+
40+
/**
41+
* @return float[]
42+
* @phpstan-return array<int, float>
43+
*/
44+
public function getFloatProperties() : array{
45+
return $this->floatProperties;
46+
}
47+
48+
public static function read(PacketSerializer $in) : self{
49+
$intProperties = [];
50+
$floatProperties = [];
51+
52+
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
53+
$intProperties[$in->getUnsignedVarInt()] = $in->getVarInt();
54+
}
55+
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
56+
$floatProperties[$in->getUnsignedVarInt()] = $in->getLFloat();
57+
}
58+
59+
return new self($intProperties, $floatProperties);
60+
}
61+
62+
public function write(PacketSerializer $out) : void{
63+
$out->putUnsignedVarInt(count($this->intProperties));
64+
foreach($this->intProperties as $key => $value){
65+
$out->putUnsignedVarInt($key);
66+
$out->putVarInt($value);
67+
}
68+
$out->putUnsignedVarInt(count($this->floatProperties));
69+
foreach($this->floatProperties as $key => $value){
70+
$out->putUnsignedVarInt($key);
71+
$out->putLFloat($value);
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)