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

134 lines
6.1 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-03-07 12:51:28 +01:00
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.util.Util;
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;
2015-06-18 13:14:57 +02:00
if(id != CRAFTER_ID && id != DRILL_ID){
tile = (TileEntityBase)world.getTileEntity(x, y, z);
}
2015-05-20 22:39:43 +02:00
switch(id){
case FEEDER_ID:
return new ContainerFeeder(entityPlayer.inventory, tile);
case GIANT_CHEST_ID:
return new ContainerGiantChest(entityPlayer.inventory, tile);
case CRAFTER_ID:
return new ContainerCrafter(entityPlayer);
case GRINDER_ID:
return new ContainerGrinder(entityPlayer.inventory, tile, false);
case GRINDER_DOUBLE_ID:
return new ContainerGrinder(entityPlayer.inventory, tile, true);
case FURNACE_DOUBLE_ID:
return new ContainerFurnaceDouble(entityPlayer.inventory, tile);
2015-03-19 21:27:56 +01:00
case INPUTTER_ID:
return new ContainerInputter(entityPlayer.inventory, tile, false);
case INPUTTER_ADVANCED_ID:
return new ContainerInputter(entityPlayer.inventory, tile, true);
2015-04-02 12:06:42 +02:00
case REPAIRER_ID:
return new ContainerRepairer(entityPlayer.inventory, tile);
2015-04-19 01:50:02 +02:00
case BREAKER_ID:
return new ContainerBreaker(entityPlayer.inventory, tile);
2015-05-04 17:26:50 +02:00
case DROPPER_ID:
return new ContainerDropper(entityPlayer.inventory, tile);
2015-05-20 22:39:43 +02:00
case CANOLA_PRESS_ID:
return new ContainerCanolaPress(entityPlayer.inventory, tile);
2015-05-20 22:39:43 +02:00
case FERMENTING_BARREL_ID:
return new ContainerFermentingBarrel(entityPlayer.inventory, tile);
2015-05-20 22:39:43 +02:00
case COAL_GENERATOR_ID:
return new ContainerCoalGenerator(entityPlayer.inventory, tile);
2015-05-20 22:39:43 +02:00
case OIL_GENERATOR_ID:
return new ContainerOilGenerator(entityPlayer.inventory, tile);
2015-05-25 17:00:54 +02:00
case PHANTOM_PLACER_ID:
return new ContainerPhantomPlacer(entityPlayer.inventory, tile);
2015-05-30 17:47:57 +02:00
case FLUID_COLLECTOR_ID:
return new ContainerFluidCollector(entityPlayer.inventory, tile);
case COFFEE_MACHINE_ID:
return new ContainerCoffeeMachine(entityPlayer.inventory, tile);
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;
2015-06-18 13:14:57 +02:00
if(id != CRAFTER_ID && id != DRILL_ID){
tile = (TileEntityBase)world.getTileEntity(x, y, z);
}
2015-05-20 22:39:43 +02:00
switch(id){
case FEEDER_ID:
return new GuiFeeder(entityPlayer.inventory, tile);
case GIANT_CHEST_ID:
return new GuiGiantChest(entityPlayer.inventory, tile);
case CRAFTER_ID:
return new GuiCrafter(entityPlayer);
case GRINDER_ID:
return new GuiGrinder(entityPlayer.inventory, tile, false);
case GRINDER_DOUBLE_ID:
return new GuiGrinder(entityPlayer.inventory, tile, true);
case FURNACE_DOUBLE_ID:
return new GuiFurnaceDouble(entityPlayer.inventory, tile);
2015-03-19 21:27:56 +01:00
case INPUTTER_ID:
return new GuiInputter(entityPlayer.inventory, tile, x, y, z, world, false);
case INPUTTER_ADVANCED_ID:
return new GuiInputter(entityPlayer.inventory, tile, x, y, z, world, true);
2015-04-02 12:06:42 +02:00
case REPAIRER_ID:
return new GuiRepairer(entityPlayer.inventory, tile);
2015-04-19 01:50:02 +02:00
case BREAKER_ID:
return new GuiBreaker(entityPlayer.inventory, tile);
2015-05-04 17:26:50 +02:00
case DROPPER_ID:
return new GuiDropper(entityPlayer.inventory, tile);
2015-05-20 22:39:43 +02:00
case CANOLA_PRESS_ID:
return new GuiCanolaPress(entityPlayer.inventory, tile);
2015-05-20 22:39:43 +02:00
case FERMENTING_BARREL_ID:
return new GuiFermentingBarrel(entityPlayer.inventory, tile);
2015-05-20 22:39:43 +02:00
case COAL_GENERATOR_ID:
return new GuiCoalGenerator(entityPlayer.inventory, tile);
2015-05-20 22:39:43 +02:00
case OIL_GENERATOR_ID:
return new GuiOilGenerator(entityPlayer.inventory, tile);
2015-05-25 17:00:54 +02:00
case PHANTOM_PLACER_ID:
return new GuiPhantomPlacer(entityPlayer.inventory, tile);
2015-05-30 17:47:57 +02:00
case FLUID_COLLECTOR_ID:
return new GuiFluidCollector(entityPlayer.inventory, tile);
case COFFEE_MACHINE_ID:
return new GuiCoffeeMachine(entityPlayer.inventory, tile, x, y, z, world);
2014-12-18 19:24:06 +01:00
default:
return null;
}
}
public static final int FEEDER_ID = 0;
public static final int GIANT_CHEST_ID = 1;
public static final int CRAFTER_ID = 2;
public static final int GRINDER_ID = 3;
public static final int GRINDER_DOUBLE_ID = 4;
public static final int FURNACE_DOUBLE_ID = 5;
2015-03-19 21:27:56 +01:00
public static final int INPUTTER_ID = 6;
2015-04-02 12:06:42 +02:00
public static final int REPAIRER_ID = 7;
public static final int INPUTTER_ADVANCED_ID = 8;
2015-04-19 01:50:02 +02:00
public static final int BREAKER_ID = 9;
2015-05-04 17:26:50 +02:00
public static final int DROPPER_ID = 10;
2015-05-20 22:39:43 +02:00
public static final int CANOLA_PRESS_ID = 11;
public static final int FERMENTING_BARREL_ID = 12;
public static final int COAL_GENERATOR_ID = 13;
public static final int OIL_GENERATOR_ID = 14;
2015-05-25 17:00:54 +02:00
public static final int PHANTOM_PLACER_ID = 15;
2015-05-30 17:47:57 +02:00
public static final int FLUID_COLLECTOR_ID = 16;
public static final int COFFEE_MACHINE_ID = 17;
2015-06-15 22:06:07 +02:00
public static final int DRILL_ID = 18;
2014-12-18 19:24:06 +01:00
public static void init(){
Util.logInfo("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
}
}