38 lines
1.5 KiB
Java
38 lines
1.5 KiB
Java
package net.minecraft.world.item;
|
|
|
|
import net.minecraft.stats.Stat;
|
|
import net.minecraft.stats.Stats;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
|
|
import net.minecraft.sounds.SoundSource;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.world.InteractionResultHolder;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.level.Level;
|
|
|
|
public class EnderpearlItem extends Item {
|
|
public EnderpearlItem(final Properties a) {
|
|
super(a);
|
|
}
|
|
|
|
@Override
|
|
public InteractionResultHolder<ItemStack> use(final Level bjt, final Player ayg, final InteractionHand ajh) {
|
|
final ItemStack bek5 = ayg.getItemInHand(ajh);
|
|
bjt.playSound(null, ayg.getX(), ayg.getY(), ayg.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5f, 0.4f / (EnderpearlItem.random.nextFloat() * 0.4f + 0.8f));
|
|
ayg.getCooldowns().addCooldown(this, 20);
|
|
if (!bjt.isClientSide) {
|
|
final ThrownEnderpearl aze6 = new ThrownEnderpearl(bjt, ayg);
|
|
aze6.setItem(bek5);
|
|
aze6.shootFromRotation(ayg, ayg.xRot, ayg.yRot, 0.0f, 1.5f, 1.0f);
|
|
bjt.addFreshEntity(aze6);
|
|
}
|
|
ayg.awardStat(Stats.ITEM_USED.get(this));
|
|
if (!ayg.abilities.instabuild) {
|
|
bek5.shrink(1);
|
|
}
|
|
return InteractionResultHolder.<ItemStack>success(bek5);
|
|
}
|
|
}
|