mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +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){
|
foreach($lastChunk as $index => $Yndex){
|
||||||
$X = null;
|
|
||||||
$Z = null;
|
|
||||||
Level::getXZ($index, $X, $Z);
|
|
||||||
if($Yndex === 0){
|
if($Yndex === 0){
|
||||||
|
$X = null;
|
||||||
|
$Z = null;
|
||||||
|
Level::getXZ($index, $X, $Z);
|
||||||
foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){
|
foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){
|
||||||
if($entity !== $this){
|
if($entity !== $this){
|
||||||
$entity->despawnFrom($this);
|
$entity->despawnFrom($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
|
||||||
$pk = new UnloadChunkPacket();
|
$pk = new UnloadChunkPacket();
|
||||||
$pk->chunkX = $X;
|
$pk->chunkX = $X;
|
||||||
$pk->chunkZ = $Z;
|
$pk->chunkZ = $Z;
|
||||||
|
@ -49,6 +49,7 @@ use pocketmine\network\protocol\MovePlayerPacket;
|
|||||||
use pocketmine\network\protocol\RemoveEntityPacket;
|
use pocketmine\network\protocol\RemoveEntityPacket;
|
||||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||||
use pocketmine\network\protocol\SetTimePacket;
|
use pocketmine\network\protocol\SetTimePacket;
|
||||||
|
use pocketmine\network\protocol\UnloadChunkPacket;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
@ -593,6 +594,11 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){
|
foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){
|
||||||
$entity->despawnFrom($this);
|
$entity->despawnFrom($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pk = new UnloadChunkPacket();
|
||||||
|
$pk->chunkX = $X;
|
||||||
|
$pk->chunkZ = $Z;
|
||||||
|
$this->dataPacket($pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->getLevel()->freeAllChunks($this);
|
$this->getLevel()->freeAllChunks($this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user