package com.dairymoose.modernlife.tileentities;

import javax.annotation.Nonnull;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.wrapper.InvWrapper;

/* loaded from: outputsrg.jar:com/dairymoose/modernlife/tileentities/ExtractorItemHandler.class */
public class ExtractorItemHandler extends InvWrapper {
    private final ExtractorBlockEntity hopper;

    public ExtractorItemHandler(ExtractorBlockEntity hopper) {
        super(hopper);
        this.hopper = hopper;
    }

    @Nonnull
    public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
        if (simulate) {
            return super.insertItem(slot, stack, simulate);
        }
        boolean wasEmpty = getInv().isEmpty();
        int originalStackSize = stack.getCount();
        ItemStack stack2 = super.insertItem(slot, stack, simulate);
        if (wasEmpty && originalStackSize > stack2.getCount() && !this.hopper.isOnCustomCooldown()) {
            this.hopper.setCooldown(8);
        }
        return stack2;
    }
}
