Moved client-sensitive info over to MekanismClient

This commit is contained in:
Aidan C. Brady 2013-10-14 23:36:07 -04:00
parent c0651a9377
commit 1b717267f3
11 changed files with 59 additions and 76 deletions

View file

@ -20,9 +20,9 @@ public final class ItemRetriever
*
* Mekanism identifiers follow an easy-to-remember pattern. All identifiers
* are identical to the String returned by 'getItemName().' None include spaces,
* and always make sure you start with a capital letter. The name that shows up
* in-game can be stripped down to identifier form by removing spaces and all non-
* alphabetic characters (,./'=-_). Below is an example:
* and all start with a capital letter. The name that shows up in-game can be
* stripped down to identifier form by removing spaces and all non-alphabetic
* characters (,./'=-_). Below is an example:
*
* ItemStack enrichedAlloy = ItemRetriever.getItem("EnrichedAlloy");
*

View file

@ -45,7 +45,7 @@ public class ClientPlayerTickHandler implements ITickHandler
{
ItemConfigurator item = (ItemConfigurator)entityPlayer.getCurrentEquippedItem().getItem();
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitchDown)
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitch.isPressed())
{
if(!lastTickUpdate)
{
@ -63,7 +63,7 @@ public class ClientPlayerTickHandler implements ITickHandler
{
ItemElectricBow item = (ItemElectricBow)entityPlayer.getCurrentEquippedItem().getItem();
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitchDown)
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitch.isPressed())
{
if(!lastTickUpdate)
{
@ -81,7 +81,7 @@ public class ClientPlayerTickHandler implements ITickHandler
{
ItemWalkieTalkie item = (ItemWalkieTalkie)entityPlayer.getCurrentEquippedItem().getItem();
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitchDown && item.getOn(stack))
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitch.isPressed() && item.getOn(stack))
{
if(!lastTickUpdate)
{

View file

@ -123,8 +123,8 @@ public class ClientProxy extends CommonProxy
super.loadConfiguration();
Mekanism.configuration.load();
Mekanism.enableSounds = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableSounds", true).getBoolean(true);
Mekanism.fancyUniversalCableRender = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "FancyUniversalCableRender", true).getBoolean(true);
MekanismClient.enableSounds = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableSounds", true).getBoolean(true);
MekanismClient.fancyUniversalCableRender = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "FancyUniversalCableRender", true).getBoolean(true);
Mekanism.configuration.save();
}
@ -137,11 +137,11 @@ public class ClientProxy extends CommonProxy
@Override
public void registerSound(TileEntity tileEntity)
{
if(Mekanism.enableSounds && Minecraft.getMinecraft().sndManager.sndSystem != null)
if(MekanismClient.enableSounds && Minecraft.getMinecraft().sndManager.sndSystem != null)
{
synchronized(Mekanism.audioHandler.sounds)
synchronized(MekanismClient.audioHandler.sounds)
{
Mekanism.audioHandler.register(tileEntity);
MekanismClient.audioHandler.register(tileEntity);
}
}
}
@ -149,13 +149,13 @@ public class ClientProxy extends CommonProxy
@Override
public void unregisterSound(TileEntity tileEntity)
{
if(Mekanism.enableSounds && Minecraft.getMinecraft().sndManager.sndSystem != null)
if(MekanismClient.enableSounds && Minecraft.getMinecraft().sndManager.sndSystem != null)
{
synchronized(Mekanism.audioHandler.sounds)
synchronized(MekanismClient.audioHandler.sounds)
{
if(Mekanism.audioHandler.getFrom(tileEntity) != null)
if(MekanismClient.audioHandler.getFrom(tileEntity) != null)
{
Mekanism.audioHandler.getFrom(tileEntity).remove();
MekanismClient.audioHandler.getFrom(tileEntity).remove();
}
}
}
@ -376,23 +376,23 @@ public class ClientProxy extends CommonProxy
@Override
public void loadSoundHandler()
{
if(Mekanism.enableSounds)
if(MekanismClient.enableSounds)
{
Mekanism.audioHandler = new SoundHandler();
MekanismClient.audioHandler = new SoundHandler();
}
}
@Override
public void unloadSoundHandler()
{
if(Mekanism.enableSounds)
if(MekanismClient.enableSounds)
{
if(Mekanism.audioHandler != null)
if(MekanismClient.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
synchronized(MekanismClient.audioHandler.sounds)
{
HashMap<TileEntity, Sound> sounds = new HashMap<TileEntity, Sound>();
sounds.putAll(Mekanism.audioHandler.sounds);
sounds.putAll(MekanismClient.audioHandler.sounds);
for(Sound sound : sounds.values())
{

View file

@ -1,6 +1,5 @@
package mekanism.client;
import java.lang.reflect.Method;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
@ -11,11 +10,7 @@ import mekanism.common.ObfuscatedNames;
import mekanism.common.util.MekanismUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureObject;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.ITickHandler;
@ -134,11 +129,11 @@ public class ClientTickHandler implements ITickHandler
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
if(Mekanism.audioHandler != null)
if(MekanismClient.audioHandler != null)
{
synchronized(Mekanism.audioHandler.sounds)
synchronized(MekanismClient.audioHandler.sounds)
{
Mekanism.audioHandler.onTick();
MekanismClient.audioHandler.onTick();
}
}
}

View file

@ -0,0 +1,17 @@
package mekanism.client;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism;
public class MekanismClient extends Mekanism
{
@SideOnly(Side.CLIENT)
/** The main SoundHandler instance that is used by all audio sources */
public static SoundHandler audioHandler;
//General Configuration
public static boolean enableSounds = true;
public static boolean fancyUniversalCableRender = true;
}

View file

@ -17,9 +17,6 @@ public class MekanismKeyHandler extends KeyHandler
public static KeyBinding modeSwitch = new KeyBinding("Mekanism Mode Switch", Keyboard.KEY_M);
public static KeyBinding voice = new KeyBinding("Mekanism Voice", Keyboard.KEY_U);
public static boolean modeSwitchDown = false;
public static boolean voiceDown = false;
public MekanismKeyHandler()
{
super(new KeyBinding[] {modeSwitch, voice}, new boolean[] {false, false});
@ -32,30 +29,10 @@ public class MekanismKeyHandler extends KeyHandler
}
@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat)
{
if(kb.keyCode == modeSwitch.keyCode)
{
modeSwitchDown = true;
}
else if(kb.keyCode == voice.keyCode)
{
voiceDown = true;
}
}
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {}
@Override
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd)
{
if(kb.keyCode == modeSwitch.keyCode)
{
modeSwitchDown = false;
}
else if(kb.keyCode == voice.keyCode)
{
voiceDown = false;
}
}
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {}
@Override
public EnumSet<TickType> ticks()

View file

@ -4,14 +4,14 @@ import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.Object3D;
import mekanism.common.Mekanism;
import mekanism.common.tileentity.TileEntityDynamicTank;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ThreadTankSparkle extends Thread
@ -33,7 +33,7 @@ public class ThreadTankSparkle extends Thread
try {
if(Mekanism.dynamicTankEasterEgg)
{
Mekanism.audioHandler.quickPlay("cj/CJ_" + (random.nextInt(3)+1) + ".ogg", pointer.worldObj, Object3D.get(pointer));
MekanismClient.audioHandler.quickPlay("cj/CJ_" + (random.nextInt(3)+1) + ".ogg", pointer.worldObj, Object3D.get(pointer));
}
loop(pointer);

View file

@ -3,12 +3,12 @@ package mekanism.client.render.tileentity;
import java.util.HashMap;
import java.util.Map;
import mekanism.client.MekanismClient;
import mekanism.client.model.ModelTransmitter;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.BooleanArray;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.Mekanism;
import mekanism.common.tileentity.TileEntityUniversalCable;
import mekanism.common.util.CableUtils;
import mekanism.common.util.MekanismUtils;
@ -65,7 +65,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
if(tileEntity.getEnergyScale() <= 0 || !Mekanism.fancyUniversalCableRender)
if(tileEntity.getEnergyScale() <= 0 || !MekanismClient.fancyUniversalCableRender)
{
return;
}

View file

@ -2,7 +2,7 @@ package mekanism.client.sound;
import java.net.URL;
import mekanism.common.Mekanism;
import mekanism.client.MekanismClient;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
@ -40,7 +40,7 @@ public class Sound
*/
public Sound(String id, String sound, TileEntity tileentity)
{
synchronized(Mekanism.audioHandler.sounds)
synchronized(MekanismClient.audioHandler.sounds)
{
soundPath = sound;
identifier = id;
@ -60,7 +60,7 @@ public class Sound
SoundHandler.getSoundSystem().activate(id);
}
Mekanism.audioHandler.sounds.put(tileEntity, this);
MekanismClient.audioHandler.sounds.put(tileEntity, this);
}
}
@ -69,7 +69,7 @@ public class Sound
*/
public void play()
{
synchronized(Mekanism.audioHandler.sounds)
synchronized(MekanismClient.audioHandler.sounds)
{
if(isPlaying)
{
@ -91,7 +91,7 @@ public class Sound
*/
public void stopLoop()
{
synchronized(Mekanism.audioHandler.sounds)
synchronized(MekanismClient.audioHandler.sounds)
{
if(!isPlaying)
{
@ -113,14 +113,14 @@ public class Sound
*/
public void remove()
{
synchronized(Mekanism.audioHandler.sounds)
synchronized(MekanismClient.audioHandler.sounds)
{
if(isPlaying)
{
stopLoop();
}
Mekanism.audioHandler.sounds.remove(tileEntity);
MekanismClient.audioHandler.sounds.remove(tileEntity);
if(SoundHandler.getSoundSystem() != null)
{
@ -136,13 +136,13 @@ public class Sound
*/
public void updateVolume(EntityPlayer entityplayer)
{
synchronized(Mekanism.audioHandler.sounds)
synchronized(MekanismClient.audioHandler.sounds)
{
if(entityplayer != null && tileEntity != null && entityplayer.worldObj == tileEntity.worldObj)
{
float multiplier = ((IHasSound)tileEntity).getVolumeMultiplier();
float volume = 0;
float masterVolume = Mekanism.audioHandler.masterVolume;
float masterVolume = MekanismClient.audioHandler.masterVolume;
double distance = entityplayer.getDistance(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
volume = (float)Math.min(Math.max(masterVolume-((distance*.08F)*masterVolume), 0)*multiplier, 1);

View file

@ -40,11 +40,11 @@ public class VoiceInput extends Thread
while(voiceClient.running)
{
if(MekanismKeyHandler.voiceDown)
if(MekanismKeyHandler.voice.isPressed())
{
targetLine.flush();
while(voiceClient.running && MekanismKeyHandler.voiceDown)
while(voiceClient.running && MekanismKeyHandler.voice.isPressed())
{
int availableBytes = audioInput.available();
byte[] audioData = new byte[availableBytes > 2200 ? 2200 : availableBytes];

View file

@ -164,10 +164,6 @@ public class Mekanism
/** The recent news which is received from the Mekanism server */
public static String recentNews;
@SideOnly(Side.CLIENT)
/** The main SoundHandler instance that is used by all audio sources */
public static SoundHandler audioHandler;
/** The VoiceServer manager for walkie talkies */
public static VoiceServerManager voiceManager;
@ -229,8 +225,6 @@ public class Mekanism
public static boolean disableBCBronzeCrafting = true;
public static boolean disableBCSteelCrafting = true;
public static boolean updateNotifications = true;
public static boolean enableSounds = true;
public static boolean fancyUniversalCableRender = true;
public static boolean controlCircuitOreDict = true;
public static boolean logPackets = false;
public static boolean dynamicTankEasterEgg = false;