better handle buggy IItemHandlers

This commit is contained in:
Adrian Siekierka 2022-06-08 20:20:32 +02:00
parent 318d82092c
commit eb2619b6de

View File

@ -142,8 +142,12 @@ object InventoryUtils {
val count = (amount - extracted.getCount) max 0 val count = (amount - extracted.getCount) max 0
if (count > 0) inventory.extractItem(slot, count, false) match { if (count > 0) inventory.extractItem(slot, count, false) match {
case realExtracted: ItemStack if realExtracted.getCount == count => consumer(realExtracted, false) case realExtracted: ItemStack if realExtracted.getCount == count => consumer(realExtracted, false)
case _ => case realExtracted =>
OpenComputers.log.warn("An IItemHandler instance acted differently between simulated and non-simulated extraction. Offender: " + inventory) OpenComputers.log.warn("An IItemHandler instance acted differently between simulated and non-simulated extraction. Offender: " + inventory)
// Attempt inserting the stack anyway, to minimize world-side item loss.
if (realExtracted != null && !realExtracted.isEmpty) {
consumer(realExtracted, false)
}
} }
count count
case _ => 0 case _ => 0