mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
Fixed chunk unload on level change
This commit is contained in:
parent
6f36e9af24
commit
cb1c4da4ea
@ -653,17 +653,15 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
|
||||
foreach($lastChunk as $index => $Yndex){
|
||||
$X = null;
|
||||
$Z = null;
|
||||
Level::getXZ($index, $X, $Z);
|
||||
if($Yndex === 0){
|
||||
$X = null;
|
||||
$Z = null;
|
||||
Level::getXZ($index, $X, $Z);
|
||||
foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){
|
||||
if($entity !== $this){
|
||||
$entity->despawnFrom($this);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
$pk = new UnloadChunkPacket();
|
||||
$pk->chunkX = $X;
|
||||
$pk->chunkZ = $Z;
|
||||
|
@ -49,6 +49,7 @@ use pocketmine\network\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\network\protocol\SetTimePacket;
|
||||
use pocketmine\network\protocol\UnloadChunkPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Server;
|
||||
@ -593,6 +594,11 @@ abstract class Entity extends Position implements Metadatable{
|
||||
foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){
|
||||
$entity->despawnFrom($this);
|
||||
}
|
||||
|
||||
$pk = new UnloadChunkPacket();
|
||||
$pk->chunkX = $X;
|
||||
$pk->chunkZ = $Z;
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
$this->getLevel()->freeAllChunks($this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user