Skip to content

Commit

Permalink
1.20.60 support with backward compability
Browse files Browse the repository at this point in the history
  • Loading branch information
AkmalFairuz committed Feb 7, 2024
1 parent 959312b commit 5296dbd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/LevelChunkPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public function getExtraPayload() : string{

protected function decodePayload(PacketSerializer $in) : void{
$this->chunkPosition = ChunkPosition::read($in);
$this->dimensionId = $in->getVarInt();
if($in->getProtocol() >= ProtocolInfo::PROTOCOL_649){
$this->dimensionId = $in->getVarInt();
}

$subChunkCountButNotReally = $in->getUnsignedVarInt();
if($subChunkCountButNotReally === self::CLIENT_REQUEST_FULL_COLUMN_FAKE_COUNT){
Expand Down Expand Up @@ -121,7 +123,9 @@ protected function decodePayload(PacketSerializer $in) : void{

protected function encodePayload(PacketSerializer $out) : void{
$this->chunkPosition->write($out);
$out->putVarInt($this->dimensionId);
if($out->getProtocol() >= ProtocolInfo::PROTOCOL_649){
$out->putVarInt($this->dimensionId);
}

if($this->clientSubChunkRequestsEnabled){
if($this->subChunkCount === PHP_INT_MAX){
Expand Down
12 changes: 8 additions & 4 deletions src/PlayerAuthInputPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,10 @@ protected function decodePayload(PacketSerializer $in) : void{
};
}
}
if($this->hasFlag(PlayerAuthInputFlags::IN_CLIENT_PREDICTED_VEHICLE)){
$this->clientPredictedVehicleActorUniqueId = $in->getActorUniqueId();
if($in->getProtocol() >= ProtocolInfo::PROTOCOL_649){
if($this->hasFlag(PlayerAuthInputFlags::IN_CLIENT_PREDICTED_VEHICLE)){
$this->clientPredictedVehicleActorUniqueId = $in->getActorUniqueId();
}
}
if($in->getProtocol() >= ProtocolInfo::PROTOCOL_575){
$this->analogMoveVecX = $in->getLFloat();
Expand Down Expand Up @@ -291,8 +293,10 @@ protected function encodePayload(PacketSerializer $out) : void{
$blockAction->write($out);
}
}
if($this->clientPredictedVehicleActorUniqueId !== null){
$out->putActorUniqueId($this->clientPredictedVehicleActorUniqueId);
if($out->getProtocol() >= ProtocolInfo::PROTOCOL_649){
if($this->clientPredictedVehicleActorUniqueId !== null){
$out->putActorUniqueId($this->clientPredictedVehicleActorUniqueId);
}
}
if($out->getProtocol() >= ProtocolInfo::PROTOCOL_575){
$out->putLFloat($this->analogMoveVecX);
Expand Down
8 changes: 6 additions & 2 deletions src/PlayerListPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ protected function decodePayload(PacketSerializer $in) : void{
$entry->skinData = $in->getSkin();
$entry->isTeacher = $in->getBool();
$entry->isHost = $in->getBool();
$entry->isSubClient = $in->getBool();
if($in->getProtocol() >= ProtocolInfo::PROTOCOL_649){
$entry->isSubClient = $in->getBool();
}
}else{
$entry->uuid = $in->getUUID();
}
Expand Down Expand Up @@ -97,7 +99,9 @@ protected function encodePayload(PacketSerializer $out) : void{
$out->putSkin($entry->skinData);
$out->putBool($entry->isTeacher);
$out->putBool($entry->isHost);
$out->putBool($entry->isSubClient);
if($out->getProtocol() >= ProtocolInfo::PROTOCOL_649){
$out->putBool($entry->isSubClient);
}
}else{
$out->putUUID($entry->uuid);
}
Expand Down
2 changes: 2 additions & 0 deletions src/ProtocolInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ private function __construct(){

public const BASE_VERSION = '1.18.0';

public const PROTOCOL_649 = 649; // 1.20.60
public const PROTOCOL_630 = 630; // 1.20.50
public const PROTOCOL_622 = 622; // 1.20.40
public const PROTOCOL_618 = 618; // 1.20.30
Expand All @@ -61,6 +62,7 @@ private function __construct(){
public const PROTOCOL_475 = 475; // v1.18.0

public const COMPATIBLE_PROTOCOL = [
self::PROTOCOL_649,
self::PROTOCOL_630,
self::PROTOCOL_622,
self::PROTOCOL_618,
Expand Down

0 comments on commit 5296dbd

Please sign in to comment.