package net.minecraft.world.item;

import java.util.AbstractList;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.effect.MobEffect;

public class SuspiciousStewItem extends Item {
    public SuspiciousStewItem(final Properties a) {
        super(a);
    }
    
    public static void saveMobEffect(final ItemStack bki, final MobEffect aoe, final int integer) {
        final CompoundTag le4 = bki.getOrCreateTag();
        final ListTag lk5 = le4.getList("Effects", 9);
        final CompoundTag le5 = new CompoundTag();
        le5.putByte("EffectId", (byte)MobEffect.getId(aoe));
        le5.putInt("EffectDuration", integer);
        ((AbstractList<CompoundTag>)lk5).add(le5);
        le4.put("Effects", lk5);
    }
    
    @Override
    public ItemStack finishUsingItem(final ItemStack bki, final Level bqb, final LivingEntity aoy) {
        final ItemStack bki2 = super.finishUsingItem(bki, bqb, aoy);
        final CompoundTag le6 = bki.getTag();
        if (le6 != null && le6.contains("Effects", 9)) {
            final ListTag lk7 = le6.getList("Effects", 10);
            for (int integer8 = 0; integer8 < lk7.size(); ++integer8) {
                int integer9 = 160;
                final CompoundTag le7 = lk7.getCompound(integer8);
                if (le7.contains("EffectDuration", 3)) {
                    integer9 = le7.getInt("EffectDuration");
                }
                final MobEffect aoe11 = MobEffect.byId(le7.getByte("EffectId"));
                if (aoe11 != null) {
                    aoy.addEffect(new MobEffectInstance(aoe11, integer9));
                }
            }
        }
        if (aoy instanceof Player && ((Player)aoy).abilities.instabuild) {
            return bki2;
        }
        return new ItemStack(Items.BOWL);
    }
}
