ItemStackRequestExecutor: fixed another possible crash condition

This commit is contained in:
Dylan K. Taylor 2023-03-21 00:06:33 +00:00
parent ccd288d7fa
commit 955f7944bb
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -141,6 +141,9 @@ final class ItemStackRequestExecutor{
private function removeItemFromSlot(ItemStackRequestSlotInfo $slotInfo, int $count) : Item{
$this->requestSlotInfos[] = $slotInfo;
[$inventory, $slot] = $this->getBuilderInventoryAndSlot($slotInfo);
if($count === 0){
throw new ItemStackRequestProcessException($this->prettyInventoryAndSlot($inventory, $slot) . ": Cannot take 0 items from a stack");
}
$existingItem = $inventory->getItem($slot);
if($existingItem->getCount() < $count){