mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Throw exceptions when entities/tiles are created on chunks that don't exist
These assertions don't make sense. Since the chunk field is used below in both cases, the chunk should **never** be null no matter what.
This commit is contained in:
parent
c9e2e8980f
commit
c747c7d025
@ -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();
|
||||
|
||||
|
@ -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++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user