use of crazypants.enderio.base.machine.sound.MachineSound in project EnderIO by SleepyTrousers.
the class ItemRodOfReturn method onUsingClient.
@SideOnly(Side.CLIENT)
private void onUsingClient(ItemStack stack, EntityLivingBase player, int timeLeft) {
if (timeLeft > (Config.rodOfReturnTicksToActivate - 2)) {
return;
}
float progress = 1 - ((float) timeLeft / Config.rodOfReturnTicksToActivate);
float spinSpeed = progress * 2;
if (activeSound != null) {
activeSound.setPitch(MathHelper.clamp(0.5f + (spinSpeed / 1.5f), 0.5f, 2));
}
if (activeSound == null) {
BlockPos p = player.getPosition();
activeSound = new MachineSound(ACTIVE_RES, p.getX(), p.getY(), p.getZ(), 0.3f, 1);
playSound();
}
double dist = 2 - (progress * 1.5);
Random rand = player.world.rand;
for (int i = 0; i < 6; i++) {
double xo = randomOffset(rand, dist);
double yo = randomOffset(rand, dist);
double zo = randomOffset(rand, dist);
double x = player.posX + xo;
double y = player.posY + yo + player.height / 2;
double z = player.posZ + zo;
Vector3d velocity = new Vector3d(xo, yo, zo);
velocity.normalize();
Particle fx = Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(EnumParticleTypes.PORTAL.getParticleID(), x, y, z, 0, 0, 0, 0);
if (fx != null) {
// if(rand.nextInt(8) == 0) {
// fx.setRBGColorF((rand.nextFloat() * 0.1f), 0.6f + (rand.nextFloat() * 0.15f), 0.75f + (rand.nextFloat() * 0.2f));
// }
ClientUtil.setParticleVelocity(fx, velocity.x, velocity.y, velocity.z);
fx.setMaxAge(timeLeft + 2);
}
}
}
use of crazypants.enderio.base.machine.sound.MachineSound in project EnderIO by SleepyTrousers.
the class TileTelePad method updateEntityClient.
@Override
@SideOnly(Side.CLIENT)
protected void updateEntityClient() {
updateRotations();
if (activeSound != null) {
activeSound.setPitch(MathHelper.clamp(0.5f + (spinSpeed / 1.5f), 0.5f, 2));
}
if (active()) {
if (activeSound == null) {
BlockPos p = getPos();
FMLClientHandler.instance().getClient().getSoundHandler().playSound(activeSound = new MachineSound(ACTIVE_RES, p.getX(), p.getY(), p.getZ(), 0.3f, 1));
}
updateQueuedEntities();
} else if (!active() && activeSound != null) {
if (activeSound.getPitch() <= 0.5f) {
activeSound.endPlaying();
activeSound = null;
}
}
}
Aggregations