From e4223bb7dc5b4fc08eb00e02b7c09e6a19210c80 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 3 Dec 2018 18:30:27 +0000 Subject: [PATCH] Level: Duct tape fix for crashy trees at the top of the world this doesn't fix shit but it at least doesn't crash. Fixing this properly can't be effectively done any other way without backwards compatibility breaks. Fortunately it's not common practice to grow trees at the top of the world. --- src/pocketmine/level/Level.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 43bb7d112..38ea07f37 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -2177,6 +2177,9 @@ class Level implements ChunkManager, Metadatable{ * @param int $id 0-255 */ public function setBlockIdAt(int $x, int $y, int $z, int $id){ + if(!$this->isInWorld($x, $y, $z)){ //TODO: bad hack but fixing this requires BC breaks to do properly :( + return; + } unset($this->blockCache[$chunkHash = Level::chunkHash($x >> 4, $z >> 4)][$blockHash = Level::blockHash($x, $y, $z)]); $this->getChunk($x >> 4, $z >> 4, true)->setBlockId($x & 0x0f, $y, $z & 0x0f, $id & 0xff); @@ -2211,6 +2214,9 @@ class Level implements ChunkManager, Metadatable{ * @param int $data 0-15 */ public function setBlockDataAt(int $x, int $y, int $z, int $data){ + if(!$this->isInWorld($x, $y, $z)){ //TODO: bad hack but fixing this requires BC breaks to do properly :( + return; + } unset($this->blockCache[$chunkHash = Level::chunkHash($x >> 4, $z >> 4)][$blockHash = Level::blockHash($x, $y, $z)]); $this->getChunk($x >> 4, $z >> 4, true)->setBlockData($x & 0x0f, $y, $z & 0x0f, $data & 0x0f);