diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 7a49ae9048..75f1936998 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -516,7 +516,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0); $this->recalculateBoundingBox(); - $this->chunk = $this->level->getChunk($this->getFloorX() >> 4, $this->getFloorZ() >> 4, false); + $this->chunk = $this->level->getChunkAtPosition($this, false); if($this->chunk === null){ throw new \InvalidStateException("Cannot create entities in unloaded chunks"); } diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index c64ada77ae..f3b03e291f 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1554,7 +1554,7 @@ class Level implements ChunkManager, Metadatable{ $this->timings->setBlock->startTiming(); - if($this->getChunk($pos->x >> 4, $pos->z >> 4, true)->setBlock($pos->x & 0x0f, $pos->y, $pos->z & 0x0f, $block->getId(), $block->getDamage())){ + if($this->getChunkAtPosition($pos, true)->setBlock($pos->x & 0x0f, $pos->y, $pos->z & 0x0f, $block->getId(), $block->getDamage())){ if(!($pos instanceof Position)){ $pos = $this->temporalPosition->setComponents($pos->x, $pos->y, $pos->z); } @@ -2859,7 +2859,7 @@ class Level implements ChunkManager, Metadatable{ $max = $this->worldHeight; $v = $spawn->floor(); - $chunk = $this->getChunk($v->x >> 4, $v->z >> 4, false); + $chunk = $this->getChunkAtPosition($v, false); $x = (int) $v->x; $z = (int) $v->z; if($chunk !== null and $chunk->isGenerated()){