Player: move sendAllInventories() to network layer

This commit is contained in:
Dylan K. Taylor
2019-05-26 15:58:03 +01:00
parent 85718e2750
commit 33d1203bfd
4 changed files with 16 additions and 9 deletions

View File

@ -819,6 +819,12 @@ class NetworkSession{
}
}
public function syncAllInventoryContents() : void{
foreach($this->player->getAllWindows() as $inventory){
$this->syncInventoryContents($inventory);
}
}
public function syncInventoryData(Inventory $inventory, int $propertyId, int $value) : void{
$windowId = $this->player->getWindowId($inventory);
if($windowId !== ContainerIds::NONE){

View File

@ -158,7 +158,7 @@ class InGameSessionHandler extends SessionHandler{
public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool{
if($this->player->isSpectator()){
$this->player->sendAllInventories();
$this->session->syncAllInventoryContents();
return true;
}
@ -167,7 +167,7 @@ class InGameSessionHandler extends SessionHandler{
if($packet->trData instanceof NormalTransactionData){
$result = $this->handleNormalTransaction($packet->trData);
}elseif($packet->trData instanceof MismatchTransactionData){
$this->player->sendAllInventories();
$this->session->syncAllInventoryContents();
$result = true;
}elseif($packet->trData instanceof UseItemTransactionData){
$result = $this->handleUseItemTransaction($packet->trData);
@ -178,7 +178,7 @@ class InGameSessionHandler extends SessionHandler{
}
if(!$result){
$this->player->sendAllInventories();
$this->session->syncAllInventoryContents();
}
return $result;
}

View File

@ -91,7 +91,7 @@ class PreSpawnSessionHandler extends SessionHandler{
$this->player->sendPotionEffects($this->player);
$this->player->sendData($this->player);
$this->player->sendAllInventories();
$this->session->syncAllInventoryContents();
$this->player->getInventory()->sendCreativeContents();
$this->player->getInventory()->sendHeldItem($this->player);
$this->session->queueCompressed($this->server->getCraftingManager()->getCraftingDataPacket());