Make SoundHandler static, remove some unneeded stuff.
This commit is contained in:
parent
c4d1fd32f4
commit
2a52ba36af
11 changed files with 30 additions and 107 deletions
|
@ -39,12 +39,13 @@ public class MekanismConfig
|
|||
|
||||
public static class client
|
||||
{
|
||||
public static boolean enableSounds = true;
|
||||
public static boolean enablePlayerSounds = true;
|
||||
public static boolean fancyUniversalCableRender = true;
|
||||
public static boolean holidays = true;
|
||||
public static double baseSoundVolume = 1;
|
||||
public static boolean machineEffects = true;
|
||||
public static boolean oldTransmitterRender = false;
|
||||
public static boolean replaceSoundsWhenResuming = true;
|
||||
}
|
||||
|
||||
public static class usage
|
||||
|
|
|
@ -88,7 +88,6 @@ import mekanism.client.render.tileentity.RenderRotaryCondensentrator;
|
|||
import mekanism.client.render.tileentity.RenderSalinationController;
|
||||
import mekanism.client.render.tileentity.RenderSeismicVibrator;
|
||||
import mekanism.client.render.tileentity.RenderTeleporter;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.CommonProxy;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
|
@ -181,12 +180,14 @@ public class ClientProxy extends CommonProxy
|
|||
{
|
||||
super.loadConfiguration();
|
||||
|
||||
client.enableSounds = Mekanism.configuration.get("client", "EnableSounds", true).getBoolean(true);
|
||||
client.enablePlayerSounds = Mekanism.configuration.get("client", "EnableSounds", true).getBoolean(true);
|
||||
client.fancyUniversalCableRender = Mekanism.configuration.get("client", "FancyUniversalCableRender", true).getBoolean(true);
|
||||
client.holidays = Mekanism.configuration.get("client", "Holidays", true).getBoolean(true);
|
||||
client.baseSoundVolume = Mekanism.configuration.get("client", "SoundVolume", 1D).getDouble(1D);
|
||||
client.machineEffects = Mekanism.configuration.get("client", "MachineEffects", true).getBoolean(true);
|
||||
client.oldTransmitterRender = Mekanism.configuration.get("client", "OldTransmitterRender", false).getBoolean();
|
||||
client.replaceSoundsWhenResuming = Mekanism.configuration.get("client", "ReplaceSoundsWhenResuming", true,
|
||||
"If true, will reduce lagging between player sounds. Setting to false will reduce GC load").getBoolean();
|
||||
|
||||
if(Mekanism.configuration.hasChanged())
|
||||
Mekanism.configuration.save();
|
||||
|
@ -482,15 +483,6 @@ public class ClientProxy extends CommonProxy
|
|||
HolidayManager.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadSoundHandler()
|
||||
{
|
||||
if(client.enableSounds)
|
||||
{
|
||||
MekanismClient.audioHandler = new SoundHandler();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit()
|
||||
{
|
||||
|
|
|
@ -8,9 +8,9 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import mekanism.api.IClientTicker;
|
||||
import mekanism.api.MekanismConfig.client;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.client.sound.FlamethrowerSound;
|
||||
import mekanism.client.sound.GasMaskSound;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.KeySync;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
|
@ -249,45 +249,45 @@ public class ClientTickHandler
|
|||
Mekanism.packetHandler.sendToServer(new ScubaTankDataMessage(ScubaTankPacket.UPDATE, mc.thePlayer.getCommandSenderName(), isGasMaskOn(mc.thePlayer)));
|
||||
}
|
||||
|
||||
if(MekanismClient.audioHandler != null)
|
||||
if(client.enablePlayerSounds)
|
||||
{
|
||||
for(String username : Mekanism.jetpackOn)
|
||||
{
|
||||
EntityPlayer player = mc.theWorld.getPlayerEntityByName(username);
|
||||
|
||||
|
||||
if(player != null)
|
||||
{
|
||||
if(!MekanismClient.audioHandler.soundPlaying(player, JETPACK))
|
||||
if(!SoundHandler.soundPlaying(player, JETPACK))
|
||||
{
|
||||
MekanismClient.audioHandler.addSound(player, JETPACK, true);
|
||||
SoundHandler.addSound(player, JETPACK, true);
|
||||
}
|
||||
MekanismClient.audioHandler.playSound(player, JETPACK);
|
||||
SoundHandler.playSound(player, JETPACK);
|
||||
}
|
||||
}
|
||||
|
||||
for(String username : Mekanism.gasmaskOn)
|
||||
{
|
||||
EntityPlayer player = mc.theWorld.getPlayerEntityByName(username);
|
||||
|
||||
|
||||
if(player != null)
|
||||
{
|
||||
if(!MekanismClient.audioHandler.soundPlaying(player, GASMASK))
|
||||
if(!SoundHandler.soundPlaying(player, GASMASK))
|
||||
{
|
||||
MekanismClient.audioHandler.addSound(player, GASMASK, true);
|
||||
SoundHandler.addSound(player, GASMASK, true);
|
||||
}
|
||||
MekanismClient.audioHandler.playSound(player, GASMASK);
|
||||
SoundHandler.playSound(player, GASMASK);
|
||||
}
|
||||
}
|
||||
|
||||
for(EntityPlayer player : (List<EntityPlayer>)mc.theWorld.playerEntities)
|
||||
|
||||
for(EntityPlayer player : (List<EntityPlayer>) mc.theWorld.playerEntities)
|
||||
{
|
||||
if(hasFlamethrower(player))
|
||||
{
|
||||
if(!MekanismClient.audioHandler.soundPlaying(player, FLAMETHROWER))
|
||||
if(!SoundHandler.soundPlaying(player, FLAMETHROWER))
|
||||
{
|
||||
MekanismClient.audioHandler.addSound(player, FLAMETHROWER, true);
|
||||
SoundHandler.addSound(player, FLAMETHROWER, true);
|
||||
}
|
||||
MekanismClient.audioHandler.playSound(player, FLAMETHROWER);
|
||||
SoundHandler.playSound(player, FLAMETHROWER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class MekanismClient extends Mekanism
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
/** The main SoundHandler instance that is used by all audio sources */
|
||||
public static SoundHandler audioHandler;
|
||||
|
||||
public static VoiceClient voiceClient;
|
||||
|
||||
public static long ticksPassed = 0;
|
||||
|
@ -46,7 +42,6 @@ public class MekanismClient extends Mekanism
|
|||
}
|
||||
|
||||
ClientTickHandler.tickingSet.clear();
|
||||
Mekanism.proxy.unloadSoundHandler();
|
||||
|
||||
MekanismAPI.getBoxIgnore().clear();
|
||||
MinecraftForge.EVENT_BUS.post(new BoxBlacklistEvent());
|
||||
|
|
|
@ -18,20 +18,20 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
/**
|
||||
* SoundHandler - a class that handles all Sounds used by Mekanism.
|
||||
* Runs off of PaulsCode's SoundSystem.
|
||||
* @author AidanBrady
|
||||
* Runs off of PaulsCode's SoundSystem through Minecraft.
|
||||
* @author AidanBrady rewritten by unpairedbracket
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class SoundHandler
|
||||
{
|
||||
public Map<String, Map<String, IResettableSound>> soundMaps = new HashMap<String, Map<String, IResettableSound>>();
|
||||
public static Map<String, Map<String, IResettableSound>> soundMaps = new HashMap<String, Map<String, IResettableSound>>();
|
||||
|
||||
public static Map<ISound, String> invPlayingSounds;
|
||||
|
||||
public static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public enum Channel
|
||||
public static enum Channel
|
||||
{
|
||||
JETPACK("jetpack", JetpackSound.class),
|
||||
GASMASK("gasMask", GasMaskSound.class),
|
||||
|
@ -64,7 +64,7 @@ public class SoundHandler
|
|||
}
|
||||
}
|
||||
|
||||
public boolean soundPlaying(EntityPlayer player, Channel channel)
|
||||
public static boolean soundPlaying(EntityPlayer player, Channel channel)
|
||||
{
|
||||
String name = player.getCommandSenderName();
|
||||
Map<String, IResettableSound> map = getMap(name);
|
||||
|
@ -73,7 +73,7 @@ public class SoundHandler
|
|||
return !(sound == null || sound.isDonePlaying());
|
||||
}
|
||||
|
||||
public void addSound(EntityPlayer player, Channel channel, boolean replace)
|
||||
public static void addSound(EntityPlayer player, Channel channel, boolean replace)
|
||||
{
|
||||
String name = player.getCommandSenderName();
|
||||
Map<String, IResettableSound> map = getMap(name);
|
||||
|
@ -85,7 +85,7 @@ public class SoundHandler
|
|||
}
|
||||
}
|
||||
|
||||
public boolean playSound(EntityPlayer player, Channel channel)
|
||||
public static boolean playSound(EntityPlayer player, Channel channel)
|
||||
{
|
||||
String name = player.getCommandSenderName();
|
||||
Map<String, IResettableSound> map = getMap(name);
|
||||
|
@ -102,7 +102,7 @@ public class SoundHandler
|
|||
return false;
|
||||
}
|
||||
|
||||
public Map<String, IResettableSound> getMap(String name)
|
||||
public static Map<String, IResettableSound> getMap(String name)
|
||||
{
|
||||
Map<String, IResettableSound> map = soundMaps.get(name);
|
||||
if(map == null)
|
||||
|
|
|
@ -149,12 +149,6 @@ public class CommonProxy
|
|||
GameRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier");
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a client-side sound, assigned to a TileEntity;
|
||||
* @param tileEntity - TileEntity who is unregistering the sound
|
||||
*/
|
||||
public void unregisterSound(TileEntity tileEntity) {}
|
||||
|
||||
/**
|
||||
* Handles an ELECTRIC_CHEST_CLIENT_OPEN packet via the proxy, not handled on the server-side.
|
||||
* @param entityplayer - player the packet was sent from
|
||||
|
@ -286,16 +280,6 @@ public class CommonProxy
|
|||
FMLCommonHandler.instance().bus().register(Mekanism.worldTickHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up and load the sound handler.
|
||||
*/
|
||||
public void loadSoundHandler() {}
|
||||
|
||||
/**
|
||||
* Unload the sound handler.
|
||||
*/
|
||||
public void unloadSoundHandler() {}
|
||||
|
||||
/**
|
||||
* Whether or not the game is paused.
|
||||
*/
|
||||
|
|
|
@ -1128,7 +1128,6 @@ public class Mekanism
|
|||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
proxy.loadSoundHandler();
|
||||
hooks = new MekanismHooks();
|
||||
hooks.hook();
|
||||
|
||||
|
|
|
@ -5,12 +5,10 @@ import io.netty.buffer.ByteBuf;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Pos3D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IEjector;
|
||||
import mekanism.common.base.IElectricMachine;
|
||||
import mekanism.common.base.IInvConfiguration;
|
||||
|
@ -21,13 +19,11 @@ import mekanism.common.tile.component.TileComponentEjector;
|
|||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.ISound.AttenuationType;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
|
@ -188,17 +184,6 @@ public abstract class TileEntityBasicMachine extends TileEntityNoisyElectricBloc
|
|||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
Mekanism.proxy.unregisterSound(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scaled progress level for the GUI.
|
||||
* @return
|
||||
|
|
|
@ -137,17 +137,6 @@ public class TileEntityChargepad extends TileEntityNoisyElectricBlock
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
Mekanism.proxy.unregisterSound(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EnumSet<ForgeDirection> getConsumingSides()
|
||||
{
|
||||
|
|
|
@ -467,17 +467,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
Mekanism.proxy.unregisterSound(this);
|
||||
}
|
||||
}
|
||||
|
||||
public int getScaledProgress(int i, int process)
|
||||
{
|
||||
return progress[process]*i / MekanismUtils.getTicks(this, TICKS_REQUIRED);
|
||||
|
|
|
@ -321,17 +321,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
|||
return ((double)operatingTicks) / ((double)MekanismUtils.getTicks(this, TICKS_REQUIRED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
Mekanism.proxy.unregisterSound(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue