Search in sources :

Example 1 with MachineSound

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);
        }
    }
}
Also used : Particle(net.minecraft.client.particle.Particle) Random(java.util.Random) Vector3d(com.enderio.core.common.vecmath.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) MachineSound(crazypants.enderio.base.machine.sound.MachineSound) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with MachineSound

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;
        }
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) MachineSound(crazypants.enderio.base.machine.sound.MachineSound) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

MachineSound (crazypants.enderio.base.machine.sound.MachineSound)2 BlockPos (net.minecraft.util.math.BlockPos)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 Vector3d (com.enderio.core.common.vecmath.Vector3d)1 Random (java.util.Random)1 Particle (net.minecraft.client.particle.Particle)1