From b66f49dc5e074e82e4417bc4f24d67a94a91d8cb Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 19 Aug 2014 11:37:02 +0200 Subject: [PATCH] Fixed infinite recursion when setting a block on an EmptyChunkSection --- src/pocketmine/level/format/generic/BaseChunk.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/level/format/generic/BaseChunk.php b/src/pocketmine/level/format/generic/BaseChunk.php index a89438fcb..ca77803a8 100644 --- a/src/pocketmine/level/format/generic/BaseChunk.php +++ b/src/pocketmine/level/format/generic/BaseChunk.php @@ -152,7 +152,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ return $this->sections[$y >> 4]->setBlock($x, $y & 0x0f, $z, $blockId & 0xff, $meta & 0x0f); }catch(\Exception $e){ $level = $this->getProvider(); - $this->setSection($Y = $y >> 4, $level::createChunkSection($Y)); + $this->setInternalSection($Y = $y >> 4, $level::createChunkSection($Y)); return $this->setBlock($x, $y, $z, $blockId, $meta); } } @@ -166,7 +166,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ $this->sections[$y >> 4]->setBlockId($x, $y & 0x0f, $z, $id); }catch(\Exception $e){ $level = $this->getProvider(); - $this->setSection($Y = $y >> 4, $level::createChunkSection($Y)); + $this->setInternalSection($Y = $y >> 4, $level::createChunkSection($Y)); $this->setBlockId($x, $y, $z, $id); } } @@ -180,7 +180,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ $this->sections[$y >> 4]->setBlockData($x, $y & 0x0f, $z, $data); }catch(\Exception $e){ $level = $this->getProvider(); - $this->setSection($Y = $y >> 4, $level::createChunkSection($Y)); + $this->setInternalSection($Y = $y >> 4, $level::createChunkSection($Y)); $this->setBlockData($x, $y, $z, $data); } } @@ -194,7 +194,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ $this->sections[$y >> 4]->getBlockSkyLight($x, $y & 0x0f, $z, $data); }catch(\Exception $e){ $level = $this->getProvider(); - $this->setSection($Y = $y >> 4, $level::createChunkSection($Y)); + $this->setInternalSection($Y = $y >> 4, $level::createChunkSection($Y)); $this->setBlockSkyLight($x, $y, $z, $data); } } @@ -208,7 +208,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ $this->sections[$y >> 4]->getBlockSkyLight($x, $y & 0x0f, $z, $data); }catch(\Exception $e){ $level = $this->getProvider(); - $this->setSection($Y = $y >> 4, $level::createChunkSection($Y)); + $this->setInternalSection($Y = $y >> 4, $level::createChunkSection($Y)); $this->setBlockLight($x, $y, $z, $data); } } @@ -261,6 +261,10 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ } } + private function setInternalSection($fY, ChunkSection $section){ + $this->sections[(int) $fY] = $section; + } + public function load($generate = true){ return $this->getProvider() === null ? false : $this->getProvider()->getChunk($this->getX(), $this->getZ(), true) instanceof Chunk; }