package net.blay09.mods.cookingforblockheads.util;

import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;

import javax.annotation.Nonnull;

public class NonOccupyingItemHandler implements IItemHandler {

    private final IItemHandler itemHandler;

    public NonOccupyingItemHandler(IItemHandler itemHandler) {
        this.itemHandler = itemHandler;
    }

    @Override
    public int getSlots() {
        return itemHandler.getSlots();
    }

    @Nonnull
    @Override
    public ItemStack getStackInSlot(int slot) {
        return itemHandler.getStackInSlot(slot);
    }

    @Nonnull
    @Override
    public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
        if (itemHandler.extractItem(slot, 1, true).isEmpty()) {
            return stack;
        }

        return itemHandler.insertItem(slot, stack, simulate);
    }

    @Nonnull
    @Override
    public ItemStack extractItem(int slot, int amount, boolean simulate) {
        return itemHandler.extractItem(slot, amount, simulate);
    }

    @Override
    public int getSlotLimit(int slot) {
        return itemHandler.getSlotLimit(slot);
    }

}

@@ -708,32 +708,118 @@
 ean simulate) %7B%0A
+        boolean foundItem = false;%0A        for (int i = 0; i %3C getSlots(); i++) %7B%0A    
         if (item
@@ -838,20 +838,17 @@
 actItem(
-slot
+i
 , 1, tru
@@ -854,15 +854,34 @@
 ue).
-isEmpty
+getItem() == stack.getItem
 ()) 
@@ -898,21 +898,66 @@
     
+    
-return stack;
+foundItem = true;%0A                break;%0A            %7D
 %0A   
@@ -970,32 +970,44 @@
 %0A%0A        return
+ foundItem ?
  itemHandler.ins
@@ -1028,32 +1028,40 @@
 stack, simulate)
+ : stack
 ;%0A    %7D%0A%0A    @No

Improve #321 support to work more like Quark's smart dropoff