Send creative inventory for all gamemodes, fixed recipe book

This commit is contained in:
Dylan K. Taylor
2017-09-12 14:40:05 +01:00
parent 1d31958ce6
commit 297172d111
2 changed files with 5 additions and 7 deletions

View File

@ -1303,9 +1303,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->inventory->sendContents($this); $this->inventory->sendContents($this);
$this->inventory->sendContents($this->getViewers()); $this->inventory->sendContents($this->getViewers());
$this->inventory->sendHeldItem($this->hasSpawned); $this->inventory->sendHeldItem($this->hasSpawned);
if($this->isCreative()){
$this->inventory->sendCreativeContents(); $this->inventory->sendCreativeContents();
}
return true; return true;
} }
@ -1937,9 +1936,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->sendCommandData(); $this->sendCommandData();
if($this->isCreative()){ $this->inventory->sendCreativeContents();
$this->inventory->sendCreativeContents();
}
$this->server->addOnlinePlayer($this); $this->server->addOnlinePlayer($this);
$this->server->onPlayerCompleteLoginSequence($this); $this->server->onPlayerCompleteLoginSequence($this);

View File

@ -509,7 +509,8 @@ class PlayerInventory extends BaseInventory{
public function sendCreativeContents(){ public function sendCreativeContents(){
$pk = new InventoryContentPacket(); $pk = new InventoryContentPacket();
$pk->windowId = ContainerIds::CREATIVE; $pk->windowId = ContainerIds::CREATIVE;
if($this->getHolder()->getGamemode() === Player::CREATIVE){
if(!$this->getHolder()->isSpectator()){ //fill it for all gamemodes except spectator
foreach(Item::getCreativeItems() as $i => $item){ foreach(Item::getCreativeItems() as $i => $item){
$pk->items[$i] = clone $item; $pk->items[$i] = clone $item;
} }