writeLInt() публичный статический Метод

public static writeLInt ( $value )
Пример #1
0
 public function putLInt($v)
 {
     $this->buffer .= Binary::writeLInt($v);
 }
Пример #2
0
 public static function chunkIndex($chunkX, $chunkZ)
 {
     return Binary::writeLInt($chunkX) . Binary::writeLInt($chunkZ);
 }
Пример #3
0
 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;
 }
Пример #4
0
 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);
 }
Пример #5
0
 public function putInt($v)
 {
     $this->buffer .= $this->endianness === self::BIG_ENDIAN ? Binary::writeInt($v) : Binary::writeLInt($v);
 }
Пример #6
0
 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);
 }
Пример #7
0
 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;
 }
Пример #8
0
 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);
     }
 }
Пример #9
0
 public function putInt($int)
 {
     $this->buffer .= Binary::writeLInt($int);
 }