minecraft-source/src/net/minecraft/world/item/ChorusFruitItem.java

42 lines
1.7 KiB
Java

package net.minecraft.world.item;
import net.minecraft.world.entity.player.Player;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
public class ChorusFruitItem extends Item {
public ChorusFruitItem(final Properties a) {
super(a);
}
@Override
public ItemStack finishUsingItem(final ItemStack bek, final Level bjt, final LivingEntity akw) {
final ItemStack bek2 = super.finishUsingItem(bek, bjt, akw);
if (!bjt.isClientSide) {
final double double6 = akw.getX();
final double double7 = akw.getY();
final double double8 = akw.getZ();
for (int integer12 = 0; integer12 < 16; ++integer12) {
final double double9 = akw.getX() + (akw.getRandom().nextDouble() - 0.5) * 16.0;
final double double10 = Mth.clamp(akw.getY() + (akw.getRandom().nextInt(16) - 8), 0.0, bjt.getHeight() - 1);
final double double11 = akw.getZ() + (akw.getRandom().nextDouble() - 0.5) * 16.0;
if (akw.isPassenger()) {
akw.stopRiding();
}
if (akw.randomTeleport(double9, double10, double11, true)) {
bjt.playSound(null, double6, double7, double8, SoundEvents.CHORUS_FRUIT_TELEPORT, SoundSource.PLAYERS, 1.0f, 1.0f);
akw.playSound(SoundEvents.CHORUS_FRUIT_TELEPORT, 1.0f, 1.0f);
break;
}
}
if (akw instanceof Player) {
((Player)akw).getCooldowns().addCooldown(this, 20);
}
}
return bek2;
}
}