mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
fixed freeAllChunks
This commit is contained in:
parent
cef28d2c38
commit
c4b03ce13c
3 changed files with 19 additions and 28 deletions
|
|
@ -569,6 +569,7 @@ class Player{
|
|||
$z = $Z << 4;
|
||||
$this->level->useChunk($X, $Z, $this);
|
||||
$this->chunksLoaded["$X:$Z"] = true;
|
||||
|
||||
$pk = new FullChunkDataPacket;
|
||||
$pk->chunkX = $X;
|
||||
$pk->chunkZ = $Z;
|
||||
|
|
@ -1132,16 +1133,6 @@ class Player{
|
|||
if(isset($this->received[$p->messageIndex])){
|
||||
continue;
|
||||
}
|
||||
switch($p->pid()){
|
||||
case 0x01:
|
||||
case ProtocolInfo::PING_PACKET:
|
||||
case ProtocolInfo::PONG_PACKET:
|
||||
case ProtocolInfo::MOVE_PLAYER_PACKET:
|
||||
case ProtocolInfo::REQUEST_CHUNK_PACKET:
|
||||
case ProtocolInfo::ANIMATE_PACKET:
|
||||
case ProtocolInfo::SET_HEALTH_PACKET:
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->received[$p->messageIndex] = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -408,8 +408,8 @@ class Entity extends Position
|
|||
} else{
|
||||
$hasUpdate = true;
|
||||
}
|
||||
if(($this->player instanceof Player) and ($this->player->gamemode & 0x01) === CREATIVE){ // Remove fire effects in next tick
|
||||
$this->fire = 1;
|
||||
if(($this->player instanceof Player) and ($this->player->gamemode & 0x01) === CREATIVE){
|
||||
$this->fire = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,19 +85,22 @@ class Level{
|
|||
}
|
||||
|
||||
public function fastSetBlockUpdate($x, $y, $z, $id, $meta, $updateBlocksAround = false){
|
||||
$x = (int)$x;
|
||||
$y = (int)$y;
|
||||
$z = (int)$z;
|
||||
$this->level->setBlock($x, $y, $z, $id, $meta);
|
||||
$pk = new UpdateBlockPacket;
|
||||
$pk->x = $x;
|
||||
$pk->y = $y;
|
||||
$pk->z = $z;
|
||||
$pk->block = $id;
|
||||
$pk->meta = $meta;
|
||||
$this->server->api->player->broadcastPacket($this->players, $pk); //TODO broadcast in another queue?
|
||||
$this->sendBlockToAll($x, $y, $z);
|
||||
if($updateBlocksAround){
|
||||
$this->server->api->block->blockUpdateAround(new Position($x, $y, $z, $this), BLOCK_UPDATE_NORMAL, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendBlockToAll($x, $y, $z){
|
||||
foreach($this->players as $p){
|
||||
$this->resendBlocksToPlayers[$p->CID]["$x.$y.$z"] = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct(){
|
||||
if(isset($this->level)){
|
||||
$this->save(false, false);
|
||||
|
|
@ -312,8 +315,11 @@ class Level{
|
|||
}
|
||||
|
||||
public function freeAllChunks(Player $player){
|
||||
foreach($this->usedChunks as $i => $c){
|
||||
unset($this->usedChunks[$i][$player->CID]);
|
||||
foreach($player->chunksLoaded as $chunk => $c){
|
||||
$xz = explode(":", $chunk);
|
||||
$x = $xz[0];
|
||||
$z = $xz[1];
|
||||
$player->stopUsingChunk($x, $z);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -517,13 +523,7 @@ class Level{
|
|||
}
|
||||
$block->position($pos);
|
||||
if($direct === true){
|
||||
$pk = new UpdateBlockPacket;
|
||||
$pk->x = $pos->x;
|
||||
$pk->y = $pos->y;
|
||||
$pk->z = $pos->z;
|
||||
$pk->block = $block->getID();
|
||||
$pk->meta = $block->getMetadata();
|
||||
$this->server->api->player->broadcastPacket($this->players, $pk);
|
||||
$this->sendBlockToAll($pos->x, $pos->y, $pos->z);
|
||||
}else{
|
||||
$i = ($pos->x >> 4) . ":" . ($pos->y >> 4) . ":" . ($pos->z >> 4);
|
||||
if(!isset($this->changedBlocks[$i])){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue