mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Added chunk move spawning logic
This commit is contained in:
parent
dad2f21888
commit
c2ad811451
@ -325,6 +325,19 @@ abstract class Entity extends Position{
|
||||
}
|
||||
$this->chunkIndex = $index;
|
||||
$this->level->loadChunk($this->x >> 4, $this->z >> 4);
|
||||
|
||||
$newChunk = $this->level->getUsingChunk($this->x >> 4, $this->z >> 4);
|
||||
foreach($this->hasSpawned as $CID => $player){
|
||||
if(!isset($newChunk[$CID])){
|
||||
$this->despawnFrom($player);
|
||||
}else{
|
||||
unset($newChunk[$CID]);
|
||||
}
|
||||
}
|
||||
foreach($newChunk as $player){
|
||||
$this->spawnTo($player);
|
||||
}
|
||||
|
||||
$this->level->chunkEntities[$this->chunkIndex][$this->id] = $this;
|
||||
}
|
||||
$this->boundingBox->setBounds($pos->x - $radius, $pos->y, $pos->z - $radius, $pos->x + $radius, $pos->y + $this->height, $pos->z + $radius);
|
||||
|
@ -265,12 +265,12 @@ class Player extends PlayerEntity{
|
||||
if(!isset($this->chunksLoaded[$index])){
|
||||
$this->chunksLoaded[$index] = 0xff;
|
||||
}
|
||||
$Yndex = $this->chunksLoaded[$index];
|
||||
$this->chunksLoaded[$index] = 0; //Load them all
|
||||
$X = null;
|
||||
$Z = null;
|
||||
PMFLevel::getXZ($index, $X, $Z);
|
||||
$this->level->useChunk($X, $Z, $this);
|
||||
$Yndex = $this->chunksLoaded[$index];
|
||||
$this->chunksLoaded[$index] = 0; //Load them all
|
||||
$pk = new ChunkDataPacket;
|
||||
$pk->chunkX = $X;
|
||||
$pk->chunkZ = $Z;
|
||||
|
@ -62,10 +62,14 @@ class Level{
|
||||
$this->__destruct();
|
||||
}
|
||||
|
||||
public function getUsingChunk($X, $Z){
|
||||
return isset($this->usedChunks[$index]) ? $this->usedChunks[$index]:array();
|
||||
}
|
||||
|
||||
public function useChunk($X, $Z, Player $player){
|
||||
$index = PMFLevel::getIndex($X, $Z);
|
||||
$this->loadChunk($X, $Z);
|
||||
$this->usedChunks[$index][$player->CID] = true;
|
||||
$this->usedChunks[$index][$player->CID] = $player;
|
||||
}
|
||||
|
||||
public function freeAllChunks(Player $player){
|
||||
|
Loading…
x
Reference in New Issue
Block a user