From 8ae9cd4eafc0de20ee335c2641c205e2b5a37dfd Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 19 Mar 2015 15:41:26 +0100 Subject: [PATCH 1/4] Clone initial chunk in Flat.php The Flat generator destroys Chunk at 0,0. What happens is that it request the level to read Chunk at 0,0. It then uses that chunk to create the template chunk. However this obliterates whatever was in Chunk at 0,0. Added a line to "clone" this chunk, so when parsePreset generates the template chunk, all this goes to a copy rather than the original file chunk 0,0. --- src/pocketmine/level/generator/Flat.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/level/generator/Flat.php b/src/pocketmine/level/generator/Flat.php index 0aa190204..a4e15f7b9 100644 --- a/src/pocketmine/level/generator/Flat.php +++ b/src/pocketmine/level/generator/Flat.php @@ -106,7 +106,7 @@ class Flat extends Generator{ } - $this->chunk = $this->level->getChunk(0, 0); + $this->chunk = clone $this->level->getChunk(0, 0); $this->chunk->setGenerated(); for($Z = 0; $Z < 16; ++$Z){ @@ -165,4 +165,4 @@ class Flat extends Generator{ public function getSpawn(){ return new Vector3(128, $this->floorLevel, 128); } -} \ No newline at end of file +} From 1d1a8a316e7fd7ba6a206ffc9df9cb411a79ad16 Mon Sep 17 00:00:00 2001 From: Alejandro Liu Date: Fri, 20 Mar 2015 08:13:55 +0100 Subject: [PATCH 2/4] Take-2: Delay "parsePreset" until we have to really generate a block --- src/pocketmine/level/generator/Flat.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/level/generator/Flat.php b/src/pocketmine/level/generator/Flat.php index a4e15f7b9..2264c1ea8 100644 --- a/src/pocketmine/level/generator/Flat.php +++ b/src/pocketmine/level/generator/Flat.php @@ -59,6 +59,7 @@ class Flat extends Generator{ $this->preset = "2;7,2x3,2;1;"; //$this->preset = "2;7,59x1,3x3,2;1;spawn(radius=10 block=89),decoration(treecount=80 grasscount=45)"; $this->options = $options; + $this->chunk = null; if(isset($this->options["decoration"])){ $ores = new Ore(); @@ -80,7 +81,7 @@ class Flat extends Generator{ }*/ } - protected function parsePreset($preset){ + protected function parsePreset($preset, $chunkX, $chunkZ){ $this->preset = $preset; $preset = explode(";", $preset); $version = (int) $preset[0]; @@ -106,7 +107,7 @@ class Flat extends Generator{ } - $this->chunk = clone $this->level->getChunk(0, 0); + $this->chunk = $this->level->getChunk($chunkX, $chunkZ); $this->chunk->setGenerated(); for($Z = 0; $Z < 16; ++$Z){ @@ -139,15 +140,24 @@ class Flat extends Generator{ $this->level = $level; $this->random = $random; + /* + // Commented out : We want to delay this if(isset($this->options["preset"]) and $this->options["preset"] != ""){ $this->parsePreset($this->options["preset"]); }else{ $this->parsePreset($this->preset); } - + */ } public function generateChunk($chunkX, $chunkZ){ + if($this->chunk === null) { + if(isset($this->options["preset"]) and $this->options["preset"] != ""){ + $this->parsePreset($this->options["preset"], $chunkX, $chunkZ); + }else{ + $this->parsePreset($this->preset, $chunkX, $chunkZ); + } + } $chunk = clone $this->chunk; $chunk->setX($chunkX); $chunk->setZ($chunkZ); From c68cd2c49623e94f1f02219d2fa8dfaf44cea8e6 Mon Sep 17 00:00:00 2001 From: Alejandro Liu Date: Mon, 23 Mar 2015 10:28:29 +0100 Subject: [PATCH 3/4] Cloned the initial empty chunk --- src/pocketmine/level/generator/Flat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/level/generator/Flat.php b/src/pocketmine/level/generator/Flat.php index 2264c1ea8..edaf7cb19 100644 --- a/src/pocketmine/level/generator/Flat.php +++ b/src/pocketmine/level/generator/Flat.php @@ -107,7 +107,7 @@ class Flat extends Generator{ } - $this->chunk = $this->level->getChunk($chunkX, $chunkZ); + $this->chunk = clone $this->level->getChunk($chunkX, $chunkZ); $this->chunk->setGenerated(); for($Z = 0; $Z < 16; ++$Z){ From 4a79c65544bdfdc56bbddb38813fc9d898f0479d Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 24 Mar 2015 23:47:33 +0100 Subject: [PATCH 4/4] Corrected MINECART constant definition on Item.php MINECART was defined as 329, where it should be 328. --- src/pocketmine/item/Item.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index c8f85de3c..71d081c50 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -316,7 +316,7 @@ class Item{ const WOODEN_DOOR = 324; const BUCKET = 325; - const MINECART = 329; + const MINECART = 328; const IRON_DOOR = 330; const REDSTONE = 331; @@ -656,4 +656,4 @@ class Item{ return $this->id === $item->getId() and ($checkDamage === false or $this->getDamage() === $item->getDamage()); } -} \ No newline at end of file +}