I load the area from the file. Everything loads correctly. After a few minutes some parts disappear ... A little bit later... After restarting the server, almost 80% is lost Why? Spoiler: AsyncTask PHP: class LoadTask extends AsyncTask{ private $target; private $file; public function __construct($target, $file){ $this->target = json_decode($target, true); //$this->target = $target; $this->file = $file; } public function onRun() { } public function onCompletion(Server $server) { $nbt = new BigEndianNBTStream(); $data = $nbt->readCompressed(file_get_contents($this->file)); $width = (int)$data->getShort("Width"); $height = (int)$data->getShort("Height"); $length = (int)$data->getShort("Length"); if($data->offsetExists("Materials")) { $materials = $data->getString("Materials"); } if ($data->offsetExists("Blocks") && $data->offsetExists("Data")) { $blocks = $data->getByteArray("Blocks"); $data_damage = $data->getByteArray("Data"); $types = $data->getByteArray("Type"); $i = 0; $world = $server->getLevelByName($this->target['world']); $iterator = new ChunkIterator($world); for($y = 0; $y < $height; $y++) { for ($z = 0; $z < $length; $z++) { for($x = 0; $x < $width; $x++) { $id = ord($blocks{$i}); $damage = ord($data_damage{$i}); if($damage >= 16) { // prevents bug $damage = 0; } $type = ord($types{$i}); if($type >= 16) { // prevents bug $type = 0; } $block = new Block($id, $damage); $pos = new Position($x + $this->target['x'], $y + $this->target['y'], $z + $this->target['z'], $world); $block->x = $pos->getX(); $block->y = $pos->getY(); $block->z = $pos->getZ(); $block->level = $pos->getLevel(); SpecialHelper::setBlock($pos, $block, $iterator, $type); $i++; } } } $max_x = $this->target['x'] + $width; $max_z = $this->target['z'] + $length; SpecialHelper::updateData($world, $this->target['x'] >> 4, $max_x >> 4, $this->target['z'] >> 4, $max_z >> 4); } }} Spoiler: SpecialHelper setBlock PHP: $iterator->moveTo($pos->getX(), $pos->getY(), $pos->getZ()); $iterator->currentSubChunk->setBlock($pos->getX() & 0x0f, $pos->getY() & 0x0f, $pos->getZ() & 0x0f, $block->getId(), $block->getDamage()); Spoiler: ChunkIterator PHP: class ChunkIterator extends SubChunkIteratorManager { public function moveTo(int $x, int $y, int $z): bool { if (parent::moveTo($x, $y, $z)) { return true; } if ($this->currentSubChunk === null) { $this->currentSubChunl = $this->level->getChunk($this->currentX, $this->currentZ)->getSubChunk($y >> 4, $this->allocateEmptySubs); return true; } return false; }}
Do you have autosave disabled? Use /save-on to enable autosave. Also, you have a typo in your ChunkIterator.
Problem still exists.. Blocks gradually disappear. After the reboot disappears 100%. P.S. $world->save(); - no result