Fixed moving from different chunks, lots of issues fixed (all kind of strange things)

This commit is contained in:
Shoghi Cervantes 2015-04-11 21:39:51 +02:00
parent 363e0e3b13
commit a65c300a0a
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
2 changed files with 9 additions and 9 deletions

View File

@ -117,11 +117,6 @@ abstract class Entity extends Location implements Metadatable{
public $passenger = null; public $passenger = null;
public $vehicle = null; public $vehicle = null;
/** @var int */
public $chunkX;
/** @var int */
public $chunkZ;
/** @var Chunk */ /** @var Chunk */
public $chunk; public $chunk;
@ -1294,14 +1289,12 @@ abstract class Entity extends Location implements Metadatable{
$this->boundingBox->setBounds($pos->x - $radius, $pos->y, $pos->z - $radius, $pos->x + $radius, $pos->y + $this->height, $pos->z + $radius); $this->boundingBox->setBounds($pos->x - $radius, $pos->y, $pos->z - $radius, $pos->x + $radius, $pos->y + $this->height, $pos->z + $radius);
if($this->chunk === null or ($this->chunkX !== ($this->x >> 4) and $this->chunkZ !== ($this->z >> 4))){ if($this->chunk === null or ($this->chunk->getX() !== ($this->x >> 4) or $this->chunk->getZ() !== ($this->z >> 4))){
if($this->chunk !== null){ if($this->chunk !== null){
$this->chunk->removeEntity($this); $this->chunk->removeEntity($this);
} }
$this->level->loadChunk($this->x >> 4, $this->z >> 4); $this->level->loadChunk($this->x >> 4, $this->z >> 4);
$this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4, true); $this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4, true);
$this->chunkX = $this->chunk->getX();
$this->chunkZ = $this->chunk->getZ();
if(!$this->justCreated){ if(!$this->justCreated){
$newChunk = $this->level->getUsingChunk($this->x >> 4, $this->z >> 4); $newChunk = $this->level->getUsingChunk($this->x >> 4, $this->z >> 4);
@ -1410,7 +1403,10 @@ abstract class Entity extends Location implements Metadatable{
} }
public function spawnToAll(){ public function spawnToAll(){
foreach($this->level->getUsingChunk($this->chunkX, $this->chunkZ) as $player){ if($this->chunk === null){
return;
}
foreach($this->level->getUsingChunk($this->chunk->getX(), $this->chunk->getZ()) as $player){
if($player->loggedIn === true){ if($player->loggedIn === true){
$this->spawnTo($player); $this->spawnTo($player);
} }

View File

@ -323,4 +323,8 @@ class AxisAlignedBB{
return MovingObjectPosition::fromBlock(0, 0, 0, $f, $vector); return MovingObjectPosition::fromBlock(0, 0, 0, $f, $vector);
} }
public function __toString(){
return "AxisAlignedBB({$this->minX}, {$this->minY}, {$this->minZ}, {$this->maxX}, {$this->maxY}, {$this->maxZ})";
}
} }