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
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD> 2015 Ellpeck
|
|
|
|
|
*/
|
|
|
|
|
|
2015-03-07 12:51:28 +01:00
|
|
|
|
package ellpeck.actuallyadditions.inventory;
|
2014-12-18 19:24:06 +01:00
|
|
|
|
|
2015-02-17 16:15:16 +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-06-12 19:12:06 +02:00
|
|
|
|
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;
|
|
|
|
|
|
2015-02-09 17:25:05 +01:00
|
|
|
|
public class GuiHandler implements IGuiHandler{
|
2014-12-18 19:24:06 +01:00
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
|
public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
|
2015-08-29 14:31:02 +02:00
|
|
|
|
if(id == GuiTypes.BOOK.ordinal()) return null;
|
|
|
|
|
|
2015-06-12 19:12:06 +02:00
|
|
|
|
TileEntityBase tile = null;
|
2015-07-17 09:03:31 +02:00
|
|
|
|
if(id != GuiTypes.CRAFTER.ordinal() && id != GuiTypes.DRILL.ordinal()){
|
2015-06-12 19:12:06 +02:00
|
|
|
|
tile = (TileEntityBase)world.getTileEntity(x, y, z);
|
|
|
|
|
}
|
2015-07-17 09:03:31 +02:00
|
|
|
|
switch(GuiTypes.values()[id]){
|
|
|
|
|
case FEEDER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerFeeder(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case GIANT_CHEST:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerGiantChest(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case CRAFTER:
|
2015-03-07 02:23:31 +01:00
|
|
|
|
return new ContainerCrafter(entityPlayer);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case GRINDER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerGrinder(entityPlayer.inventory, tile, false);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case GRINDER_DOUBLE:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerGrinder(entityPlayer.inventory, tile, true);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case FURNACE_DOUBLE:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerFurnaceDouble(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case INPUTTER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerInputter(entityPlayer.inventory, tile, false);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case INPUTTER_ADVANCED:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerInputter(entityPlayer.inventory, tile, true);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case REPAIRER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerRepairer(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case BREAKER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerBreaker(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case DROPPER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerDropper(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case CANOLA_PRESS:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerCanolaPress(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case FERMENTING_BARREL:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerFermentingBarrel(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case COAL_GENERATOR:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerCoalGenerator(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case OIL_GENERATOR:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerOilGenerator(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case PHANTOM_PLACER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerPhantomPlacer(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case FLUID_COLLECTOR:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerFluidCollector(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case COFFEE_MACHINE:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new ContainerCoffeeMachine(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case DRILL:
|
2015-06-21 02:28:49 +02:00
|
|
|
|
return new ContainerDrill(entityPlayer.inventory);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case ENERGIZER:
|
2015-07-12 01:22:47 +02:00
|
|
|
|
return new ContainerEnergizer(entityPlayer, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case ENERVATOR:
|
2015-07-12 01:22:47 +02:00
|
|
|
|
return new ContainerEnervator(entityPlayer, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case XP_SOLIDIFIER:
|
2015-07-13 23:44:33 +02:00
|
|
|
|
return new ContainerXPSolidifier(entityPlayer.inventory, tile);
|
2015-07-30 10:32:30 +02:00
|
|
|
|
case ORE_MAGNET:
|
|
|
|
|
return new ContainerOreMagnet(entityPlayer.inventory, tile);
|
2015-08-23 23:41:46 +02:00
|
|
|
|
case CLOUD:
|
|
|
|
|
return new ContainerSmileyCloud();
|
2014-12-18 19:24:06 +01:00
|
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
|
public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
|
2015-06-12 19:12:06 +02:00
|
|
|
|
TileEntityBase tile = null;
|
2015-07-17 09:03:31 +02:00
|
|
|
|
if(id != GuiTypes.CRAFTER.ordinal() && id != GuiTypes.DRILL.ordinal()){
|
2015-06-12 19:12:06 +02:00
|
|
|
|
tile = (TileEntityBase)world.getTileEntity(x, y, z);
|
|
|
|
|
}
|
2015-07-17 09:03:31 +02:00
|
|
|
|
switch(GuiTypes.values()[id]){
|
|
|
|
|
case FEEDER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiFeeder(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case GIANT_CHEST:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiGiantChest(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case CRAFTER:
|
2015-03-07 02:23:31 +01:00
|
|
|
|
return new GuiCrafter(entityPlayer);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case GRINDER:
|
2015-07-29 11:03:17 +02:00
|
|
|
|
return new GuiGrinder(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case GRINDER_DOUBLE:
|
2015-07-29 11:03:17 +02:00
|
|
|
|
return new GuiGrinder.GuiGrinderDouble(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case FURNACE_DOUBLE:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiFurnaceDouble(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case INPUTTER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiInputter(entityPlayer.inventory, tile, x, y, z, world, false);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case INPUTTER_ADVANCED:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiInputter(entityPlayer.inventory, tile, x, y, z, world, true);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case REPAIRER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiRepairer(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case BREAKER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiBreaker(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case DROPPER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiDropper(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case CANOLA_PRESS:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiCanolaPress(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case FERMENTING_BARREL:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiFermentingBarrel(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case COAL_GENERATOR:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiCoalGenerator(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case OIL_GENERATOR:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiOilGenerator(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case PHANTOM_PLACER:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiPhantomPlacer(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case FLUID_COLLECTOR:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiFluidCollector(entityPlayer.inventory, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case COFFEE_MACHINE:
|
2015-06-12 19:12:06 +02:00
|
|
|
|
return new GuiCoffeeMachine(entityPlayer.inventory, tile, x, y, z, world);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case DRILL:
|
2015-06-21 02:28:49 +02:00
|
|
|
|
return new GuiDrill(entityPlayer.inventory);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case ENERGIZER:
|
2015-07-12 01:22:47 +02:00
|
|
|
|
return new GuiEnergizer(entityPlayer, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case ENERVATOR:
|
2015-07-12 01:22:47 +02:00
|
|
|
|
return new GuiEnervator(entityPlayer, tile);
|
2015-07-17 09:03:31 +02:00
|
|
|
|
case XP_SOLIDIFIER:
|
2015-07-13 23:44:33 +02:00
|
|
|
|
return new GuiXPSolidifier(entityPlayer.inventory, tile, x, y, z, world);
|
2015-07-30 10:32:30 +02:00
|
|
|
|
case ORE_MAGNET:
|
|
|
|
|
return new GuiOreMagnet(entityPlayer.inventory, tile);
|
2015-08-23 23:41:46 +02:00
|
|
|
|
case CLOUD:
|
|
|
|
|
return new GuiSmileyCloud(tile, x, y, z, world);
|
2015-08-28 21:17:09 +02:00
|
|
|
|
case BOOK:
|
2015-08-30 19:10:10 +02:00
|
|
|
|
return new GuiBooklet(entityPlayer);
|
2014-12-18 19:24:06 +01:00
|
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-17 09:03:31 +02:00
|
|
|
|
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,
|
2015-07-30 10:32:30 +02:00
|
|
|
|
XP_SOLIDIFIER,
|
2015-08-23 23:41:46 +02:00
|
|
|
|
ORE_MAGNET,
|
2015-08-28 21:17:09 +02:00
|
|
|
|
CLOUD,
|
|
|
|
|
BOOK
|
2015-07-17 09:03:31 +02:00
|
|
|
|
}
|
2015-02-17 16:15:16 +01:00
|
|
|
|
|
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
|
|
|
|
}
|
2015-02-20 22:45:33 +01:00
|
|
|
|
}
|