72 lines
2.3 KiB
Java
72 lines
2.3 KiB
Java
package net.minecraft.world.item;
|
|
|
|
import net.minecraft.world.InteractionResultHolder;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.sounds.SoundEvent;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.level.ItemLike;
|
|
import net.minecraft.world.effect.MobEffects;
|
|
import net.minecraft.stats.Stat;
|
|
import net.minecraft.stats.Stats;
|
|
import net.minecraft.advancements.CriteriaTriggers;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
import net.minecraft.world.level.Level;
|
|
|
|
public class HoneyBottleItem extends Item {
|
|
public HoneyBottleItem(final Properties a) {
|
|
super(a);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack finishUsingItem(final ItemStack bek, final Level bjt, final LivingEntity akw) {
|
|
super.finishUsingItem(bek, bjt, akw);
|
|
if (akw instanceof ServerPlayer) {
|
|
final ServerPlayer xe5 = (ServerPlayer)akw;
|
|
CriteriaTriggers.CONSUME_ITEM.trigger(xe5, bek);
|
|
xe5.awardStat(Stats.ITEM_USED.get(this));
|
|
}
|
|
if (!bjt.isClientSide) {
|
|
akw.removeEffect(MobEffects.POISON);
|
|
}
|
|
if (bek.isEmpty()) {
|
|
return new ItemStack(Items.GLASS_BOTTLE);
|
|
}
|
|
if (akw instanceof Player && !((Player)akw).abilities.instabuild) {
|
|
final ItemStack bek2 = new ItemStack(Items.GLASS_BOTTLE);
|
|
final Player ayg6 = (Player)akw;
|
|
if (!ayg6.inventory.add(bek2)) {
|
|
ayg6.drop(bek2, false);
|
|
}
|
|
}
|
|
return bek;
|
|
}
|
|
|
|
@Override
|
|
public int getUseDuration(final ItemStack bek) {
|
|
return 40;
|
|
}
|
|
|
|
@Override
|
|
public UseAnim getUseAnimation(final ItemStack bek) {
|
|
return UseAnim.DRINK;
|
|
}
|
|
|
|
@Override
|
|
public SoundEvent getDrinkingSound() {
|
|
return SoundEvents.HONEY_DRINK;
|
|
}
|
|
|
|
@Override
|
|
public SoundEvent getEatingSound() {
|
|
return SoundEvents.HONEY_DRINK;
|
|
}
|
|
|
|
@Override
|
|
public InteractionResultHolder<ItemStack> use(final Level bjt, final Player ayg, final InteractionHand ajh) {
|
|
ayg.startUsingItem(ajh);
|
|
return InteractionResultHolder.<ItemStack>success(ayg.getItemInHand(ajh));
|
|
}
|
|
}
|