Skip to content

Commit 72a9291

Browse files
committed
Add 1.20.60 MP
1 parent 72a8c69 commit 72a9291

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

src/ClientMovementPredictionSyncPacket.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function getActorUniqueId() : int{ return $this->actorUniqueId; }
117117
public function getActorFlyingState() : bool{ return $this->actorFlyingState; }
118118

119119
protected function decodePayload(PacketSerializer $in) : void{
120-
$this->flags = BitSet::read($in, self::FLAG_LENGTH);
120+
$this->flags = BitSet::read($in, $in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_70 ? self::FLAG_LENGTH : 120);
121121
$this->scale = $in->getLFloat();
122122
$this->width = $in->getLFloat();
123123
$this->height = $in->getLFloat();
@@ -128,11 +128,13 @@ protected function decodePayload(PacketSerializer $in) : void{
128128
$this->health = $in->getLFloat();
129129
$this->hunger = $in->getLFloat();
130130
$this->actorUniqueId = $in->getActorUniqueId();
131-
$this->actorFlyingState = $in->getBool();
131+
if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_70){
132+
$this->actorFlyingState = $in->getBool();
133+
}
132134
}
133135

134136
protected function encodePayload(PacketSerializer $out) : void{
135-
$this->flags->write($out);
137+
$this->flags->write($out, $out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_70 ? self::FLAG_LENGTH : 120);
136138
$out->putLFloat($this->scale);
137139
$out->putLFloat($this->width);
138140
$out->putLFloat($this->height);
@@ -143,7 +145,9 @@ protected function encodePayload(PacketSerializer $out) : void{
143145
$out->putLFloat($this->health);
144146
$out->putLFloat($this->hunger);
145147
$out->putActorUniqueId($this->actorUniqueId);
146-
$out->putBool($this->actorFlyingState);
148+
if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_70){
149+
$out->putBool($this->actorFlyingState);
150+
}
147151
}
148152

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

src/LevelSoundEventPacket.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ protected function decodePayload(PacketSerializer $in) : void{
6464
$this->entityType = $in->getString();
6565
$this->isBabyMob = $in->getBool();
6666
$this->disableRelativeVolume = $in->getBool();
67-
$this->actorUniqueId = $in->getLLong(); //WHY IS THIS NON-STANDARD?
67+
if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_70){
68+
$this->actorUniqueId = $in->getLLong(); //WHY IS THIS NON-STANDARD?
69+
}
6870
}
6971

7072
protected function encodePayload(PacketSerializer $out) : void{
@@ -74,7 +76,9 @@ protected function encodePayload(PacketSerializer $out) : void{
7476
$out->putString($this->entityType);
7577
$out->putBool($this->isBabyMob);
7678
$out->putBool($this->disableRelativeVolume);
77-
$out->putLLong($this->actorUniqueId);
79+
if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_70){
80+
$out->putLLong($this->actorUniqueId);
81+
}
7882
}
7983

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

src/SetHudPacket.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,25 @@ public function getVisibility() : HudVisibility{ return $this->visibility; }
4545
protected function decodePayload(PacketSerializer $in) : void{
4646
$this->hudElements = [];
4747
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
48-
$this->hudElements[] = HudElement::fromPacket($in->getVarInt());
48+
$this->hudElements[] = HudElement::fromPacket($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_70 ? $in->getVarInt() : $in->getByte());
4949
}
50-
$this->visibility = HudVisibility::fromPacket($in->getVarInt());
50+
$this->visibility = HudVisibility::fromPacket($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_70 ? $in->getVarInt() : $in->getByte());
5151
}
5252

5353
protected function encodePayload(PacketSerializer $out) : void{
5454
$out->putUnsignedVarInt(count($this->hudElements));
5555
foreach($this->hudElements as $element){
56-
$out->putVarInt($element->value);
56+
if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_70){
57+
$out->putVarInt($element->value);
58+
}else{
59+
$out->putByte($element->value);
60+
}
61+
}
62+
if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_70){
63+
$out->putVarInt($this->visibility->value);
64+
}else{
65+
$out->putByte($this->visibility->value);
5766
}
58-
$out->putVarInt($this->visibility->value);
5967
}
6068

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

src/types/login/ClientData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ final class ClientData{
6767
/** @required */
6868
public string $GameVersion;
6969

70-
/** @required */
70+
/** >= ProtocolInfo::PROTOCOL_1_21_70 */
7171
public int $GraphicsMode;
7272

7373
/** @required */

0 commit comments

Comments
 (0)