2012-11-05 20:29:04 +01:00
|
|
|
package mekanism.client;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
|
|
|
|
2012-11-05 20:29:04 +01:00
|
|
|
import mekanism.common.CommonProxy;
|
|
|
|
import mekanism.common.EntityObsidianTNT;
|
2013-01-21 02:15:59 +01:00
|
|
|
import mekanism.common.ItemPortableTeleporter;
|
2012-11-05 20:29:04 +01:00
|
|
|
import mekanism.common.Mekanism;
|
2012-11-15 21:04:12 +01:00
|
|
|
import mekanism.common.TileEntityAdvancedElectricMachine;
|
2012-11-21 16:14:35 +01:00
|
|
|
import mekanism.common.TileEntityControlPanel;
|
2012-11-15 21:04:12 +01:00
|
|
|
import mekanism.common.TileEntityElectricMachine;
|
2012-11-28 16:33:34 +01:00
|
|
|
import mekanism.common.TileEntityEnergyCube;
|
2012-12-20 22:53:39 +01:00
|
|
|
import mekanism.common.TileEntityGasTank;
|
|
|
|
import mekanism.common.TileEntityMetallurgicInfuser;
|
2013-02-22 04:03:54 +01:00
|
|
|
import mekanism.common.TileEntityPressurizedTube;
|
2013-03-20 16:14:26 +01:00
|
|
|
import mekanism.common.TileEntityFactory;
|
2013-01-21 02:15:59 +01:00
|
|
|
import mekanism.common.TileEntityTeleporter;
|
2012-11-05 20:29:04 +01:00
|
|
|
import mekanism.common.TileEntityTheoreticalElementizer;
|
2013-03-25 17:00:45 +01:00
|
|
|
import mekanism.common.TileEntityUniversalCable;
|
2012-12-20 22:53:39 +01:00
|
|
|
import net.minecraft.client.gui.GuiScreen;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-01-21 02:15:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2012-12-20 22:53:39 +01:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.world.World;
|
2012-08-15 22:41:41 +02:00
|
|
|
import net.minecraftforge.client.MinecraftForgeClient;
|
2013-02-14 19:26:13 +01:00
|
|
|
import net.minecraftforge.common.Configuration;
|
2012-12-20 22:53:39 +01:00
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
2012-12-23 20:46:11 +01:00
|
|
|
import cpw.mods.fml.client.registry.ClientRegistry;
|
2012-12-20 22:53:39 +01:00
|
|
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
|
|
|
import cpw.mods.fml.common.registry.TickRegistry;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
|
|
|
/**
|
2012-11-05 20:29:04 +01:00
|
|
|
* Client proxy for the Mekanism mod.
|
2012-08-15 22:41:41 +02:00
|
|
|
* @author AidanBrady
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class ClientProxy extends CommonProxy
|
|
|
|
{
|
2012-11-28 16:33:34 +01:00
|
|
|
public static int RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
|
2013-03-25 17:00:45 +01:00
|
|
|
public static int TRANSMITTER_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
|
2012-11-28 16:33:34 +01:00
|
|
|
|
2013-02-14 19:26:13 +01:00
|
|
|
@Override
|
|
|
|
public void loadConfiguration()
|
|
|
|
{
|
|
|
|
super.loadConfiguration();
|
|
|
|
|
|
|
|
Mekanism.configuration.load();
|
|
|
|
Mekanism.enableSounds = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableSounds", true).getBoolean(true);
|
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-31 01:27:35 +02:00
|
|
|
public int getArmorIndex(String string)
|
|
|
|
{
|
|
|
|
return RenderingRegistry.addNewArmourRendererPrefix(string);
|
|
|
|
}
|
|
|
|
|
2012-12-23 20:46:11 +01:00
|
|
|
@Override
|
|
|
|
public void registerSpecialTileEntities()
|
|
|
|
{
|
|
|
|
ClientRegistry.registerTileEntity(TileEntityTheoreticalElementizer.class, "TheoreticalElementizer", new RenderTheoreticalElementizer());
|
2013-02-22 04:03:54 +01:00
|
|
|
ClientRegistry.registerTileEntity(TileEntityPressurizedTube.class, "PressurizedTube", new RenderPressurizedTube());
|
2013-03-25 17:00:45 +01:00
|
|
|
ClientRegistry.registerTileEntity(TileEntityUniversalCable.class, "UniversalCable", new RenderUniversalCable());
|
2012-12-23 20:46:11 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public void registerRenderInformation()
|
|
|
|
{
|
|
|
|
//Register entity rendering handlers
|
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new RenderObsidianTNT());
|
2012-11-21 16:14:35 +01:00
|
|
|
|
2012-11-28 16:33:34 +01:00
|
|
|
//Register item handler
|
|
|
|
MinecraftForgeClient.registerItemRenderer(Mekanism.energyCubeID, new ItemRenderingHandler());
|
2012-12-23 20:46:11 +01:00
|
|
|
|
2013-02-22 04:03:54 +01:00
|
|
|
//Register block handlers
|
2012-12-23 20:46:11 +01:00
|
|
|
RenderingRegistry.registerBlockHandler(new BlockRenderingHandler());
|
2013-03-25 17:00:45 +01:00
|
|
|
RenderingRegistry.registerBlockHandler(new TransmitterRenderer());
|
2012-11-28 16:33:34 +01:00
|
|
|
|
|
|
|
System.out.println("[Mekanism] Render registrations complete.");
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-09-03 18:11:25 +02:00
|
|
|
public World getClientWorld()
|
|
|
|
{
|
|
|
|
return FMLClientHandler.instance().getClient().theWorld;
|
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public void loadUtilities()
|
|
|
|
{
|
2012-11-29 02:03:55 +01:00
|
|
|
if(FMLClientHandler.instance().getClient().gameSettings.snooperEnabled)
|
|
|
|
{
|
|
|
|
new ThreadSendData();
|
|
|
|
}
|
|
|
|
|
2012-11-05 20:29:04 +01:00
|
|
|
System.out.println("[Mekanism] Utility initiative complete.");
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public GuiScreen getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z)
|
|
|
|
{
|
2012-11-15 21:04:12 +01:00
|
|
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
|
|
|
|
2012-08-15 22:41:41 +02:00
|
|
|
switch(ID)
|
|
|
|
{
|
2012-09-25 21:15:47 +02:00
|
|
|
case 0:
|
2012-08-15 22:41:41 +02:00
|
|
|
return new GuiStopwatch(player);
|
2012-09-25 21:15:47 +02:00
|
|
|
case 1:
|
2012-08-15 22:41:41 +02:00
|
|
|
return new GuiCredits();
|
2012-09-25 21:15:47 +02:00
|
|
|
case 2:
|
2012-08-15 22:41:41 +02:00
|
|
|
return new GuiWeatherOrb(player);
|
2012-09-25 21:15:47 +02:00
|
|
|
case 3:
|
2013-01-23 21:42:45 +01:00
|
|
|
return new GuiEnrichmentChamber(player.inventory, (TileEntityElectricMachine)tileEntity);
|
2012-09-25 21:15:47 +02:00
|
|
|
case 4:
|
2013-02-27 02:21:30 +01:00
|
|
|
return new GuiOsmiumCompressor(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity);
|
2012-09-25 21:15:47 +02:00
|
|
|
case 5:
|
2013-01-23 21:42:45 +01:00
|
|
|
return new GuiCombiner(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity);
|
2012-09-25 21:15:47 +02:00
|
|
|
case 6:
|
2013-01-23 21:42:45 +01:00
|
|
|
return new GuiCrusher(player.inventory, (TileEntityElectricMachine)tileEntity);
|
2012-09-25 21:15:47 +02:00
|
|
|
case 7:
|
2012-11-15 21:04:12 +01:00
|
|
|
return new GuiTheoreticalElementizer(player.inventory, (TileEntityTheoreticalElementizer)tileEntity);
|
2012-10-02 20:39:40 +02:00
|
|
|
case 8:
|
2012-11-28 16:33:34 +01:00
|
|
|
return new GuiEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity);
|
2012-10-28 23:18:23 +01:00
|
|
|
case 9:
|
2012-11-21 16:14:35 +01:00
|
|
|
return new GuiControlPanel((TileEntityControlPanel)tileEntity, player, world);
|
2012-11-25 16:45:00 +01:00
|
|
|
case 10:
|
2012-11-21 16:14:35 +01:00
|
|
|
return new GuiGasTank(player.inventory, (TileEntityGasTank)tileEntity);
|
2012-12-19 21:23:55 +01:00
|
|
|
case 11:
|
2013-03-20 16:14:26 +01:00
|
|
|
return new GuiFactory(player.inventory, (TileEntityFactory)tileEntity);
|
2012-12-20 22:53:39 +01:00
|
|
|
case 12:
|
|
|
|
return new GuiMetallurgicInfuser(player.inventory, (TileEntityMetallurgicInfuser)tileEntity);
|
2013-01-21 02:15:59 +01:00
|
|
|
case 13:
|
|
|
|
return new GuiTeleporter(player.inventory, (TileEntityTeleporter)tileEntity);
|
|
|
|
case 14:
|
|
|
|
ItemStack itemStack = player.getCurrentEquippedItem();
|
|
|
|
if(itemStack != null && itemStack.getItem() instanceof ItemPortableTeleporter)
|
|
|
|
{
|
|
|
|
return new GuiPortableTeleporter(player, itemStack);
|
|
|
|
}
|
2013-01-23 21:42:45 +01:00
|
|
|
case 15:
|
|
|
|
return new GuiPurificationChamber(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity);
|
2013-03-20 21:28:45 +01:00
|
|
|
case 16:
|
|
|
|
return new GuiEnergizedSmelter(player.inventory, (TileEntityElectricMachine)tileEntity);
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public void loadTickHandler()
|
|
|
|
{
|
2013-01-21 02:15:59 +01:00
|
|
|
super.loadTickHandler();
|
|
|
|
|
2012-08-15 22:41:41 +02:00
|
|
|
TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
|
2013-03-31 00:13:59 +01:00
|
|
|
TickRegistry.registerTickHandler(new ClientPlayerTickHandler(), Side.CLIENT);
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
2012-11-05 16:52:56 +01:00
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-11-05 16:52:56 +01:00
|
|
|
public void loadSoundHandler()
|
|
|
|
{
|
2013-02-14 19:26:13 +01:00
|
|
|
if(Mekanism.enableSounds)
|
|
|
|
{
|
|
|
|
Mekanism.audioHandler = new SoundHandler();
|
|
|
|
}
|
2012-11-05 16:52:56 +01:00
|
|
|
}
|
2012-12-30 22:34:45 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void unloadSoundHandler()
|
|
|
|
{
|
2013-02-14 19:26:13 +01:00
|
|
|
if(Mekanism.audioHandler != null)
|
2012-12-30 22:34:45 +01:00
|
|
|
{
|
2013-02-14 19:26:13 +01:00
|
|
|
synchronized(Mekanism.audioHandler.sounds)
|
2012-12-30 22:34:45 +01:00
|
|
|
{
|
2013-02-14 19:26:13 +01:00
|
|
|
for(Sound sound : Mekanism.audioHandler.sounds)
|
|
|
|
{
|
|
|
|
sound.stopLoop();
|
|
|
|
Mekanism.audioHandler.soundSystem.removeSource(sound.identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
Mekanism.audioHandler.sounds.clear();
|
2012-12-30 22:34:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|