World: rename getChunkAtPosition() to getOrLoadChunkAtPosition()

this more accurately reflects what it does.
This commit is contained in:
Dylan K. Taylor 2020-11-03 14:12:47 +00:00
parent bd78d0bff8
commit 5cc2a9c3dd
3 changed files with 4 additions and 4 deletions

View File

@ -147,7 +147,7 @@ class Block{
} }
public function writeStateToWorld() : void{ public function writeStateToWorld() : void{
$this->pos->getWorld()->getChunkAtPosition($this->pos)->setFullBlock($this->pos->x & 0xf, $this->pos->y, $this->pos->z & 0xf, $this->getFullId()); $this->pos->getWorld()->getOrLoadChunkAtPosition($this->pos)->setFullBlock($this->pos->x & 0xf, $this->pos->y, $this->pos->z & 0xf, $this->getFullId());
$tileType = $this->idInfo->getTileClass(); $tileType = $this->idInfo->getTileClass();
$oldTile = $this->pos->getWorld()->getTile($this->pos); $oldTile = $this->pos->getWorld()->getTile($this->pos);

View File

@ -243,7 +243,7 @@ abstract class Entity{
$this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0); $this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
$this->recalculateBoundingBox(); $this->recalculateBoundingBox();
$this->chunk = $this->getWorld()->getChunkAtPosition($this->location, false); $this->chunk = $this->getWorld()->getOrLoadChunkAtPosition($this->location, false);
if($this->chunk === null){ if($this->chunk === null){
throw new \InvalidStateException("Cannot create entities in unloaded chunks"); throw new \InvalidStateException("Cannot create entities in unloaded chunks");
} }

View File

@ -1936,7 +1936,7 @@ class World implements ChunkManager{
/** /**
* Returns the chunk containing the given Vector3 position. * Returns the chunk containing the given Vector3 position.
*/ */
public function getChunkAtPosition(Vector3 $pos, bool $create = false) : ?Chunk{ public function getOrLoadChunkAtPosition(Vector3 $pos, bool $create = false) : ?Chunk{
return $this->getOrLoadChunk($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4, $create); return $this->getOrLoadChunk($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4, $create);
} }
@ -2342,7 +2342,7 @@ class World implements ChunkManager{
$max = $this->worldHeight; $max = $this->worldHeight;
$v = $spawn->floor(); $v = $spawn->floor();
$chunk = $this->getChunkAtPosition($v, false); $chunk = $this->getOrLoadChunkAtPosition($v, false);
$x = (int) $v->x; $x = (int) $v->x;
$y = $v->y; $y = $v->y;
$z = (int) $v->z; $z = (int) $v->z;