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 ben, final MobEffect aki, final int integer) {
        final CompoundTag jt4 = ben.getOrCreateTag();
        final ListTag jz5 = jt4.getList("Effects", 9);
        final CompoundTag jt5 = new CompoundTag();
        jt5.putByte("EffectId", (byte)MobEffect.getId(aki));
        jt5.putInt("EffectDuration", integer);
        ((AbstractList<CompoundTag>)jz5).add(jt5);
        jt4.put("Effects", jz5);
    }
    
    @Override
    public ItemStack finishUsingItem(final ItemStack ben, final Level bjw, final LivingEntity akz) {
        final ItemStack ben2 = super.finishUsingItem(ben, bjw, akz);
        final CompoundTag jt6 = ben.getTag();
        if (jt6 != null && jt6.contains("Effects", 9)) {
            final ListTag jz7 = jt6.getList("Effects", 10);
            for (int integer8 = 0; integer8 < jz7.size(); ++integer8) {
                int integer9 = 160;
                final CompoundTag jt7 = jz7.getCompound(integer8);
                if (jt7.contains("EffectDuration", 3)) {
                    integer9 = jt7.getInt("EffectDuration");
                }
                final MobEffect aki11 = MobEffect.byId(jt7.getByte("EffectId"));
                if (aki11 != null) {
                    akz.addEffect(new MobEffectInstance(aki11, integer9));
                }
            }
        }
        if (akz instanceof Player && ((Player)akz).abilities.instabuild) {
            return ben2;
        }
        return new ItemStack(Items.BOWL);
    }
}
