53 lines
2.0 KiB
Java
53 lines
2.0 KiB
Java
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 bek, final MobEffect akf, final int integer) {
|
|
final CompoundTag jt4 = bek.getOrCreateTag();
|
|
final ListTag jz5 = jt4.getList("Effects", 9);
|
|
final CompoundTag jt5 = new CompoundTag();
|
|
jt5.putByte("EffectId", (byte)MobEffect.getId(akf));
|
|
jt5.putInt("EffectDuration", integer);
|
|
((AbstractList<CompoundTag>)jz5).add(jt5);
|
|
jt4.put("Effects", jz5);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack finishUsingItem(final ItemStack bek, final Level bjt, final LivingEntity akw) {
|
|
final ItemStack bek2 = super.finishUsingItem(bek, bjt, akw);
|
|
final CompoundTag jt6 = bek.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 akf11 = MobEffect.byId(jt7.getByte("EffectId"));
|
|
if (akf11 != null) {
|
|
akw.addEffect(new MobEffectInstance(akf11, integer9));
|
|
}
|
|
}
|
|
}
|
|
if (akw instanceof Player && ((Player)akw).abilities.instabuild) {
|
|
return bek2;
|
|
}
|
|
return new ItemStack(Items.BOWL);
|
|
}
|
|
}
|