Skip to content
Permalink
Browse files

Initial 1.15 support

  • Loading branch information
timmyRS committed Jan 18, 2020
1 parent ec47d52 commit dc1a813a533fa9918338e55f1f845d46142ca316

Large diffs are not rendered by default.

@@ -123,13 +123,7 @@ static function writeBoolean(Connection $con, int $index, bool $value): void
*/
private static function writeType(Connection $con, string $type): void
{
$versions = [
472 => "1.14",
383 => "1.13",
328 => "1.12",
57 => "1.11"
];
foreach($versions as $pv => $v)
foreach(self::versions() as $pv => $v)
{
if($con->protocol_version >= $pv)
{
@@ -151,6 +145,17 @@ private static function writeType(Connection $con, string $type): void
throw new RuntimeException("Unable to write type id for type $type");
}

private static function versions()
{
return [
565 => "1.15",
472 => "1.14",
383 => "1.13",
328 => "1.12",
57 => "1.11"
];
}

/**
* @param Connection $con
* @param int $index
@@ -199,12 +204,6 @@ function read(Connection $con): Metadata
{
if($con->protocol_version >= 57)
{
$versions = [
472 => "1.14",
383 => "1.13",
328 => "1.12",
57 => "1.11"
];
do
{
$index = $con->readUnsignedByte();
@@ -215,7 +214,7 @@ function read(Connection $con): Metadata
$type = $con->readByte();
if(!$this->read_($con, $index))
{
foreach($versions as $pv => $v)
foreach(self::versions() as $pv => $v)
{
if($con->protocol_version >= $pv)
{
@@ -30,6 +30,14 @@ class JoinGamePacket extends Packet
* @var int $render_distance
*/
public $render_distance = 8;
/**
* Set to false when the doImmediateRespawn gamerule is true.
* Only for 1.15+ clients.
*
* @since 0.5.1
* @var bool $enable_respawn_screen
*/
public $enable_respawn_screen = true;

/**
* @param GMP|int|string $eid
@@ -71,6 +79,7 @@ static function read(Connection $con): JoinGamePacket
$packet->render_distance = gmp_intval($con->readVarInt()); // Render Distance
}
$con->ignoreBytes(1); // Reduced Debug Info (Boolean)
$packet->enable_respawn_screen = $con->readBoolean();
return $packet;
}

@@ -104,13 +113,21 @@ function send(Connection $con): void
{
$con->writeByte($this->difficulty);
}
else if($con->protocol_version >= 565)
{
$con->writeLong(0); // Hashed Seed
}
$con->writeByte(100); // Max Players
$con->writeString(""); // Level Type
if($con->protocol_version >= 472)
{
$con->writeVarInt($this->render_distance); // Render Distance
}
$con->writeBoolean(false); // Reduced Debug Info
if($con->protocol_version >= 565)
{
$con->writeBoolean($this->enable_respawn_screen);
}
$con->send();
if($con->protocol_version >= 472)
{
@@ -41,6 +41,7 @@ protected static function populateAllCache_(string $key): void
private static function versions(): array
{
return [
565 => "1.15",
498 => "1.14.4",
472 => "1.14.1",
383 => "1.13",
@@ -24,6 +24,18 @@ static function list(bool $all = true): array
if(!$all)
{
return [
//"1.15.2-pre2" => 567,
//"1.15.2-pre1" => 566,
"1.15.1" => 575,
"1.15.1-pre1" => 574,
"1.15" => 573,
"1.15-pre7" => 572,
"1.15-pre6" => 571,
"1.15-pre5" => 570,
"1.15-pre4" => 569,
"1.15-pre3" => 567,
"1.15-pre2" => 566,
"1.15-pre1" => 565,
"1.14.4" => 498,
"1.14.4-pre7" => 497,
"1.14.4-pre6" => 496,
@@ -190,6 +190,10 @@ function write(Connection $con): void
{
$this->getHeightmap()
->write($con);
if($con->protocol_version >= 565) // Biomes
{
$con->write_buffer .= str_repeat("\x00\x00\x00\x7F", 1024);
}
}
$data = new Connection();
foreach($this->sections as $section)
@@ -277,7 +281,10 @@ function write(Connection $con): void
$data->write_buffer .= str_repeat("\xFF", 2048); // Sky Light
}
}
$data->write_buffer .= str_repeat($con->protocol_version >= 357 ? "\x00\x00\x00\x7F" : "\x00", 256); // Biomes
if($con->protocol_version < 565)
{
$data->write_buffer .= str_repeat($con->protocol_version >= 357 ? "\x00\x00\x00\x7F" : "\x00", 256); // Biomes
}
$con->writeVarInt(strlen($data->write_buffer));
$con->write_buffer .= $data->write_buffer;
if($con->protocol_version >= 110)

0 comments on commit dc1a813

Please sign in to comment.
You can’t perform that action at this time.