mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Fixed level block and chunk sending
This commit is contained in:
parent
f08bedf2fe
commit
5651fc1cb1
@ -455,25 +455,6 @@ class PlayerAPI{
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($CID){
|
||||
if(isset($this->server->clients[$CID])){
|
||||
$player = $this->server->clients[$CID];
|
||||
unset($this->server->clients[$CID]);
|
||||
$player->close();
|
||||
if($player->username != "" and ($player->data instanceof Config)){
|
||||
$this->saveOffline($player->data);
|
||||
}
|
||||
$this->server->query("DELETE FROM players WHERE name = '".$player->username."';");
|
||||
if($player->entity instanceof Entity){
|
||||
unset($player->entity->player);
|
||||
//unset($player->entity);
|
||||
$player->entity->close();
|
||||
}
|
||||
$player = null;
|
||||
unset($player);
|
||||
}
|
||||
}
|
||||
|
||||
public function getOffline($name){
|
||||
$iname = strtolower($name);
|
||||
$default = array(
|
||||
|
@ -305,7 +305,11 @@ class Player extends PlayerEntity{
|
||||
$this->receiveQueue = array();
|
||||
$this->resendQueue = array();
|
||||
$this->ackQueue = array();
|
||||
$this->server->api->player->remove($this->CID);
|
||||
unset($this->server->clients[$this->CID]);
|
||||
if($this->username != "" and ($this->data instanceof Config)){
|
||||
//TODO
|
||||
//$this->saveOffline($player->data);
|
||||
}
|
||||
if($msg === true and $this->username != "" and $this->spawned !== false){
|
||||
$this->server->api->chat->broadcast($this->username." left the game");
|
||||
}
|
||||
@ -319,6 +323,7 @@ class Player extends PlayerEntity{
|
||||
$this->chunkCount = array();
|
||||
$this->craftingItems = array();
|
||||
$this->received = array();
|
||||
parent::close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1462,7 +1467,7 @@ class Player extends PlayerEntity{
|
||||
//$this->server->api->player->spawnToAllPlayers($this);
|
||||
//TODO
|
||||
//$this->server->api->entity->spawnAll($this);
|
||||
$this->spawnToAll();
|
||||
//$this->spawnToAll();
|
||||
//$this->sendArmor();
|
||||
$this->sendChat($this->server->motd."\n");
|
||||
|
||||
|
@ -20,5 +20,12 @@
|
||||
*/
|
||||
|
||||
class PlayerEntity extends HumanEntity{
|
||||
|
||||
|
||||
protected function initEntity(){
|
||||
$this->level->players[$this->CID] = $this;
|
||||
}
|
||||
|
||||
public function close(){
|
||||
unset($this->level->players[$this->CID]);
|
||||
}
|
||||
}
|
@ -208,7 +208,8 @@ class PMFLevel extends PMF{
|
||||
}
|
||||
$this->initCleanChunk($X, $Z);
|
||||
$ret = $this->level->generateChunk($X, $Z);
|
||||
$this->saveChunk($X, $Z);
|
||||
$this->saveChunk($X, $Z);
|
||||
echo decbin($this->chunkInfo[self::getIndex($X, $Z)][0]).PHP_EOL;
|
||||
$this->populateChunk($X - 1, $Z);
|
||||
$this->populateChunk($X + 1, $Z);
|
||||
$this->populateChunk($X, $Z - 1);
|
||||
@ -222,6 +223,7 @@ class PMFLevel extends PMF{
|
||||
|
||||
public function populateChunk($X, $Z){
|
||||
if($this->isGenerating === 0 and
|
||||
$this->isChunkLoaded($X, $Z) and
|
||||
!$this->isPopulated($X, $Z) and
|
||||
$this->isGenerated($X - 1, $Z) and
|
||||
$this->isGenerated($X, $Z - 1) and
|
||||
@ -231,6 +233,7 @@ class PMFLevel extends PMF{
|
||||
$this->isGenerated($X - 1, $Z - 1) and
|
||||
$this->isGenerated($X + 1, $Z - 1) and
|
||||
$this->isGenerated($X - 1, $Z + 1)){
|
||||
echo "pop $X $Z\n";
|
||||
$this->level->populateChunk($X, $Z);
|
||||
$this->saveChunk($X, $Z);
|
||||
}
|
||||
@ -240,6 +243,7 @@ class PMFLevel extends PMF{
|
||||
if($this->isChunkLoaded($X, $Z)){
|
||||
return true;
|
||||
}
|
||||
echo "load $X $Z\n";
|
||||
$index = self::getIndex($X, $Z);
|
||||
$path = $this->getChunkPath($X, $Z);
|
||||
if(!file_exists($path)){
|
||||
@ -644,6 +648,8 @@ class PMFLevel extends PMF{
|
||||
}
|
||||
$this->chunkChange[$index][$Y] = 0;
|
||||
}
|
||||
$this->chunkInfo[$index][0] = $bitmap;
|
||||
$this->chunkChange[$index][-1] = false;
|
||||
$chunk = b"";
|
||||
$chunk .= chr($bitmap);
|
||||
$chunk .= Utils::writeInt($this->chunkInfo[$index][1]);
|
||||
@ -657,8 +663,6 @@ class PMFLevel extends PMF{
|
||||
}
|
||||
}
|
||||
file_put_contents($path, zlib_encode($chunk, PMFLevel::ZLIB_ENCODING, PMFLevel::ZLIB_LEVEL));
|
||||
$this->chunkChange[$index][-1] = false;
|
||||
$this->chunkInfo[$index][0] = $bitmap;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -64,9 +64,7 @@ class Level{
|
||||
|
||||
public function useChunk($X, $Z, Player $player){
|
||||
$index = PMFLevel::getIndex($X, $Z);
|
||||
if(!isset($this->usedChunks[$index])){
|
||||
$this->loadChunk($X, $Z);
|
||||
}
|
||||
$this->loadChunk($X, $Z);
|
||||
$this->usedChunks[$index][$player->CID] = true;
|
||||
}
|
||||
|
||||
@ -368,7 +366,7 @@ class Level{
|
||||
|
||||
public function getChunkEntities($X, $Z){
|
||||
$index = PMFLevel::getIndex($X, $Z);
|
||||
if(isset($this->usedChunks[$index]) or $this->level->loadChunk($X, $Z) === true){
|
||||
if(isset($this->usedChunks[$index]) or $this->loadChunk($X, $Z) === true){
|
||||
return $this->chunkEntities[$index];
|
||||
}
|
||||
return array();
|
||||
@ -376,7 +374,7 @@ class Level{
|
||||
|
||||
public function getChunkTiles($X, $Z){
|
||||
$index = PMFLevel::getIndex($X, $Z);
|
||||
if(isset($this->usedChunks[$index]) or $this->level->loadChunk($X, $Z) === true){
|
||||
if(isset($this->usedChunks[$index]) or $this->loadChunk($X, $Z) === true){
|
||||
return $this->chunkTiles[$index];
|
||||
}
|
||||
return array();
|
||||
|
Loading…
x
Reference in New Issue
Block a user