Search in sources :

Example 1 with IETileSound

use of blusunrize.immersiveengineering.common.util.sound.IETileSound in project ImmersiveEngineering by BluSunrize.

the class ClientUtils method generatePositionedIESound.

public static IETileSound generatePositionedIESound(SoundEvent soundEvent, float volume, float pitch, boolean repeat, int delay, BlockPos pos) {
    IETileSound sound = new IETileSound(soundEvent, volume, pitch, repeat, delay, pos, AttenuationType.LINEAR, SoundCategory.BLOCKS);
    //		sound.evaluateVolume();
    ClientUtils.mc().getSoundHandler().playSound(sound);
    return sound;
}
Also used : IETileSound(blusunrize.immersiveengineering.common.util.sound.IETileSound)

Example 2 with IETileSound

use of blusunrize.immersiveengineering.common.util.sound.IETileSound in project ImmersiveEngineering by BluSunrize.

the class ClientProxy method handleTileSound.

@Override
public void handleTileSound(SoundEvent soundEvent, TileEntity tile, boolean tileActive, float volume, float pitch) {
    BlockPos pos = tile.getPos();
    IETileSound sound = tileSoundMap.get(pos);
    if (sound == null && tileActive) {
        sound = ClientUtils.generatePositionedIESound(soundEvent, volume, pitch, true, 0, pos);
        tileSoundMap.put(pos, sound);
    } else if (sound != null && !tileActive) {
        sound.donePlaying = true;
        ClientUtils.mc().getSoundHandler().stopSound(sound);
        tileSoundMap.remove(pos);
    }
//		IESound sound = soundMap.get(soundName);
//		if(tileActive)
//		if(sound!=null)
//		{
//			if(new BlockPos(sound.getXPosF(), sound.getYPosF(), sound.getZPosF()).equals(tile.getPos()))
//			{
//				if(!tileActive)
//				{
////					sound.donePlaying = true;
////					sound.volume = 0;
////					ClientUtils.mc().getSoundHandler().stopSound(sound);
////					soundMap.remove(soundName);
//				}
//			}
//			else if(tileActive)
//			{
//				double dx = (sound.getXPosF()-ClientUtils.mc().getRenderViewEntity().posX)*(sound.getXPosF()-ClientUtils.mc().getRenderViewEntity().posX);
//				double dy = (sound.getYPosF()-ClientUtils.mc().getRenderViewEntity().posY)*(sound.getYPosF()-ClientUtils.mc().getRenderViewEntity().posY);
//				double dz = (sound.getZPosF()-ClientUtils.mc().getRenderViewEntity().posZ)*(sound.getZPosF()-ClientUtils.mc().getRenderViewEntity().posZ);
//				double dx1 = (tile.getPos().getX()-ClientUtils.mc().getRenderViewEntity().posX)*(tile.getPos().getX()-ClientUtils.mc().getRenderViewEntity().posX);
//				double dy1 = (tile.getPos().getY()-ClientUtils.mc().getRenderViewEntity().posY)*(tile.getPos().getY()-ClientUtils.mc().getRenderViewEntity().posY);
//				double dz1 = (tile.getPos().getZ()-ClientUtils.mc().getRenderViewEntity().posZ)*(tile.getPos().getZ()-ClientUtils.mc().getRenderViewEntity().posZ);
//				if((dx1+dy1+dz1)<(dx+dy+dz))
//				{
////					sound.setPos(tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ());
////					soundMap.put(soundName, sound);
//				}
//			}
//		}
//		else if(tileActive)
//		{
//			MovingSound
//			sound = ClientUtils.generatePositionedIESound("immersiveengineering:"+soundName, volume, pitch, true, 0, tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ());
////			soundMap.put(soundName, sound);
//		}
}
Also used : IETileSound(blusunrize.immersiveengineering.common.util.sound.IETileSound) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with IETileSound

use of blusunrize.immersiveengineering.common.util.sound.IETileSound in project ImmersiveEngineering by BluSunrize.

the class ClientProxy method stopTileSound.

@Override
public void stopTileSound(String soundName, TileEntity tile) {
    IETileSound sound = soundMap.get(soundName);
    if (sound != null && new BlockPos(sound.getXPosF(), sound.getYPosF(), sound.getZPosF()).equals(tile.getPos())) {
        ClientUtils.mc().getSoundHandler().stopSound(sound);
        sound = null;
    }
}
Also used : IETileSound(blusunrize.immersiveengineering.common.util.sound.IETileSound) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

IETileSound (blusunrize.immersiveengineering.common.util.sound.IETileSound)3 BlockPos (net.minecraft.util.math.BlockPos)2