mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 13:09:44 +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;
|
$z = $Z << 4;
|
||||||
$this->level->useChunk($X, $Z, $this);
|
$this->level->useChunk($X, $Z, $this);
|
||||||
$this->chunksLoaded["$X:$Z"] = true;
|
$this->chunksLoaded["$X:$Z"] = true;
|
||||||
|
|
||||||
$pk = new FullChunkDataPacket;
|
$pk = new FullChunkDataPacket;
|
||||||
$pk->chunkX = $X;
|
$pk->chunkX = $X;
|
||||||
$pk->chunkZ = $Z;
|
$pk->chunkZ = $Z;
|
||||||
|
|
@ -1132,16 +1133,6 @@ class Player{
|
||||||
if(isset($this->received[$p->messageIndex])){
|
if(isset($this->received[$p->messageIndex])){
|
||||||
continue;
|
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;
|
$this->received[$p->messageIndex] = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -408,8 +408,8 @@ class Entity extends Position
|
||||||
} else{
|
} else{
|
||||||
$hasUpdate = true;
|
$hasUpdate = true;
|
||||||
}
|
}
|
||||||
if(($this->player instanceof Player) and ($this->player->gamemode & 0x01) === CREATIVE){ // Remove fire effects in next tick
|
if(($this->player instanceof Player) and ($this->player->gamemode & 0x01) === CREATIVE){
|
||||||
$this->fire = 1;
|
$this->fire = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,19 +85,22 @@ class Level{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fastSetBlockUpdate($x, $y, $z, $id, $meta, $updateBlocksAround = false){
|
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);
|
$this->level->setBlock($x, $y, $z, $id, $meta);
|
||||||
$pk = new UpdateBlockPacket;
|
$this->sendBlockToAll($x, $y, $z);
|
||||||
$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?
|
|
||||||
if($updateBlocksAround){
|
if($updateBlocksAround){
|
||||||
$this->server->api->block->blockUpdateAround(new Position($x, $y, $z, $this), BLOCK_UPDATE_NORMAL, 1);
|
$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(){
|
public function __destruct(){
|
||||||
if(isset($this->level)){
|
if(isset($this->level)){
|
||||||
$this->save(false, false);
|
$this->save(false, false);
|
||||||
|
|
@ -312,8 +315,11 @@ class Level{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function freeAllChunks(Player $player){
|
public function freeAllChunks(Player $player){
|
||||||
foreach($this->usedChunks as $i => $c){
|
foreach($player->chunksLoaded as $chunk => $c){
|
||||||
unset($this->usedChunks[$i][$player->CID]);
|
$xz = explode(":", $chunk);
|
||||||
|
$x = $xz[0];
|
||||||
|
$z = $xz[1];
|
||||||
|
$player->stopUsingChunk($x, $z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -517,13 +523,7 @@ class Level{
|
||||||
}
|
}
|
||||||
$block->position($pos);
|
$block->position($pos);
|
||||||
if($direct === true){
|
if($direct === true){
|
||||||
$pk = new UpdateBlockPacket;
|
$this->sendBlockToAll($pos->x, $pos->y, $pos->z);
|
||||||
$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);
|
|
||||||
}else{
|
}else{
|
||||||
$i = ($pos->x >> 4) . ":" . ($pos->y >> 4) . ":" . ($pos->z >> 4);
|
$i = ($pos->x >> 4) . ":" . ($pos->y >> 4) . ":" . ($pos->z >> 4);
|
||||||
if(!isset($this->changedBlocks[$i])){
|
if(!isset($this->changedBlocks[$i])){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue