54 public static function create(
ChunkPosition $chunkPosition,
int $dimensionId,
int $subChunkCount,
bool $clientSubChunkRequestsEnabled, ?array $usedBlobHashes,
string $extraPayload) : self{
56 $result->chunkPosition = $chunkPosition;
57 $result->dimensionId = $dimensionId;
58 $result->subChunkCount = $subChunkCount;
59 $result->clientSubChunkRequestsEnabled = $clientSubChunkRequestsEnabled;
60 $result->usedBlobHashes = $usedBlobHashes;
61 $result->extraPayload = $extraPayload;
97 if($subChunkCountButNotReally === self::CLIENT_REQUEST_FULL_COLUMN_FAKE_COUNT){
98 $this->clientSubChunkRequestsEnabled =
true;
99 $this->subChunkCount = PHP_INT_MAX;
100 }elseif($subChunkCountButNotReally === self::CLIENT_REQUEST_TRUNCATED_COLUMN_FAKE_COUNT){
101 $this->clientSubChunkRequestsEnabled =
true;
104 $this->clientSubChunkRequestsEnabled =
false;
105 $this->subChunkCount = $subChunkCountButNotReally;
108 $cacheEnabled = $in->
getBool();
110 $this->usedBlobHashes = [];
112 if($count > self::MAX_BLOB_HASHES){
113 throw new PacketDecodeException(
"Expected at most " . self::MAX_BLOB_HASHES .
" blob hashes, got " . $count);
115 for($i = 0; $i < $count; ++$i){
116 $this->usedBlobHashes[] = $in->
getLLong();
123 $this->chunkPosition->write($out);
126 if($this->clientSubChunkRequestsEnabled){
127 if($this->subChunkCount === PHP_INT_MAX){
131 $out->putLShort($this->subChunkCount);
137 $out->putBool($this->usedBlobHashes !==
null);
138 if($this->usedBlobHashes !==
null){
140 foreach($this->usedBlobHashes as $hash){
141 $out->putLLong($hash);
144 $out->putString($this->extraPayload);