Force-close the inventory window when crafting fails to avoid desync issues

mojang, why does this have to be hard work
This commit is contained in:
Dylan K. Taylor
2017-10-03 11:04:21 +01:00
parent 76117e7fa0
commit 9bbebaa071
3 changed files with 31 additions and 17 deletions

View File

@ -2297,7 +2297,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
if($this->craftingTransaction->getPrimaryOutput() !== null){
//we get the actions for this in several packets, so we can't execute it until we get the result
$this->craftingTransaction->execute(); //if it can't execute, no inventories will be modified
$this->craftingTransaction->execute();
$this->craftingTransaction = null;
}
@ -2312,16 +2312,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$transaction = new InventoryTransaction($this, $actions);
if(!$transaction->execute()){
foreach($transaction->getInventories() as $inventory){
$inventory->sendContents($this);
if($inventory instanceof PlayerInventory){
$inventory->sendArmorContents($this);
}
}
$this->server->getLogger()->debug("Failed to execute inventory transaction from " . $this->getName() . " with actions: " . json_encode($packet->actions));
//TODO: check more stuff that might need reversion
return false; //oops!
}