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.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 sm) {
        super(sm);
    }
    
    @Override
    public boolean matches(final CraftingContainer baz, final Level bjw) {
        boolean boolean4 = false;
        boolean boolean5 = false;
        boolean boolean6 = false;
        boolean boolean7 = false;
        for (int integer8 = 0; integer8 < baz.getContainerSize(); ++integer8) {
            final ItemStack ben9 = baz.getItem(integer8);
            if (!ben9.isEmpty()) {
                if (ben9.getItem() == Blocks.BROWN_MUSHROOM.asItem() && !boolean6) {
                    boolean6 = true;
                }
                else if (ben9.getItem() == Blocks.RED_MUSHROOM.asItem() && !boolean5) {
                    boolean5 = true;
                }
                else if (ben9.getItem().is(ItemTags.SMALL_FLOWERS) && !boolean4) {
                    boolean4 = true;
                }
                else {
                    if (ben9.getItem() != Items.BOWL || boolean7) {
                        return false;
                    }
                    boolean7 = true;
                }
            }
        }
        return boolean4 && boolean6 && boolean5 && boolean7;
    }
    
    @Override
    public ItemStack assemble(final CraftingContainer baz) {
        ItemStack ben3 = ItemStack.EMPTY;
        for (int integer4 = 0; integer4 < baz.getContainerSize(); ++integer4) {
            final ItemStack ben4 = baz.getItem(integer4);
            if (!ben4.isEmpty()) {
                if (ben4.getItem().is(ItemTags.SMALL_FLOWERS)) {
                    ben3 = ben4;
                    break;
                }
            }
        }
        final ItemStack ben5 = new ItemStack(Items.SUSPICIOUS_STEW, 1);
        if (ben3.getItem() instanceof BlockItem && ((BlockItem)ben3.getItem()).getBlock() instanceof FlowerBlock) {
            final FlowerBlock brl5 = (FlowerBlock)((BlockItem)ben3.getItem()).getBlock();
            final MobEffect aki6 = brl5.getSuspiciousStewEffect();
            SuspiciousStewItem.saveMobEffect(ben5, aki6, brl5.getEffectDuration());
        }
        return ben5;
    }
    
    @Override
    public boolean canCraftInDimensions(final int integer1, final int integer2) {
        return integer1 >= 2 && integer2 >= 2;
    }
    
    @Override
    public RecipeSerializer<?> getSerializer() {
        return RecipeSerializer.SUSPICIOUS_STEW;
    }
}
