private function chunkExists($chunkX, $chunkZ) { return $this->db->get(LevelDB::chunkIndex($chunkX, $chunkZ) . self::ENTRY_VERSION) !== false; }
private function chunkExists($chunkX, $chunkZ) { return $this->db->get(LevelDB::chunkIndex($chunkX, $chunkZ) . "v") !== false; }
public function toBinary($saveExtra = false) { $chunkIndex = LevelDB::chunkIndex($this->getX(), $this->getZ()); $provider = $this->getProvider(); if ($saveExtra and $provider instanceof LevelDB) { $nbt = new NBT(NBT::LITTLE_ENDIAN); $entities = []; foreach ($this->getEntities() as $entity) { if (!$entity instanceof Player and !$entity->closed) { $entity->saveNBT(); $nbt->setData($entity->namedtag); $entities[] = $nbt->write(); } } if (count($entities) > 0) { $provider->getDatabase()->put($chunkIndex . "2", implode($entities)); } else { $provider->getDatabase()->delete($chunkIndex . "2"); } $tiles = []; foreach ($this->getTiles() as $tile) { if (!$tile->closed) { $tile->saveNBT(); $nbt->setData($tile->namedtag); $tiles[] = $nbt->write(); } } if (count($tiles) > 0) { $provider->getDatabase()->put($chunkIndex . "1", implode($tiles)); } else { $provider->getDatabase()->delete($chunkIndex . "1"); } } $biomeColors = pack("N*", ...$this->getBiomeColorArray()); return $chunkIndex . $this->getBlockIdArray() . $this->getBlockDataArray() . $this->getBlockSkyLightArray() . $this->getBlockLightArray() . $this->getBiomeIdArray() . $biomeColors . chr(($this->isPopulated() ? 0x2 : 0) | ($this->isGenerated() ? 0x1 : 0)); }
public function toBinary($saveExtra = \false) { $chunkIndex = LevelDB::chunkIndex($this->getX(), $this->getZ()); $provider = $this->getProvider(); if ($saveExtra and $provider instanceof LevelDB) { $nbt = new NBT(NBT::LITTLE_ENDIAN); $entities = []; foreach ($this->getEntities() as $entity) { if (!$entity instanceof Player and !$entity->closed) { $entity->saveNBT(); $entities[] = $entity->namedtag; } } if (\count($entities) > 0) { $nbt->setData($entities); $provider->getDatabase()->put($chunkIndex . LevelDB::ENTRY_ENTITIES, $nbt->write()); } else { $provider->getDatabase()->delete($chunkIndex . LevelDB::ENTRY_ENTITIES); } $tiles = []; foreach ($this->getTiles() as $tile) { if (!$tile->closed) { $tile->saveNBT(); $tiles[] = $tile->namedtag; } } if (\count($tiles) > 0) { $nbt->setData($tiles); $provider->getDatabase()->put($chunkIndex . LevelDB::ENTRY_TILES, $nbt->write()); } else { $provider->getDatabase()->delete($chunkIndex . LevelDB::ENTRY_TILES); } if (\count($this->getBlockExtraDataArray()) > 0) { $extraData = new BinaryStream(); $extraData->putInt(\count($this->getBlockExtraDataArray())); foreach ($this->getBlockExtraDataArray() as $key => $value) { $extraData->putInt($key); $extraData->putShort($value); } $provider->getDatabase()->put($chunkIndex . LevelDB::ENTRY_EXTRA_DATA, $extraData->getBuffer()); } else { $provider->getDatabase()->delete($chunkIndex . LevelDB::ENTRY_EXTRA_DATA); } } $heightmap = \pack("C*", ...$this->getHeightMapArray()); $biomeColors = \pack("N*", ...$this->getBiomeColorArray()); return $chunkIndex . $this->getBlockIdArray() . $this->getBlockDataArray() . $this->getBlockSkyLightArray() . $this->getBlockLightArray() . $heightmap . $biomeColors . \chr(($this->isLightPopulated() ? 0x4 : 0) | ($this->isPopulated() ? 0x2 : 0) | ($this->isGenerated() ? 0x1 : 0)); }