mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
players are now invisible in spectator, methods for making player invisible added
This commit is contained in:
parent
819803c634
commit
c03653a050
2 changed files with 21 additions and 2 deletions
|
|
@ -890,7 +890,16 @@ class Player{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function makeInvisibleForOnePlayer(Player $player){
|
||||
$pk = new RemoveEntityPacket;
|
||||
$pk->eid = $this->entity->eid;
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
public function makeInvisibleForAllPlayers(){
|
||||
$pk = new RemoveEntityPacket;
|
||||
$pk->eid = $this->entity->eid;
|
||||
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), $pk);
|
||||
}
|
||||
public function getGamemode(){
|
||||
switch($this->gamemode){
|
||||
case SURVIVAL:
|
||||
|
|
@ -941,6 +950,14 @@ class Player{
|
|||
$this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ", you've to do a forced reconnect.\n");
|
||||
$this->server->schedule(30, [$this, "close"], "gamemode change"); //Forces a kick
|
||||
}
|
||||
|
||||
if($this->gamemode === SPECTATOR){
|
||||
$this->makeInvisibleForAllPlayers();
|
||||
}
|
||||
if($this->gamemode === CREATIVE){
|
||||
$this->server->api->player->spawnToAllPlayers($this);
|
||||
}
|
||||
|
||||
$this->inventory = $inv;
|
||||
$this->sendSettings();
|
||||
$this->sendInventory();
|
||||
|
|
|
|||
|
|
@ -587,7 +587,9 @@ class Entity extends Position{
|
|||
if($this->player->connected !== true or $this->player->spawned === false){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->player->gamemode === SPECTATOR){
|
||||
break;
|
||||
}
|
||||
$pk = new AddPlayerPacket;
|
||||
$pk->clientID = 0; //$this->player->clientID;
|
||||
$pk->username = $this->player->username;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue