mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 07:39:57 +00:00
Fixed Entity & Player loaded chunk indexes
This commit is contained in:
parent
496c004efc
commit
fd4fc4ff94
@ -139,7 +139,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
protected $startAction = false;
|
protected $startAction = false;
|
||||||
protected $sleeping = false;
|
protected $sleeping = false;
|
||||||
|
|
||||||
protected $usedChunks = [];
|
public $usedChunks = [];
|
||||||
protected $loadQueue = [];
|
protected $loadQueue = [];
|
||||||
protected $chunkACK = [];
|
protected $chunkACK = [];
|
||||||
/** @var \pocketmine\scheduler\TaskHandler */
|
/** @var \pocketmine\scheduler\TaskHandler */
|
||||||
|
@ -225,7 +225,7 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function spawnTo(Player $player){
|
public function spawnTo(Player $player){
|
||||||
if(!isset($this->hasSpawned[$player->getID()]) and $player->chunksLoaded[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())] !== 0xff){
|
if(!isset($this->hasSpawned[$player->getID()]) and isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])){
|
||||||
$this->hasSpawned[$player->getID()] = $player;
|
$this->hasSpawned[$player->getID()] = $player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -585,8 +585,7 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
$this->chunk->removeEntity($this);
|
$this->chunk->removeEntity($this);
|
||||||
$this->despawnFromAll();
|
$this->despawnFromAll();
|
||||||
if($this instanceof Player){
|
if($this instanceof Player){
|
||||||
foreach($this->chunksLoaded as $index => $Yndex){
|
foreach($this->usedChunks as $index => $d){
|
||||||
if($Yndex !== 0xff){
|
|
||||||
$X = null;
|
$X = null;
|
||||||
$Z = null;
|
$Z = null;
|
||||||
Level::getXZ($index, $X, $Z);
|
Level::getXZ($index, $X, $Z);
|
||||||
@ -599,14 +598,13 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
$pk->chunkZ = $Z;
|
$pk->chunkZ = $Z;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$this->getLevel()->freeAllChunks($this);
|
$this->getLevel()->freeAllChunks($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->setLevel($targetLevel, true); //Hard reference
|
$this->setLevel($targetLevel, true); //Hard reference
|
||||||
$this->getLevel()->addEntity($this);
|
$this->getLevel()->addEntity($this);
|
||||||
if($this instanceof Player){
|
if($this instanceof Player){
|
||||||
$this->chunksLoaded = [];
|
$this->usedChunks = [];
|
||||||
$pk = new SetTimePacket();
|
$pk = new SetTimePacket();
|
||||||
$pk->time = $this->getLevel()->getTime();
|
$pk->time = $this->getLevel()->getTime();
|
||||||
$pk->started = $this->getLevel()->stopTime == false;
|
$pk->started = $this->getLevel()->stopTime == false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user