package net.minecraft.world.item.crafting;

import net.minecraft.world.Container;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.item.SuspiciousStewItem;
import net.minecraft.world.level.block.FlowerBlock;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.Item;
import net.minecraft.tags.Tag;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.Level;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.resources.ResourceLocation;

public class SuspiciousStewRecipe extends CustomRecipe {
    public SuspiciousStewRecipe(final ResourceLocation uh) {
        super(uh);
    }
    
    @Override
    public boolean matches(final CraftingContainer bgu, final Level bqb) {
        boolean boolean4 = false;
        boolean boolean5 = false;
        boolean boolean6 = false;
        boolean boolean7 = false;
        for (int integer8 = 0; integer8 < bgu.getContainerSize(); ++integer8) {
            final ItemStack bki9 = bgu.getItem(integer8);
            if (!bki9.isEmpty()) {
                if (bki9.getItem() == Blocks.BROWN_MUSHROOM.asItem() && !boolean6) {
                    boolean6 = true;
                }
                else if (bki9.getItem() == Blocks.RED_MUSHROOM.asItem() && !boolean5) {
                    boolean5 = true;
                }
                else if (bki9.getItem().is(ItemTags.SMALL_FLOWERS) && !boolean4) {
                    boolean4 = true;
                }
                else {
                    if (bki9.getItem() != Items.BOWL || boolean7) {
                        return false;
                    }
                    boolean7 = true;
                }
            }
        }
        return boolean4 && boolean6 && boolean5 && boolean7;
    }
    
    @Override
    public ItemStack assemble(final CraftingContainer bgu) {
        ItemStack bki3 = ItemStack.EMPTY;
        for (int integer4 = 0; integer4 < bgu.getContainerSize(); ++integer4) {
            final ItemStack bki4 = bgu.getItem(integer4);
            if (!bki4.isEmpty()) {
                if (bki4.getItem().is(ItemTags.SMALL_FLOWERS)) {
                    bki3 = bki4;
                    break;
                }
            }
        }
        final ItemStack bki5 = new ItemStack(Items.SUSPICIOUS_STEW, 1);
        if (bki3.getItem() instanceof BlockItem && ((BlockItem)bki3.getItem()).getBlock() instanceof FlowerBlock) {
            final FlowerBlock bxx5 = (FlowerBlock)((BlockItem)bki3.getItem()).getBlock();
            final MobEffect aoe6 = bxx5.getSuspiciousStewEffect();
            SuspiciousStewItem.saveMobEffect(bki5, aoe6, bxx5.getEffectDuration());
        }
        return bki5;
    }
    
    @Override
    public boolean canCraftInDimensions(final int integer1, final int integer2) {
        return integer1 >= 2 && integer2 >= 2;
    }
    
    @Override
    public RecipeSerializer<?> getSerializer() {
        return RecipeSerializer.SUSPICIOUS_STEW;
    }
}
