InventoryTransaction: Avoid crashing when trying to compact slot changes with invalid slot numbers

fixes #2250
This commit is contained in:
Dylan K. Taylor 2018-06-19 18:31:13 +01:00
parent 03510333dc
commit d2a037de71

View File

@ -173,6 +173,9 @@ class InventoryTransaction{
$inventory = $inventories[$hash];
$slot = $slots[$hash];
if(!$inventory->slotExists($slot)){ //this can get hit for crafting tables because the validation happens after this compaction
throw new TransactionValidationException("Slot $slot does not exist in inventory " . get_class($inventory));
}
$sourceItem = $inventory->getItem($slot);
$targetItem = $this->findResultItem($sourceItem, $list);