mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +00:00
Workaround for players getting stuck on far chunks
This commit is contained in:
parent
ec82434ef4
commit
1e03c5b795
@ -3113,6 +3113,46 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
$this->dataPacket($pk->setChannel($channel));
|
$this->dataPacket($pk->setChannel($channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function checkChunks(){
|
||||||
|
if($this->chunk === null or ($this->chunk->getX() !== ($this->x >> 4) or $this->chunk->getZ() !== ($this->z >> 4))){
|
||||||
|
if($this->chunk !== null){
|
||||||
|
$this->chunk->removeEntity($this);
|
||||||
|
}
|
||||||
|
$this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4, true);
|
||||||
|
|
||||||
|
if(!$this->justCreated){
|
||||||
|
$newChunk = $this->level->getChunkPlayers($this->x >> 4, $this->z >> 4);
|
||||||
|
/** @var Player[] $reload */
|
||||||
|
$reload = [];
|
||||||
|
foreach($this->hasSpawned as $player){
|
||||||
|
if(!isset($newChunk[$player->getLoaderId()])){
|
||||||
|
$this->despawnFrom($player);
|
||||||
|
}else{
|
||||||
|
unset($newChunk[$player->getLoaderId()]);
|
||||||
|
$reload[] = $player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO HACK: Minecraft: PE does not like moving a player from old chunks.
|
||||||
|
//Player entities get stuck in unloaded chunks and the client does not accept position updates.
|
||||||
|
foreach($reload as $player){
|
||||||
|
$player->despawnFrom($player);
|
||||||
|
$player->spawnTo($player);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($newChunk as $player){
|
||||||
|
$this->spawnTo($player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->chunk === null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->chunk->addEntity($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function checkTeleportPosition(){
|
protected function checkTeleportPosition(){
|
||||||
if($this->teleportPosition !== null){
|
if($this->teleportPosition !== null){
|
||||||
$chunkX = $this->teleportPosition->x >> 4;
|
$chunkX = $this->teleportPosition->x >> 4;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user