ActuallyAdditions/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java

169 lines
7 KiB
Java
Raw Normal View History

2015-03-07 12:51:28 +01:00
package ellpeck.actuallyadditions.inventory;
2014-12-18 19:24:06 +01:00
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
2015-03-07 12:51:28 +01:00
import ellpeck.actuallyadditions.ActuallyAdditions;
import ellpeck.actuallyadditions.inventory.gui.*;
2015-08-28 21:17:09 +02:00
import ellpeck.actuallyadditions.inventory.gui.lexicon.GuiBooklet;
2015-03-07 12:51:28 +01:00
import ellpeck.actuallyadditions.tile.TileEntityBase;
2015-07-01 21:32:48 +02:00
import ellpeck.actuallyadditions.util.ModUtil;
2014-12-18 19:24:06 +01:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public class GuiHandler implements IGuiHandler{
2014-12-18 19:24:06 +01:00
@Override
public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
TileEntityBase tile = null;
if(id != GuiTypes.CRAFTER.ordinal() && id != GuiTypes.DRILL.ordinal()){
tile = (TileEntityBase)world.getTileEntity(x, y, z);
}
switch(GuiTypes.values()[id]){
case FEEDER:
return new ContainerFeeder(entityPlayer.inventory, tile);
case GIANT_CHEST:
return new ContainerGiantChest(entityPlayer.inventory, tile);
case CRAFTER:
return new ContainerCrafter(entityPlayer);
case GRINDER:
return new ContainerGrinder(entityPlayer.inventory, tile, false);
case GRINDER_DOUBLE:
return new ContainerGrinder(entityPlayer.inventory, tile, true);
case FURNACE_DOUBLE:
return new ContainerFurnaceDouble(entityPlayer.inventory, tile);
case INPUTTER:
return new ContainerInputter(entityPlayer.inventory, tile, false);
case INPUTTER_ADVANCED:
return new ContainerInputter(entityPlayer.inventory, tile, true);
case REPAIRER:
return new ContainerRepairer(entityPlayer.inventory, tile);
case BREAKER:
return new ContainerBreaker(entityPlayer.inventory, tile);
case DROPPER:
return new ContainerDropper(entityPlayer.inventory, tile);
case CANOLA_PRESS:
return new ContainerCanolaPress(entityPlayer.inventory, tile);
case FERMENTING_BARREL:
return new ContainerFermentingBarrel(entityPlayer.inventory, tile);
case COAL_GENERATOR:
return new ContainerCoalGenerator(entityPlayer.inventory, tile);
case OIL_GENERATOR:
return new ContainerOilGenerator(entityPlayer.inventory, tile);
case PHANTOM_PLACER:
return new ContainerPhantomPlacer(entityPlayer.inventory, tile);
case FLUID_COLLECTOR:
return new ContainerFluidCollector(entityPlayer.inventory, tile);
case COFFEE_MACHINE:
return new ContainerCoffeeMachine(entityPlayer.inventory, tile);
case DRILL:
2015-06-21 02:28:49 +02:00
return new ContainerDrill(entityPlayer.inventory);
case ENERGIZER:
return new ContainerEnergizer(entityPlayer, tile);
case ENERVATOR:
return new ContainerEnervator(entityPlayer, tile);
case XP_SOLIDIFIER:
2015-07-13 23:44:33 +02:00
return new ContainerXPSolidifier(entityPlayer.inventory, tile);
case ORE_MAGNET:
return new ContainerOreMagnet(entityPlayer.inventory, tile);
case CLOUD:
return new ContainerSmileyCloud();
2014-12-18 19:24:06 +01:00
default:
return null;
}
}
@Override
public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
TileEntityBase tile = null;
if(id != GuiTypes.CRAFTER.ordinal() && id != GuiTypes.DRILL.ordinal()){
tile = (TileEntityBase)world.getTileEntity(x, y, z);
}
switch(GuiTypes.values()[id]){
case FEEDER:
return new GuiFeeder(entityPlayer.inventory, tile);
case GIANT_CHEST:
return new GuiGiantChest(entityPlayer.inventory, tile);
case CRAFTER:
return new GuiCrafter(entityPlayer);
case GRINDER:
return new GuiGrinder(entityPlayer.inventory, tile);
case GRINDER_DOUBLE:
return new GuiGrinder.GuiGrinderDouble(entityPlayer.inventory, tile);
case FURNACE_DOUBLE:
return new GuiFurnaceDouble(entityPlayer.inventory, tile);
case INPUTTER:
return new GuiInputter(entityPlayer.inventory, tile, x, y, z, world, false);
case INPUTTER_ADVANCED:
return new GuiInputter(entityPlayer.inventory, tile, x, y, z, world, true);
case REPAIRER:
return new GuiRepairer(entityPlayer.inventory, tile);
case BREAKER:
return new GuiBreaker(entityPlayer.inventory, tile);
case DROPPER:
return new GuiDropper(entityPlayer.inventory, tile);
case CANOLA_PRESS:
return new GuiCanolaPress(entityPlayer.inventory, tile);
case FERMENTING_BARREL:
return new GuiFermentingBarrel(entityPlayer.inventory, tile);
case COAL_GENERATOR:
return new GuiCoalGenerator(entityPlayer.inventory, tile);
case OIL_GENERATOR:
return new GuiOilGenerator(entityPlayer.inventory, tile);
case PHANTOM_PLACER:
return new GuiPhantomPlacer(entityPlayer.inventory, tile);
case FLUID_COLLECTOR:
return new GuiFluidCollector(entityPlayer.inventory, tile);
case COFFEE_MACHINE:
return new GuiCoffeeMachine(entityPlayer.inventory, tile, x, y, z, world);
case DRILL:
2015-06-21 02:28:49 +02:00
return new GuiDrill(entityPlayer.inventory);
case ENERGIZER:
return new GuiEnergizer(entityPlayer, tile);
case ENERVATOR:
return new GuiEnervator(entityPlayer, tile);
case XP_SOLIDIFIER:
2015-07-13 23:44:33 +02:00
return new GuiXPSolidifier(entityPlayer.inventory, tile, x, y, z, world);
case ORE_MAGNET:
return new GuiOreMagnet(entityPlayer.inventory, tile);
case CLOUD:
return new GuiSmileyCloud(tile, x, y, z, world);
2015-08-28 21:17:09 +02:00
case BOOK:
return new GuiBooklet();
2014-12-18 19:24:06 +01:00
default:
return null;
}
}
public enum GuiTypes{
FEEDER,
GIANT_CHEST,
CRAFTER,
GRINDER,
GRINDER_DOUBLE,
FURNACE_DOUBLE,
INPUTTER,
REPAIRER,
INPUTTER_ADVANCED,
BREAKER,
DROPPER,
CANOLA_PRESS,
FERMENTING_BARREL,
COAL_GENERATOR,
OIL_GENERATOR,
PHANTOM_PLACER,
FLUID_COLLECTOR,
COFFEE_MACHINE,
DRILL,
ENERGIZER,
ENERVATOR,
XP_SOLIDIFIER,
ORE_MAGNET,
2015-08-28 21:17:09 +02:00
CLOUD,
BOOK
}
2014-12-18 19:24:06 +01:00
public static void init(){
2015-07-01 21:32:48 +02:00
ModUtil.LOGGER.info("Initializing GuiHandler...");
2015-03-07 12:51:28 +01:00
NetworkRegistry.INSTANCE.registerGuiHandler(ActuallyAdditions.instance, new GuiHandler());
2014-12-18 19:24:06 +01:00
}
}