mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
51 lines
1.3 KiB
Java
51 lines
1.3 KiB
Java
package com.hbm.sound;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import com.hbm.tileentity.machine.TileEntityBroadcaster;
|
|
import com.hbm.tileentity.machine.TileEntityMachineChemplant;
|
|
import com.hbm.tileentity.machine.TileEntityMachineMiningDrill;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.audio.ISound;
|
|
import net.minecraft.client.entity.EntityClientPlayerMP;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
public class SoundLoopBroadcaster extends SoundLoopMachine {
|
|
|
|
public static List<SoundLoopBroadcaster> list = new ArrayList<SoundLoopBroadcaster>();
|
|
public float intendedVolume = 25.0F;
|
|
|
|
public SoundLoopBroadcaster(ResourceLocation path, TileEntity te) {
|
|
super(path, te);
|
|
list.add(this);
|
|
this.field_147666_i = ISound.AttenuationType.NONE;
|
|
}
|
|
|
|
@Override
|
|
public void update() {
|
|
super.update();
|
|
|
|
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
|
float f = 0;
|
|
|
|
if(player != null) {
|
|
f = (float)Math.sqrt(Math.pow(xPosF - player.posX, 2) + Math.pow(yPosF - player.posY, 2) + Math.pow(zPosF - player.posZ, 2));
|
|
volume = func(f, intendedVolume);
|
|
} else {
|
|
volume = intendedVolume;
|
|
}
|
|
}
|
|
|
|
public TileEntity getTE() {
|
|
return te;
|
|
}
|
|
|
|
public float func(float f, float v) {
|
|
return (f / v) * -2 + 2;
|
|
}
|
|
|
|
}
|