package net.minecraft.world.item.crafting;

import net.minecraft.world.Container;
import net.minecraft.world.effect.MobEffectInstance;
import java.util.Collection;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.resources.ResourceLocation;

public class TippedArrowRecipe extends CustomRecipe {
    public TippedArrowRecipe(final ResourceLocation uh) {
        super(uh);
    }
    
    @Override
    public boolean matches(final CraftingContainer bgu, final Level bqb) {
        if (bgu.getWidth() != 3 || bgu.getHeight() != 3) {
            return false;
        }
        for (int integer4 = 0; integer4 < bgu.getWidth(); ++integer4) {
            for (int integer5 = 0; integer5 < bgu.getHeight(); ++integer5) {
                final ItemStack bki6 = bgu.getItem(integer4 + integer5 * bgu.getWidth());
                if (bki6.isEmpty()) {
                    return false;
                }
                final Item bke7 = bki6.getItem();
                if (integer4 == 1 && integer5 == 1) {
                    if (bke7 != Items.LINGERING_POTION) {
                        return false;
                    }
                }
                else if (bke7 != Items.ARROW) {
                    return false;
                }
            }
        }
        return true;
    }
    
    @Override
    public ItemStack assemble(final CraftingContainer bgu) {
        final ItemStack bki3 = bgu.getItem(1 + bgu.getWidth());
        if (bki3.getItem() != Items.LINGERING_POTION) {
            return ItemStack.EMPTY;
        }
        final ItemStack bki4 = new ItemStack(Items.TIPPED_ARROW, 8);
        PotionUtils.setPotion(bki4, PotionUtils.getPotion(bki3));
        PotionUtils.setCustomEffects(bki4, PotionUtils.getCustomEffects(bki3));
        return bki4;
    }
    
    @Override
    public boolean canCraftInDimensions(final int integer1, final int integer2) {
        return integer1 >= 2 && integer2 >= 2;
    }
    
    @Override
    public RecipeSerializer<?> getSerializer() {
        return RecipeSerializer.TIPPED_ARROW;
    }
}
