diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 1837995d5..e72361df2 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -494,7 +494,10 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $pos = $this->namedtag->getListTag("Pos")->getAllValues(); $this->chunk = $level->getChunk(((int) $pos[0]) >> 4, ((int) $pos[2]) >> 4, true); - assert($this->chunk !== null); + if($this->chunk === null){ + throw new \InvalidStateException("Cannot create entities in unloaded chunks"); + } + $this->setLevel($level); $this->server = $level->getServer(); diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index ec28b869e..19c706c69 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -146,7 +146,9 @@ abstract class Tile extends Position{ $this->server = $level->getServer(); $this->setLevel($level); $this->chunk = $level->getChunk($this->namedtag->getInt(self::TAG_X) >> 4, $this->namedtag->getInt(self::TAG_Z) >> 4, false); - assert($this->chunk !== null); + if($this->chunk === null){ + throw new \InvalidStateException("Cannot create tiles in unloaded chunks"); + } $this->name = ""; $this->id = Tile::$tileCount++;