mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Changed chunk-sending.per-second to chunk-sending.per-tick
This commit is contained in:
parent
bf49cafeae
commit
21f764590b
@ -557,33 +557,38 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$index = key($this->loadQueue);
|
if(count($this->loadQueue) === 0){
|
||||||
$distance = @$this->loadQueue[$index];
|
|
||||||
|
|
||||||
if($index === null or $distance === null){
|
|
||||||
$this->chunkLoadTask->setNextRun($this->chunkLoadTask->getNextRun() + 30);
|
$this->chunkLoadTask->setNextRun($this->chunkLoadTask->getNextRun() + 30);
|
||||||
return;
|
}else{
|
||||||
}
|
$count = 0;
|
||||||
$X = null;
|
$limit = (int) $this->server->getProperty("chunk-sending.per-tick", 1);
|
||||||
$Z = null;
|
foreach($this->loadQueue as $index => $distance){
|
||||||
Level::getXZ($index, $X, $Z);
|
if($count >= $limit){
|
||||||
if(!$this->getLevel()->isChunkPopulated($X, $Z)){
|
break;
|
||||||
return;
|
}
|
||||||
}
|
++$count;
|
||||||
unset($this->loadQueue[$index]);
|
$X = null;
|
||||||
$this->usedChunks[$index] = [false, 0];
|
$Z = null;
|
||||||
|
Level::getXZ($index, $X, $Z);
|
||||||
|
if(!$this->getLevel()->isChunkPopulated($X, $Z)){
|
||||||
|
$this->chunkLoadTask->setNextRun($this->chunkLoadTask->getNextRun() + 30);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unset($this->loadQueue[$index]);
|
||||||
|
$this->usedChunks[$index] = [false, 0];
|
||||||
|
|
||||||
$this->getLevel()->useChunk($X, $Z, $this);
|
$this->getLevel()->useChunk($X, $Z, $this);
|
||||||
$pk = new FullChunkDataPacket;
|
$pk = new FullChunkDataPacket;
|
||||||
$pk->chunkX = $X;
|
$pk->chunkX = $X;
|
||||||
$pk->chunkZ = $Z;
|
$pk->chunkZ = $Z;
|
||||||
$pk->data = $this->getLevel()->getNetworkChunk($X, $Z, 0xff);
|
$pk->data = $this->getLevel()->getNetworkChunk($X, $Z, 0xff);
|
||||||
$cnt = $this->dataPacket($pk, true);
|
$cnt = $this->dataPacket($pk, true);
|
||||||
|
if($cnt === false or $cnt === true){
|
||||||
if($cnt === false or $cnt === true){
|
return;
|
||||||
return;
|
}
|
||||||
|
$this->chunkACK[$cnt] = $index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->chunkACK[$cnt] = $index;
|
|
||||||
|
|
||||||
if(count($this->usedChunks) >= 56 and $this->spawned === false){
|
if(count($this->usedChunks) >= 56 and $this->spawned === false){
|
||||||
$spawned = 0;
|
$spawned = 0;
|
||||||
@ -597,25 +602,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->usedChunks as $index => $d){
|
|
||||||
if($d[0] === false){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$X = null;
|
|
||||||
$Z = null;
|
|
||||||
Level::getXZ($index, $X, $Z);
|
|
||||||
foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){
|
|
||||||
if($entity !== $this){
|
|
||||||
$entity->spawnTo($this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach($this->getLevel()->getChunkTiles($X, $Z) as $tile){
|
|
||||||
if($tile instanceof Spawnable){
|
|
||||||
$tile->spawnTo($this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
//$this->heal($this->data->get("health"), "spawn", true);
|
//$this->heal($this->data->get("health"), "spawn", true);
|
||||||
$this->spawned = true;
|
$this->spawned = true;
|
||||||
@ -633,6 +619,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
|
|
||||||
$pos = new Position($this->x, $this->y, $this->z, $this->getLevel());
|
$pos = new Position($this->x, $this->y, $this->z, $this->getLevel());
|
||||||
$pos = $this->getLevel()->getSafeSpawn($pos);
|
$pos = $this->getLevel()->getSafeSpawn($pos);
|
||||||
|
|
||||||
$this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $pos));
|
$this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $pos));
|
||||||
|
|
||||||
$this->teleport($ev->getRespawnPosition());
|
$this->teleport($ev->getRespawnPosition());
|
||||||
@ -1235,7 +1222,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$this->orderChunks();
|
$this->orderChunks();
|
||||||
$this->tasks[] = $this->server->getScheduler()->scheduleDelayedRepeatingTask(new CallbackTask(array($this, "orderChunks")), 10, 40);
|
$this->tasks[] = $this->server->getScheduler()->scheduleDelayedRepeatingTask(new CallbackTask(array($this, "orderChunks")), 10, 40);
|
||||||
$this->sendNextChunk();
|
$this->sendNextChunk();
|
||||||
$this->tasks[] = $this->chunkLoadTask = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "sendNextChunk")), MAX_CHUNK_RATE);
|
$this->tasks[] = $this->chunkLoadTask = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask(array($this, "sendNextChunk")), 1);
|
||||||
|
|
||||||
$pk = new ReadyPacket();
|
$pk = new ReadyPacket();
|
||||||
$pk->x = $this->x;
|
$pk->x = $this->x;
|
||||||
|
@ -1388,7 +1388,6 @@ class Server{
|
|||||||
$this->logger->setLogDebug(\pocketmine\DEBUG > 1);
|
$this->logger->setLogDebug(\pocketmine\DEBUG > 1);
|
||||||
}
|
}
|
||||||
define("ADVANCED_CACHE", $this->getProperty("settings.advanced-cache", false));
|
define("ADVANCED_CACHE", $this->getProperty("settings.advanced-cache", false));
|
||||||
define("MAX_CHUNK_RATE", ceil(20 / $this->getProperty("chunk-sending.per-second", 20)));
|
|
||||||
if(ADVANCED_CACHE == true){
|
if(ADVANCED_CACHE == true){
|
||||||
$this->logger->info("Advanced cache enabled");
|
$this->logger->info("Advanced cache enabled");
|
||||||
}
|
}
|
||||||
|
@ -931,7 +931,7 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
$this->airTicks = 300;
|
$this->airTicks = 300;
|
||||||
$this->fallDistance = 0;
|
$this->fallDistance = 0;
|
||||||
$this->orderChunks();
|
$this->orderChunks();
|
||||||
$this->sendNextChunk();
|
$this->chunkLoadTask->setNextRun(0);
|
||||||
$this->forceMovement = $pos;
|
$this->forceMovement = $pos;
|
||||||
|
|
||||||
$pk = new MovePlayerPacket;
|
$pk = new MovePlayerPacket;
|
||||||
|
@ -150,11 +150,11 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
|||||||
$column = "";
|
$column = "";
|
||||||
if(($x & 1) === 0){
|
if(($x & 1) === 0){
|
||||||
for($y = 0; $y < 16; $y += 2){
|
for($y = 0; $y < 16; $y += 2){
|
||||||
$column .= chr((ord($this->data{($y << 7) + $i}) & 0x0f) | ((ord($this->data{(($y + 1) << 7) + $i}) & 0x0f) << 4));
|
$column .= ($this->data{($y << 7) + $i} & "\x0f") | chr((ord($this->data{(($y + 1) << 7) + $i}) & 0x0f) << 4);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
for($y = 0; $y < 16; $y += 2){
|
for($y = 0; $y < 16; $y += 2){
|
||||||
$column .= chr(((ord($this->data{($y << 7) + $i}) & 0xf0) >> 4) | (ord($this->data{(($y + 1) << 7) + $i}) & 0xf0));
|
$column .= chr((ord($this->data{($y << 7) + $i}) & 0xf0) >> 4) | ($this->data{(($y + 1) << 7) + $i} & "\xf0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,8 +164,14 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
|||||||
public function getBlockSkyLightColumn($x, $z){
|
public function getBlockSkyLightColumn($x, $z){
|
||||||
$i = ($z << 3) + ($x >> 1);
|
$i = ($z << 3) + ($x >> 1);
|
||||||
$column = "";
|
$column = "";
|
||||||
for($y = 0; $y < 16; $y += 2){
|
if(($x & 1) === 0){
|
||||||
$column .= chr((ord($this->skyLight{($y << 7) + $i}) & 0x0f) | ((ord($this->skyLight{(($y + 1) << 7) + $i}) & 0x0f) << 4));
|
for($y = 0; $y < 16; $y += 2){
|
||||||
|
$column .= ($this->skyLight{($y << 7) + $i} & "\x0f") | chr((ord($this->skyLight{(($y + 1) << 7) + $i}) & 0x0f) << 4);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
for($y = 0; $y < 16; $y += 2){
|
||||||
|
$column .= chr((ord($this->skyLight{($y << 7) + $i}) & 0xf0) >> 4) | ($this->skyLight{(($y + 1) << 7) + $i} & "\xf0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $column;
|
return $column;
|
||||||
@ -174,8 +180,14 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
|||||||
public function getBlockLightColumn($x, $z){
|
public function getBlockLightColumn($x, $z){
|
||||||
$i = ($z << 3) + ($x >> 1);
|
$i = ($z << 3) + ($x >> 1);
|
||||||
$column = "";
|
$column = "";
|
||||||
for($y = 0; $y < 16; $y += 2){
|
if(($x & 1) === 0){
|
||||||
$column .= chr((ord($this->blockLight{($y << 7) + $i}) & 0x0f) | ((ord($this->blockLight{(($y + 1) << 7) + $i}) & 0x0f) << 4));
|
for($y = 0; $y < 16; $y += 2){
|
||||||
|
$column .= ($this->blockLight{($y << 7) + $i} & "\x0f") | chr((ord($this->blockLight{(($y + 1) << 7) + $i}) & 0x0f) << 4);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
for($y = 0; $y < 16; $y += 2){
|
||||||
|
$column .= chr((ord($this->blockLight{($y << 7) + $i}) & 0xf0) >> 4) | ($this->blockLight{(($y + 1) << 7) + $i} & "\xf0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $column;
|
return $column;
|
||||||
|
@ -16,7 +16,7 @@ debug:
|
|||||||
commands: false
|
commands: false
|
||||||
|
|
||||||
chunk-sending:
|
chunk-sending:
|
||||||
per-second: 20
|
per-tick: 1
|
||||||
compression-level: 7
|
compression-level: 7
|
||||||
|
|
||||||
chunk-gc:
|
chunk-gc:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user