Skip to content
This repository was archived by the owner on Sep 12, 2022. It is now read-only.

Loading large Schematic #20

Open
benda95280 opened this issue Jun 1, 2020 · 8 comments · May be fixed by #21
Open

Loading large Schematic #20

benda95280 opened this issue Jun 1, 2020 · 8 comments · May be fixed by #21

Comments

@benda95280
Copy link

Hello,

I've tried to load a 'Large' schematic (near 2Mb), and was having error like that :

2020-06-01 [22:26:40] [Server thread/CRITICAL]: Error: "Call to a member function getSubChunk() on null" (EXCEPTION) in "plugins/WorldStyler_dev-11.phar/src/muqsit/worldstyler/utils/BlockIterator" at line 17
2020-06-01 [22:26:40] [Server thread/DEBUG]: #0 plugins/WorldStyler_dev-11.phar/src/muqsit/worldstyler/schematics/Schematic(89): muqsit\worldstyler\utils\BlockIterator->moveTo(integer 352, integer 65, integer 448)
2020-06-01 [22:26:40] [Server thread/DEBUG]: #1 plugins/WorldStyler_dev-11.phar/src/muqsit/worldstyler/executors/SchemCommandExecutor(75): muqsit\worldstyler\schematics\Schematic->paste(object pocketmine\level\Level, object pocketmine\math\Vector3, boolean 1, object Closure)
2020-06-01 [22:26:40] [Server thread/DEBUG]: #2 plugins/WorldStyler_dev-11.phar/src/muqsit/worldstyler/executors/BaseCommandExecutor(85): muqsit\worldstyler\executors\SchemCommandExecutor->onCommandExecute(object pocketmine\Player, object pocketmine\command\PluginCommand, string[6] /schem, array[2], array[0])

I've been able to fix it by do a modification on "BlockIterator.php" :

			if (!$this->level->isChunkLoaded( $this->currentX, $this->currentZ )) {
					$this->level->loadChunk ( $this->currentX, $this->currentZ );
			}
			$this->currentSubChunk = $this->level->getChunk($this->currentX, $this->currentZ)->getSubChunk($y >> 4, $this->allocateEmptySubs);
            return true;

But now, i've a message saying everything has been done, but there is missing parts.
Tried multiple time, sometimes the result is not the same. The first time, never got the message saying it was finished ...

Is it possible to have support ?
Minecraft 01_06_2020 23_56_40

@benda95280
Copy link
Author

benda95280 commented Jun 1, 2020

New attempt to show difference :
Minecraft 02_06_2020 00_02_02
Minecraft 02_06_2020 00_03_03

@jasonw4331
Copy link
Contributor

Increase your maximum memory allocation in the pocketmine.yml

@benda95280
Copy link
Author

Already done (While trying to get it works with others plugins).
WorldStyler do not use so much memory, other plugins was over 3Gb of memory and crash)
Currently it's 4GB in PHP and PocketMine configuration files.

@benda95280
Copy link
Author

Tried to add a pause after LoadChuck, result is always different

@Muqsit
Copy link
Owner

Muqsit commented Jun 2, 2020

There isn't really an easy way to solve this.
Chunk generation is asynchronous. The plugin would need to wait until the chunk being modified is generated so the world generator doesn't overwrite the changes - will need to probably do something that https://github.com/Wumpotamus/libChunkLoader does.

@benda95280
Copy link
Author

I'm not able to understand/find a way how to implement it :/

@benda95280
Copy link
Author

benda95280 commented Jun 2, 2020

Tried implentation like that in Schematic.php, line 90 :

                    $yPos = $y + $rely;
					ChunkRegion::onChunkGenerated($level, $xPos >> 4, $zPos >> 4, function() use($iterator, $xPos, $yPos, $zPos, $id, $damage){
						$iterator->moveTo($xPos, $yPos, $zPos);
						$iterator->currentSubChunk->setBlock($xPos & 0x0f, $yPos & 0x0f, $zPos & 0x0f, $id, $damage);
					});

image

After, server shutdown when over 4Gb of memory ...

EDIT: It seems to have done near 1/4 of the work :
Minecraft 02_06_2020 18_13_24

@benda95280 benda95280 linked a pull request Jun 2, 2020 that will close this issue
@benda95280
Copy link
Author

#21 => Seems to be able to load near everything !
Minecraft 03_06_2020 01_18_43

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants