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

198 lines
8 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
* This file ("GuiHandler.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2015-11-02 20:55:19 +01:00
* © 2015 Ellpeck
2015-08-29 14:33:25 +02:00
*/
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;
2015-08-29 23:01:13 +02:00
import ellpeck.actuallyadditions.booklet.GuiBooklet;
2015-11-24 19:59:33 +01:00
import ellpeck.actuallyadditions.booklet.GuiBookletStand;
import ellpeck.actuallyadditions.inventory.gui.*;
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
2015-10-03 10:16:18 +02:00
public static void init(){
ModUtil.LOGGER.info("Initializing GuiHandler...");
NetworkRegistry.INSTANCE.registerGuiHandler(ActuallyAdditions.instance, new GuiHandler());
}
@Override
public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
TileEntityBase tile = null;
if(GuiTypes.values()[id].checkTileEntity){
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 CLOUD:
return new ContainerSmileyCloud();
2015-10-05 16:53:28 +02:00
case DIRECTIONAL_BREAKER:
return new ContainerDirectionalBreaker(entityPlayer.inventory, tile);
2015-10-10 02:51:06 +02:00
case RANGED_COLLECTOR:
return new ContainerRangedCollector(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;
if(GuiTypes.values()[id].checkTileEntity){
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 CLOUD:
return new GuiSmileyCloud(tile, x, y, z, world);
2015-08-28 21:17:09 +02:00
case BOOK:
2015-11-24 17:50:27 +01:00
return new GuiBooklet(null, true, true);
2015-11-24 19:59:33 +01:00
case BOOK_STAND:
return new GuiBookletStand(tile);
2015-10-05 16:53:28 +02:00
case DIRECTIONAL_BREAKER:
return new GuiDirectionalBreaker(entityPlayer.inventory, tile);
2015-10-10 02:51:06 +02:00
case RANGED_COLLECTOR:
return new GuiRangedCollector(entityPlayer.inventory, tile, x, y, z, world);
2014-12-18 19:24:06 +01:00
default:
return null;
}
}
public enum GuiTypes{
FEEDER,
GIANT_CHEST,
CRAFTER(false),
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(false),
ENERGIZER,
ENERVATOR,
XP_SOLIDIFIER,
2015-08-28 21:17:09 +02:00
CLOUD,
2015-10-05 16:53:28 +02:00
BOOK(false),
2015-11-24 19:59:33 +01:00
BOOK_STAND,
2015-10-10 02:51:06 +02:00
DIRECTIONAL_BREAKER,
RANGED_COLLECTOR;
public boolean checkTileEntity;
GuiTypes(){
this(true);
}
2015-10-03 10:19:40 +02:00
GuiTypes(boolean checkTileEntity){
this.checkTileEntity = checkTileEntity;
}
}
}