From f5807ac0498f0953b9ddc53d2eb0de496248cf00 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 31 Oct 2020 22:22:02 +0000 Subject: [PATCH] World::getBlockAt() now doesn't assume that AIR has a fullStateId of 0 --- src/world/World.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/world/World.php b/src/world/World.php index 8f2af6cdf..999ad614d 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -33,6 +33,7 @@ use pocketmine\block\BlockLegacyIds; use pocketmine\block\tile\Spawnable; use pocketmine\block\tile\Tile; use pocketmine\block\UnknownBlock; +use pocketmine\block\VanillaBlocks; use pocketmine\entity\Entity; use pocketmine\entity\Location; use pocketmine\entity\object\ExperienceOrb; @@ -1329,7 +1330,6 @@ class World implements ChunkManager{ * @param bool $addToCache Whether to cache the block object created by this method call. */ public function getBlockAt(int $x, int $y, int $z, bool $cached = true, bool $addToCache = true) : Block{ - $fullState = 0; $relativeBlockHash = null; $chunkHash = World::chunkHash($x >> 4, $z >> 4); @@ -1342,13 +1342,15 @@ class World implements ChunkManager{ $chunk = $this->chunks[$chunkHash] ?? null; if($chunk !== null){ - $fullState = $chunk->getFullBlock($x & 0x0f, $y, $z & 0x0f); + $block = BlockFactory::getInstance()->fromFullBlock($chunk->getFullBlock($x & 0x0f, $y, $z & 0x0f)); }else{ $addToCache = false; + $block = VanillaBlocks::AIR(); } + }else{ + $block = VanillaBlocks::AIR(); } - $block = BlockFactory::getInstance()->fromFullBlock($fullState); $block->position($this, $x, $y, $z); static $dynamicStateRead = false;