package net.minecraft.world.inventory;

import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Player;

public class FurnaceResultSlot extends Slot {
    private final Player player;
    private int removeCount;
    
    public FurnaceResultSlot(final Player bec, final Container amz, final int integer3, final int integer4, final int integer5) {
        super(amz, integer3, integer4, integer5);
        this.player = bec;
    }
    
    @Override
    public boolean mayPlace(final ItemStack bki) {
        return false;
    }
    
    @Override
    public ItemStack remove(final int integer) {
        if (this.hasItem()) {
            this.removeCount += Math.min(integer, this.getItem().getCount());
        }
        return super.remove(integer);
    }
    
    @Override
    public ItemStack onTake(final Player bec, final ItemStack bki) {
        this.checkTakeAchievements(bki);
        super.onTake(bec, bki);
        return bki;
    }
    
    @Override
    protected void onQuickCraft(final ItemStack bki, final int integer) {
        this.removeCount += integer;
        this.checkTakeAchievements(bki);
    }
    
    @Override
    protected void checkTakeAchievements(final ItemStack bki) {
        bki.onCraftedBy(this.player.level, this.player, this.removeCount);
        if (!this.player.level.isClientSide && this.container instanceof AbstractFurnaceBlockEntity) {
            ((AbstractFurnaceBlockEntity)this.container).awardUsedRecipesAndPopExperience(this.player);
        }
        this.removeCount = 0;
    }
}
