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 sm) {
        super(sm);
    }
    
    @Override
    public boolean matches(final CraftingContainer baz, final Level bjw) {
        if (baz.getWidth() != 3 || baz.getHeight() != 3) {
            return false;
        }
        for (int integer4 = 0; integer4 < baz.getWidth(); ++integer4) {
            for (int integer5 = 0; integer5 < baz.getHeight(); ++integer5) {
                final ItemStack ben6 = baz.getItem(integer4 + integer5 * baz.getWidth());
                if (ben6.isEmpty()) {
                    return false;
                }
                final Item bei7 = ben6.getItem();
                if (integer4 == 1 && integer5 == 1) {
                    if (bei7 != Items.LINGERING_POTION) {
                        return false;
                    }
                }
                else if (bei7 != Items.ARROW) {
                    return false;
                }
            }
        }
        return true;
    }
    
    @Override
    public ItemStack assemble(final CraftingContainer baz) {
        final ItemStack ben3 = baz.getItem(1 + baz.getWidth());
        if (ben3.getItem() != Items.LINGERING_POTION) {
            return ItemStack.EMPTY;
        }
        final ItemStack ben4 = new ItemStack(Items.TIPPED_ARROW, 8);
        PotionUtils.setPotion(ben4, PotionUtils.getPotion(ben3));
        PotionUtils.setCustomEffects(ben4, PotionUtils.getCustomEffects(ben3));
        return ben4;
    }
    
    @Override
    public boolean canCraftInDimensions(final int integer1, final int integer2) {
        return integer1 >= 2 && integer2 >= 2;
    }
    
    @Override
    public RecipeSerializer<?> getSerializer() {
        return RecipeSerializer.TIPPED_ARROW;
    }
}
