Skip to content

Commit

Permalink
Merge pull request #943 from Hydreon/protocol_400
Browse files Browse the repository at this point in the history
Protocol 400
  • Loading branch information
vchibikov authored Mar 19, 2020
2 parents 72fbc1c + 03cbc0d commit ce9b0dc
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/pocketmine/network/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public function getPacket($id, $playerProtocol){
case Info::PROTOCOL_389:
case Info::PROTOCOL_392:
case Info::PROTOCOL_393:
case Info::PROTOCOL_400:
$class = $this->packetPool331[$id];
break;
case Info::PROTOCOL_310:
Expand All @@ -291,6 +292,7 @@ public function getPacket($id, $playerProtocol){

public static function getChunkPacketProtocol($playerProtocol){
switch ($playerProtocol) {
case Info::PROTOCOL_400:
case Info::PROTOCOL_393:
case Info::PROTOCOL_392:
case Info::PROTOCOL_389:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static function prepareCommands($commands) {
Info::PROTOCOL_389 => new BinaryStream(),
Info::PROTOCOL_392 => new BinaryStream(),
Info::PROTOCOL_393 => new BinaryStream(),
Info::PROTOCOL_400 => new BinaryStream(),
];

foreach ($commands as $commandName => &$commandData) { // Replace &$commandData with $commandData when alises fix for 1.2 won't be needed anymore
Expand Down
1 change: 1 addition & 0 deletions src/pocketmine/network/protocol/DataPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public static function initPackets() {
self::$packetsIds[Info::PROTOCOL_389] = $oClass->getConstants();
self::$packetsIds[Info::PROTOCOL_392] = $oClass->getConstants();
self::$packetsIds[Info::PROTOCOL_393] = $oClass->getConstants();
self::$packetsIds[Info::PROTOCOL_400] = $oClass->getConstants();
}

}
27 changes: 16 additions & 11 deletions src/pocketmine/network/protocol/ExplodePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,23 @@ public function decode($playerProtocol){

public function encode($playerProtocol){
$this->reset($playerProtocol);
$this->putLFloat($this->x);
$this->putLFloat($this->y);
$this->putLFloat($this->z);
$this->putVarInt((int) ($this->radius * 100));
$this->putVarInt(count($this->records));
if(count($this->records) > 0){
foreach($this->records as $record){
$this->putSignedVarInt($record->x);
$this->putSignedVarInt($record->y);
$this->putSignedVarInt($record->z);
if ($playerProtocol < Info::PROTOCOL_386) {
$this->putLFloat($this->x);
$this->putLFloat($this->y);
$this->putLFloat($this->z);
$this->putVarInt((int) ($this->radius * 100));
$this->putVarInt(count($this->records));
if(count($this->records) > 0){
foreach($this->records as $record){
$this->putSignedVarInt($record->x);
$this->putSignedVarInt($record->y);
$this->putSignedVarInt($record->z);
}
}
} else {
//Tick sync packet
$this->putLong(0);
$this->putLong(0);
}
}

}
4 changes: 3 additions & 1 deletion src/pocketmine/network/protocol/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
interface Info{

const CURRENT_PROTOCOL = 120;
const ACCEPTED_PROTOCOLS = [134, 135, 136, 137, 140, 141, 150, 160, 200, 201, 220, 221, 222, 224, 223, 240, 250, 260, 261, 270, 271, 273, 274, 280, 281, 282, 290, 291, 310, 311, 312, 313, 330, 331, 332, 342, 340, 350, 351, 352, 353, 354, 360, 361, 370, 371, 385, 386, 387, 388, 389, 390, 392, 393, 394, 395, 396];
const ACCEPTED_PROTOCOLS = [134, 135, 136, 137, 140, 141, 150, 160, 200, 201, 220, 221, 222, 224, 223, 240, 250, 260, 261, 270, 271, 273, 274, 280, 281, 282, 290, 291, 310, 311, 312, 313, 330, 331, 332, 342, 340, 350, 351, 352, 353, 354, 360, 361, 370, 371, 385, 386, 387, 388, 389, 390, 392, 393, 394, 395, 396, 400];

const PROTOCOL_134 = 134; // 1.2.0.20, 1.2.0.22
const PROTOCOL_135 = 135; // 1.2.0.24, 1.2.0.25
Expand Down Expand Up @@ -87,6 +87,8 @@ interface Info{
const PROTOCOL_394 = 394; // 1.15.0.54
const PROTOCOL_395 = 395; // 1.15.0.55
const PROTOCOL_396 = 396; // 1.15.0.56
const PROTOCOL_400 = 400; // 1.16.0.51


/** OUTDATED (supporting will be removed with next release, may didn't work properly)*/
const PROTOCOL_120 = 120; // 1.2.0.xx (beta)
Expand Down
2 changes: 2 additions & 0 deletions src/pocketmine/network/protocol/PEPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function reset($playerProtocol = 0) {

public final static function convertProtocol($protocol) {
switch ($protocol) {
case Info::PROTOCOL_400:
return Info::PROTOCOL_400;
case Info::PROTOCOL_396:
case Info::PROTOCOL_395:
case Info::PROTOCOL_394:
Expand Down
22 changes: 18 additions & 4 deletions src/pocketmine/network/protocol/StartGamePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ public function encode($playerProtocol){
// Level settings

$this->putSignedVarInt($this->seed);


if ($playerProtocol >= Info::PROTOCOL_400) {
$this->putByte(0);
$this->putByte(0);
$this->putString('');
}

$this->putSignedVarInt($this->dimension);

$this->putSignedVarInt($this->generator);
Expand All @@ -87,6 +93,10 @@ public function encode($playerProtocol){
$this->putByte(1); // hasAchievementsDisabled

$this->putSignedVarInt(0); // DayCycleStopTyme 1x VarInt

if ($playerProtocol >= Info::PROTOCOL_400) {
$this->putByte(0);
}

$this->putByte(0); //edu mode

Expand All @@ -99,7 +109,7 @@ public function encode($playerProtocol){
$this->putLFloat(0); //lightning level

if ($playerProtocol >= Info::PROTOCOL_332) {
$this->putByte(0); // ???
$this->putByte(0); // has confirmed platform Locked Content
}

$this->putByte(1); // is multiplayer game
Expand All @@ -111,8 +121,8 @@ public function encode($playerProtocol){
$this->putByte(1); // Broadcast to XBL?
}

if ($playerProtocol >= Info::PROTOCOL_392) {
$this->putByte(0); // unknown
if ($playerProtocol >= Info::PROTOCOL_392 && $playerProtocol < Info::PROTOCOL_400) {
$this->putByte(0); // unknown
}

$this->putByte(1); // commands enabled
Expand Down Expand Up @@ -177,6 +187,10 @@ public function encode($playerProtocol){
if ($playerProtocol >= Info::PROTOCOL_392) {
$this->putLInt(16); //unknown
$this->putLInt(16); //unknown
if ($playerProtocol >= Info::PROTOCOL_400) {
$this->putByte(0);
}

}

// level settings end
Expand Down
2 changes: 2 additions & 0 deletions src/pocketmine/utils/MetadataConvertor.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public static function updateMeta($meta, $protocol) {

private static function updateMetaIds($meta, $protocol) {
switch ($protocol) {
case Info::PROTOCOL_400:
case Info::PROTOCOL_393:
case Info::PROTOCOL_392:
case Info::PROTOCOL_389:
Expand Down Expand Up @@ -278,6 +279,7 @@ private static function updateEntityFlags($meta, $protocol) {
return $meta;
}
switch ($protocol) {
case Info::PROTOCOL_400:
case Info::PROTOCOL_393:
case Info::PROTOCOL_392:
case Info::PROTOCOL_389:
Expand Down

0 comments on commit ce9b0dc

Please sign in to comment.