TechReborn/src/main/java/techreborn/client/GuiHandler.java

259 lines
14 KiB
Java
Raw Normal View History

2015-04-10 00:17:30 +02:00
package techreborn.client;
import net.minecraft.entity.player.EntityPlayer;
2016-03-13 17:08:30 +01:00
import net.minecraft.util.math.BlockPos;
2015-04-10 00:17:30 +02:00
import net.minecraft.world.World;
2015-11-23 20:19:18 +01:00
import net.minecraftforge.fml.common.network.IGuiHandler;
2016-04-12 09:33:38 +02:00
import reborncore.api.tile.IContainerLayout;
import reborncore.common.container.RebornContainer;
2016-03-27 21:10:49 +02:00
import techreborn.client.container.*;
import techreborn.client.gui.*;
2016-02-25 19:25:52 +01:00
import techreborn.manual.GuiManual;
2016-03-27 21:10:49 +02:00
import techreborn.tiles.*;
import techreborn.tiles.fusionReactor.TileEntityFusionController;
2016-03-27 21:10:49 +02:00
import techreborn.tiles.generator.*;
import techreborn.tiles.idsu.TileIDSU;
2015-06-14 17:42:03 +02:00
import techreborn.tiles.lesu.TileLesu;
import techreborn.tiles.multiblock.*;
2016-03-21 16:30:32 +01:00
import techreborn.tiles.storage.TileBatBox;
import techreborn.tiles.storage.TileMFE;
2016-03-27 21:10:49 +02:00
import techreborn.tiles.storage.TileMFSU;
import techreborn.tiles.teir1.*;
2015-04-10 00:17:30 +02:00
2016-10-08 21:46:16 +02:00
public class GuiHandler implements IGuiHandler {
2015-04-10 00:17:30 +02:00
2016-03-25 10:47:34 +01:00
public static final int thermalGeneratorID = 0;
public static final int quantumTankID = 1;
public static final int quantumChestID = 2;
public static final int centrifugeID = 3;
public static final int rollingMachineID = 4;
public static final int blastFurnaceID = 5;
public static final int alloySmelterID = 6;
public static final int industrialGrinderID = 7;
public static final int implosionCompresserID = 8;
public static final int matterfabID = 9;
public static final int manuelID = 10;
public static final int chunkloaderID = 11;
public static final int assemblingmachineID = 12;
public static final int dieselGeneratorID = 15;
public static final int industrialElectrolyzerID = 16;
public static final int aesuID = 17;
public static final int alloyFurnaceID = 18;
public static final int sawMillID = 19;
public static final int chemicalReactorID = 20;
public static final int semifluidGeneratorID = 21;
public static final int gasTurbineID = 22;
public static final int digitalChestID = 23;
public static final int destructoPackID = 25;
public static final int lesuID = 26;
public static final int idsuID = 27;
public static final int chargeBench = 28;
public static final int fusionID = 29;
public static final int vacuumFreezerID = 30;
public static final int grinderID = 31;
public static final int generatorID = 32;
public static final int extractorID = 33;
public static final int compressorID = 34;
public static final int electricFurnaceID = 35;
public static final int ironFurnace = 36;
public static final int recyclerID = 37;
public static final int scrapboxinatorID = 38;
public static final int batboxID = 39;
2016-03-27 21:10:49 +02:00
public static final int mfsuID = 40;
public static final int mfeID = 41;
2016-10-08 21:46:16 +02:00
2016-03-25 10:47:34 +01:00
@Override
2016-10-08 21:46:16 +02:00
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
2016-04-12 09:33:38 +02:00
RebornContainer container = null;
2016-10-08 21:46:16 +02:00
if (ID == thermalGeneratorID) {
2016-03-25 10:47:34 +01:00
return new ContainerThermalGenerator((TileThermalGenerator) world.getTileEntity(new BlockPos(x, y, z)),
2016-10-08 21:46:16 +02:00
player);
} else if (ID == semifluidGeneratorID) {
2016-03-25 10:47:34 +01:00
return new ContainerSemifluidGenerator((TileSemifluidGenerator) world.getTileEntity(new BlockPos(x, y, z)),
2016-10-08 21:46:16 +02:00
player);
} else if (ID == gasTurbineID) {
2016-03-25 10:47:34 +01:00
return new ContainerGasTurbine((TileGasTurbine) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == quantumTankID) {
2016-03-25 10:47:34 +01:00
return new ContainerQuantumTank((TileQuantumTank) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == digitalChestID) {
2016-03-25 10:47:34 +01:00
return new ContainerDigitalChest((TileDigitalChest) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == quantumChestID) {
2016-03-25 10:47:34 +01:00
return new ContainerQuantumChest((TileQuantumChest) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == centrifugeID) {
container = new ContainerCentrifuge();
2016-10-08 21:46:16 +02:00
} else if (ID == rollingMachineID) {
2016-03-25 10:47:34 +01:00
return new ContainerRollingMachine((TileRollingMachine) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == blastFurnaceID) {
2016-03-25 10:47:34 +01:00
return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == alloySmelterID) {
2016-04-12 09:39:50 +02:00
container = new ContainerAlloySmelter();
2016-10-08 21:46:16 +02:00
} else if (ID == industrialGrinderID) {
2016-03-25 10:47:34 +01:00
return new ContainerIndustrialGrinder((TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)),
2016-10-08 21:46:16 +02:00
player);
} else if (ID == implosionCompresserID) {
2016-03-25 10:47:34 +01:00
return new ContainerImplosionCompressor(
2016-10-08 21:46:16 +02:00
(TileImplosionCompressor) world.getTileEntity(new BlockPos(x, y, z)), player);
} else if (ID == matterfabID) {
2016-03-25 10:47:34 +01:00
return new ContainerMatterFabricator((TileMatterFabricator) world.getTileEntity(new BlockPos(x, y, z)),
2016-10-08 21:46:16 +02:00
player);
} else if (ID == chunkloaderID) {
2016-03-25 10:47:34 +01:00
return new ContainerChunkloader((TileChunkLoader) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == assemblingmachineID) {
container = new ContainerAssemblingMachine();
2016-10-08 21:46:16 +02:00
} else if (ID == dieselGeneratorID) {
2016-03-25 10:47:34 +01:00
return new ContainerDieselGenerator((TileDieselGenerator) world.getTileEntity(new BlockPos(x, y, z)),
2016-10-08 21:46:16 +02:00
player);
} else if (ID == industrialElectrolyzerID) {
2016-03-25 10:47:34 +01:00
return new ContainerIndustrialElectrolyzer(
2016-10-08 21:46:16 +02:00
(TileIndustrialElectrolyzer) world.getTileEntity(new BlockPos(x, y, z)), player);
} else if (ID == aesuID) {
2016-03-29 04:47:00 +02:00
return new ContainerAESU((TileAesu) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == alloyFurnaceID) {
2016-03-25 10:47:34 +01:00
return new ContainerAlloyFurnace((TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == sawMillID) {
2016-03-25 10:47:34 +01:00
return new ContainerIndustrialSawmill((TileIndustrialSawmill) world.getTileEntity(new BlockPos(x, y, z)),
2016-10-08 21:46:16 +02:00
player);
} else if (ID == chemicalReactorID) {
2016-03-25 10:47:34 +01:00
return new ContainerChemicalReactor((TileChemicalReactor) world.getTileEntity(new BlockPos(x, y, z)),
2016-10-08 21:46:16 +02:00
player);
} else if (ID == manuelID) {
2016-03-25 10:47:34 +01:00
return null;
2016-10-08 21:46:16 +02:00
} else if (ID == destructoPackID) {
2016-03-25 10:47:34 +01:00
return new ContainerDestructoPack(player);
2016-10-08 21:46:16 +02:00
} else if (ID == lesuID) {
2016-03-29 04:47:00 +02:00
return new ContainerLESU((TileLesu) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == idsuID) {
2016-03-25 10:47:34 +01:00
return new ContainerIDSU((TileIDSU) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == chargeBench) {
2016-03-25 10:47:34 +01:00
return new ContainerChargeBench((TileChargeBench) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == fusionID) {
2016-03-25 10:47:34 +01:00
return new ContainerFusionReactor((TileEntityFusionController) world.getTileEntity(new BlockPos(x, y, z)),
2016-10-08 21:46:16 +02:00
player);
} else if (ID == vacuumFreezerID) {
2016-03-25 10:47:34 +01:00
return new ContainerVacuumFreezer((TileVacuumFreezer) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == grinderID) {
2016-11-05 11:39:13 +01:00
container = new ContainerGrinder(player, (TileGrinder) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == generatorID) {
2016-03-25 10:47:34 +01:00
return new ContainerGenerator((TileGenerator) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == extractorID) {
2016-11-05 11:39:13 +01:00
container = new ContainerExtractor(player, (TileExtractor) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == compressorID) {
2016-03-25 10:47:34 +01:00
return new ContainerCompressor((TileCompressor) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == electricFurnaceID) {
2016-03-25 10:47:34 +01:00
return new ContainerElectricFurnace((TileElectricFurnace) world.getTileEntity(new BlockPos(x, y, z)),
2016-10-08 21:46:16 +02:00
player);
} else if (ID == ironFurnace) {
2016-03-25 10:47:34 +01:00
return new ContainerIronFurnace((TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == recyclerID) {
2016-03-25 10:47:34 +01:00
return new ContainerRecycler((TileRecycler) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == scrapboxinatorID) {
2016-03-25 10:47:34 +01:00
return new ContainerScrapboxinator((TileScrapboxinator) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == batboxID) {
2016-03-25 10:47:34 +01:00
return new ContainerBatbox((TileBatBox) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == mfsuID) {
2016-03-27 21:10:49 +02:00
return new ContainerMFSU((TileMFSU) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-10-08 21:46:16 +02:00
} else if (ID == mfeID) {
return new ContainerMFE((TileMFE) world.getTileEntity(new BlockPos(x, y, z)), player);
2016-03-25 10:47:34 +01:00
}
2016-10-08 21:46:16 +02:00
if (container != null) {
if (container instanceof IContainerLayout) {
2016-04-12 09:33:38 +02:00
IContainerLayout layout = (IContainerLayout) container;
layout.setTile(world.getTileEntity(new BlockPos(x, y, z)));
layout.setPlayer(player);
layout.addInventorySlots();
layout.addPlayerSlots();
}
return container;
}
2016-03-25 10:47:34 +01:00
return null;
}
2016-03-25 10:47:34 +01:00
@Override
2016-10-08 21:46:16 +02:00
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == thermalGeneratorID) {
2016-03-25 10:47:34 +01:00
return new GuiThermalGenerator(player, (TileThermalGenerator) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == semifluidGeneratorID) {
2016-03-25 10:47:34 +01:00
return new GuiSemifluidGenerator(player,
2016-10-08 21:46:16 +02:00
(TileSemifluidGenerator) world.getTileEntity(new BlockPos(x, y, z)));
} else if (ID == gasTurbineID) {
2016-03-25 10:47:34 +01:00
return new GuiGasTurbine(player, (TileGasTurbine) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == quantumTankID) {
2016-03-25 10:47:34 +01:00
return new GuiQuantumTank(player, (TileQuantumTank) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == digitalChestID) {
2016-03-25 10:47:34 +01:00
return new GuiDigitalChest(player, (TileDigitalChest) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == quantumChestID) {
2016-03-25 10:47:34 +01:00
return new GuiQuantumChest(player, (TileQuantumChest) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == centrifugeID) {
2016-03-25 10:47:34 +01:00
return new GuiCentrifuge(player, (TileCentrifuge) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == rollingMachineID) {
2016-03-25 10:47:34 +01:00
return new GuiRollingMachine(player, (TileRollingMachine) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == blastFurnaceID) {
2016-03-25 10:47:34 +01:00
return new GuiBlastFurnace(player, (TileBlastFurnace) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == alloySmelterID) {
2016-03-25 10:47:34 +01:00
return new GuiAlloySmelter(player, (TileAlloySmelter) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == industrialGrinderID) {
2016-03-25 10:47:34 +01:00
return new GuiIndustrialGrinder(player, (TileIndustrialGrinder) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == implosionCompresserID) {
2016-03-25 10:47:34 +01:00
return new GuiImplosionCompressor(player,
2016-10-08 21:46:16 +02:00
(TileImplosionCompressor) world.getTileEntity(new BlockPos(x, y, z)));
} else if (ID == matterfabID) {
2016-03-25 10:47:34 +01:00
return new GuiMatterFabricator(player, (TileMatterFabricator) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == chunkloaderID) {
2016-03-25 10:47:34 +01:00
return new GuiChunkLoader(player, (TileChunkLoader) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == assemblingmachineID) {
2016-03-25 10:47:34 +01:00
return new GuiAssemblingMachine(player, (TileAssemblingMachine) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == dieselGeneratorID) {
2016-03-25 10:47:34 +01:00
return new GuiDieselGenerator(player, (TileDieselGenerator) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == industrialElectrolyzerID) {
2016-03-25 10:47:34 +01:00
return new GuiIndustrialElectrolyzer(player,
2016-10-08 21:46:16 +02:00
(TileIndustrialElectrolyzer) world.getTileEntity(new BlockPos(x, y, z)));
} else if (ID == aesuID) {
2016-03-29 04:47:00 +02:00
return new GuiAESU(player, (TileAesu) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == alloyFurnaceID) {
2016-03-25 10:47:34 +01:00
return new GuiAlloyFurnace(player, (TileAlloyFurnace) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == sawMillID) {
2016-03-25 10:47:34 +01:00
return new GuiIndustrialSawmill(player, (TileIndustrialSawmill) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == chemicalReactorID) {
2016-03-25 10:47:34 +01:00
return new GuiChemicalReactor(player, (TileChemicalReactor) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == manuelID) {
2016-03-25 10:47:34 +01:00
return new GuiManual();
2016-10-08 21:46:16 +02:00
} else if (ID == destructoPackID) {
2016-03-25 10:47:34 +01:00
return new GuiDestructoPack(new ContainerDestructoPack(player));
2016-10-08 21:46:16 +02:00
} else if (ID == lesuID) {
2016-03-29 04:47:00 +02:00
return new GuiLESU(player, (TileLesu) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == idsuID) {
2016-03-25 10:47:34 +01:00
return new GuiIDSU(player, (TileIDSU) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == chargeBench) {
2016-03-25 10:47:34 +01:00
return new GuiChargeBench(player, (TileChargeBench) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == fusionID) {
2016-03-25 10:47:34 +01:00
return new GuiFusionReactor(player,
2016-10-08 21:46:16 +02:00
(TileEntityFusionController) world.getTileEntity(new BlockPos(x, y, z)));
} else if (ID == vacuumFreezerID) {
2016-03-25 10:47:34 +01:00
return new GuiVacuumFreezer(player, (TileVacuumFreezer) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == grinderID) {
2016-03-25 10:47:34 +01:00
return new GuiGrinder(player, (TileGrinder) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == generatorID) {
2016-03-25 10:47:34 +01:00
return new GuiGenerator(player, (TileGenerator) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == extractorID) {
2016-03-25 10:47:34 +01:00
return new GuiExtractor(player, (TileExtractor) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == compressorID) {
2016-03-25 10:47:34 +01:00
return new GuiCompressor(player, (TileCompressor) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == electricFurnaceID) {
2016-03-25 10:47:34 +01:00
return new GuiElectricFurnace(player, (TileElectricFurnace) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == ironFurnace) {
2016-03-25 10:47:34 +01:00
return new GuiIronFurnace(player, (TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == recyclerID) {
2016-03-25 10:47:34 +01:00
return new GuiRecycler(player, (TileRecycler) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == scrapboxinatorID) {
2016-03-25 10:47:34 +01:00
return new GuiScrapboxinator(player, (TileScrapboxinator) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == batboxID) {
2016-03-25 10:47:34 +01:00
return new GuiBatbox(player, (TileBatBox) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == mfsuID) {
2016-03-27 21:10:49 +02:00
return new GuiMFSU(player, (TileMFSU) world.getTileEntity(new BlockPos(x, y, z)));
2016-10-08 21:46:16 +02:00
} else if (ID == mfeID) {
return new GuiMFE(player, (TileMFE) world.getTileEntity(new BlockPos(x, y, z)));
}
2016-03-25 10:47:34 +01:00
return null;
}
2015-04-10 00:17:30 +02:00
}