Added config options for sounds.

Normalised volumes a bit between machines.
This commit is contained in:
CrazyPants committed 2014-08-10 20:56:43 +08:00
1 parent 345f1bc108
commit 5b1ce7c2e0
5 files changed
+44 -27

No files matched your search

@@ -236,6 +236,10 @@ public final class Config {
public static long nutrientFoodBoostDelay = 400;
public static int enchanterBaseLevelCost = 4;
public static boolean machineSoundsEnabled = true;
public static float machineSoundVolume = 0.75f;
public static void load(FMLPreInitializationEvent event) {
@@ -361,6 +365,12 @@ public final class Config {
useSneakRightClickYetaWrench = config.get(sectionPersonal.name, "useSneakRightClickYetaWrench", useSneakRightClickYetaWrench,
"If true, shift-clicking the YetaWrench on a null or non wrenchable object will change the conduit display mode.")
.getBoolean(useSneakRightClickYetaWrench);
machineSoundsEnabled = config.get(sectionPersonal.name, "useMachineSounds", machineSoundsEnabled,
"If true, machines will make sounds.")
.getBoolean(machineSoundsEnabled);
machineSoundVolume= (float)config.get(sectionPersonal.name, "machineSoundVolume", machineSoundVolume,"Volume of machine sounds.").getDouble(machineSoundVolume);
itemConduitUsePhyscialDistance = config.get(sectionEfficiency.name, "itemConduitUsePhyscialDistance", itemConduitUsePhyscialDistance, "If true, " +
"'line of sight' distance rather than conduit path distance is used to calculate priorities.")
@@ -24,6 +24,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.TileEntityEio;
import crazypants.enderio.config.Config;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.power.Capacitors;
import crazypants.enderio.power.ICapacitor;
@@ -71,10 +72,10 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
@SideOnly(Side.CLIENT)
private MachineSound sound;
@SideOnly(Side.CLIENT)
private final ResourceLocation soundRes;
protected static ResourceLocation getSoundFor(String sound) {
return new ResourceLocation(EnderIO.MODID + ":" + sound);
}
@@ -217,18 +218,18 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
public boolean hasSound() {
return getSoundName() != null;
}
public float getVolume() {
return 0.75f;
return Config.machineSoundVolume;
}
public float getPitch() {
return 1.0f;
}
@SideOnly(Side.CLIENT)
private void updateSound() {
if(isActive() && !isInvalid()) {
if(Config.machineSoundsEnabled & isActive() && !isInvalid()) {
if(sound == null) {
sound = new MachineSound(soundRes, xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, getVolume(), getPitch());
FMLClientHandler.instance().getClient().getSoundHandler().playSound(sound);
@@ -351,12 +352,10 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
updateSound();
}
if(worldObj.isRemote && isActive())
if(forceClientUpdate) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
forceClientUpdate = false;
}
if(forceClientUpdate) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
forceClientUpdate = false;
}
return;
} // else is server, do all logic only on the server
@@ -528,11 +527,11 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
@Override
public void invalidate() {
super.invalidate();
if (worldObj.isRemote) {
if(worldObj.isRemote) {
updateSound();
}
}
@Override
public void readCustomNBT(NBTTagCompound nbtRoot) {
@@ -33,7 +33,7 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
@Override
public String getMachineName() {
return ModObject.blockSagMill.unlocalisedName;
}
}
@Override
protected boolean isMachineItemValidForSlot(int i, ItemStack itemstack) {
@@ -144,6 +144,6 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
}
public float getVolume() {
return 0.5f;
return super.getVolume() * 0.125f;
}
}
@@ -14,6 +14,7 @@ import cpw.mods.fml.relauncher.Side;
import crazypants.enderio.EnderIO;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.config.Config;
import crazypants.enderio.machine.AbstractMachineBlock;
import crazypants.enderio.network.PacketHandler;
import crazypants.util.FluidUtil;
@@ -119,17 +120,20 @@ public class BlockZombieGenerator extends AbstractMachineBlock<TileZombieGenerat
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileZombieGenerator && ((TileZombieGenerator) te).isActive()) {
//see RenderGlobal.doSpawnParticle
for (int i = 0; i < 1; i++) {
float xOffset = 0.5f + (world.rand.nextFloat() * 2.0F - 1.0F) * 0.125f;
float yOffset = 0.1f;
float zOffset = 0.5f + (world.rand.nextFloat() * 2.0F - 1.0F) * 0.125f;
world.spawnParticle("bubble", x + xOffset, y + yOffset, z + zOffset, -0.1D, 0.5D, 0.0D);
}
if (world.rand.nextInt(1) == 0) {
world.playSound(x + 0.5, y + 1, z + 0.5, EnderIO.MODID + ":generator.zombie.bubble", world.rand.nextFloat() * 0.05f + 0.025f, world.rand.nextFloat() * 0.5f + 0.5f, false);
if(rand.nextInt(3) == 0) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileZombieGenerator && ((TileZombieGenerator) te).isActive()) {
//see RenderGlobal.doSpawnParticle
for (int i = 0; i < 1; i++) {
float xOffset = 0.5f + (world.rand.nextFloat() * 2.0F - 1.0F) * 0.125f;
float yOffset = 0.1f;
float zOffset = 0.5f + (world.rand.nextFloat() * 2.0F - 1.0F) * 0.125f;
world.spawnParticle("bubble", x + xOffset, y + yOffset, z + zOffset, -0.1D, 0.5D, 0.0D);
}
if(Config.machineSoundsEnabled) {
float volume = (Config.machineSoundVolume * 0.045f);
world.playSound(x + 0.5, y + 1, z + 0.5, EnderIO.MODID + ":generator.zombie.bubble", volume, world.rand.nextFloat() * 0.75f, false);
}
}
}
}
@@ -315,4 +315,8 @@ public class TileVat extends AbstractPoweredTaskEntity implements IFluidHandler
public float getPitch() {
return 0.3f;
}
public float getVolume() {
return super.getVolume() * 0.3f;
}
}