public function putLInt($v) { $this->buffer .= Binary::writeLInt($v); }
public static function chunkIndex($chunkX, $chunkZ) { return Binary::writeLInt($chunkX) . Binary::writeLInt($chunkZ); }
public function writeChunk($X, $Z) { $X = (int) $X; $Z = (int) $Z; if (!isset($this->map[$X][$Z])) { return false; } $chunk = ""; foreach ($this->map[$X][$Z] as $section => $data) { for ($i = 0; $i < 256; ++$i) { $chunk .= $data[$i]; } } return Binary::writeLInt(strlen($chunk)) . $chunk; }
private function writePacket($client, $requestID, $packetType, $payload) { $pk = Binary::writeLInt((int) $requestID) . Binary::writeLInt((int) $packetType) . $payload . ""; //Terminate payload and packet return socket_write($client, Binary::writeLInt(strlen($pk)) . $pk); }
public function putInt($v) { $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Binary::writeInt($v) : Binary::writeLInt($v); }
public function onRun() { $orderedIds = ""; $orderedData = ""; $orderedSkyLight = ""; $orderedLight = ""; $ids = ""; $meta = ""; $blockLight = ""; $skyLight = ""; foreach ($this->sections as $section) { $ids .= $section->getIdArray(); $meta .= $section->getDataArray(); $blockLight .= $section->getLightArray(); $skyLight .= $section->getSkyLightArray(); } for ($x = 0; $x < 16; ++$x) { for ($z = 0; $z < 16; ++$z) { $orderedIds .= $this->getColumn($ids, $x, $z); $orderedData .= $this->getHalfColumn($meta, $x, $z); $orderedSkyLight .= $this->getHalfColumn($skyLight, $x, $z); $orderedLight .= $this->getHalfColumn($blockLight, $x, $z); } } $biomeColors = pack("N*", ...$this->biomeColors); $ordered = zlib_encode(Binary::writeLInt($this->chunkX) . Binary::writeLInt($this->chunkZ) . $orderedIds . $orderedData . $orderedSkyLight . $orderedLight . $this->biomeIds . $biomeColors . $this->tiles, ZLIB_ENCODING_DEFLATE, $this->compressionLevel); $this->setResult($ordered); }
public function requestChunkTask($x, $z) { $chunk = $this->getChunk($x, $z, false); if (!$chunk instanceof Chunk) { throw new \Exception("Invalid Chunk sent"); } $tiles = ""; $nbt = new NBT(NBT::LITTLE_ENDIAN); foreach ($chunk->getTiles() as $tile) { if ($tile instanceof Spawnable) { $nbt->setData($tile->getSpawnCompound()); $tiles .= $nbt->write(); } } $biomeColors = pack("N*", ...$chunk->getBiomeColorArray()); $ordered = zlib_encode(Binary::writeLInt($x) . Binary::writeLInt($z) . $chunk->getBlockIdArray() . $chunk->getBlockDataArray() . $chunk->getBlockSkyLightArray() . $chunk->getBlockLightArray() . $chunk->getBiomeIdArray() . $biomeColors . $tiles, ZLIB_ENCODING_DEFLATE, Level::$COMPRESSION_LEVEL); $this->getLevel()->chunkRequestCallback($x, $z, $ordered); return null; }
public function putInt($v, bool $network = false) { if ($network === true) { $this->buffer .= Binary::writeVarInt($v); } else { $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Binary::writeInt($v) : Binary::writeLInt($v); } }
public function putInt($int) { $this->buffer .= Binary::writeLInt($int); }