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

254 lines
11 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
2016-05-16 22:52:27 +02:00
* This file ("GuiHandler.java") is part of the Actually Additions mod for Minecraft.
2015-08-29 14:33:25 +02:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2017-01-01 16:23:26 +01:00
* © 2015-2017 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.inventory;
2014-12-18 19:24:06 +01:00
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
2016-11-11 21:07:18 +01:00
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
2021-02-27 21:24:26 +01:00
import de.ellpeck.actuallyadditions.mod.inventory.gui.*;
2016-11-11 21:07:18 +01:00
import de.ellpeck.actuallyadditions.mod.items.ItemBooklet;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
2018-03-07 03:08:25 +01:00
import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil;
2021-02-26 22:15:48 +01:00
import net.minecraft.entity.player.PlayerEntity;
2016-03-18 23:47:22 +01:00
import net.minecraft.util.math.BlockPos;
2014-12-18 19:24:06 +01:00
import net.minecraft.world.World;
public class GuiHandler {
2014-12-18 19:24:06 +01:00
@Deprecated
2021-02-26 22:15:48 +01:00
public Object getServerGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
TileEntityBase tile = null;
2019-05-02 09:10:29 +02:00
if (GuiTypes.values()[id].checkTileEntity) {
tile = (TileEntityBase) world.getTileEntity(new BlockPos(x, y, z));
}
2019-05-02 09:10:29 +02:00
switch (GuiTypes.values()[id]) {
// case FEEDER:
// return new ContainerFeeder(player.inventory, tile);
// case GIANT_CHEST:
// return new ContainerGiantChest(player.inventory, tile, 0);
// case GIANT_CHEST_PAGE_2:
// return new ContainerGiantChest(player.inventory, tile, 1);
// case GIANT_CHEST_PAGE_3:
// return new ContainerGiantChest(player.inventory, tile, 2);
// case CRAFTER:
// return CompatUtil.getCrafterContainerElement(player, world, x, y, z);
// case GRINDER:
// return new ContainerGrinder(player.inventory, tile, false);
// case GRINDER_DOUBLE:
// return new ContainerGrinder(player.inventory, tile, true);
// case FURNACE_DOUBLE:
// return new ContainerFurnaceDouble(player.inventory, tile);
// case INPUTTER:
// return new ContainerInputter(player.inventory, tile, false);
// case INPUTTER_ADVANCED:
// return new ContainerInputter(player.inventory, tile, true);
// case REPAIRER:
// return new ContainerRepairer(player.inventory, tile);
// case BREAKER:
// return new ContainerBreaker(player.inventory, tile);
// case DROPPER:
// return new ContainerDropper(player, tile);
// case CANOLA_PRESS:
// return new ContainerCanolaPress(player.inventory, tile);
// case FERMENTING_BARREL:
// return new ContainerFermentingBarrel(player.inventory, tile);
// case COAL_GENERATOR:
// return new ContainerCoalGenerator(player.inventory, tile);
// case OIL_GENERATOR:
// return new ContainerOilGenerator(player.inventory, tile);
// case PHANTOM_PLACER:
// return new ContainerPhantomPlacer(player.inventory, tile);
// case FLUID_COLLECTOR:
// return new ContainerFluidCollector(player.inventory, tile);
// case COFFEE_MACHINE:
// return new ContainerCoffeeMachine(player.inventory, tile);
// case DRILL:
// return new ContainerDrill(player.inventory);
// case FILTER:
// return new ContainerFilter(player.inventory);
// case ENERGIZER:
// return new ContainerEnergizer(player, tile);
// case ENERVATOR:
// return new ContainerEnervator(player, tile);
// case XP_SOLIDIFIER:
// return new ContainerXPSolidifier(player.inventory, tile);
// case CLOUD:
// return new ContainerSmileyCloud();
// case DIRECTIONAL_BREAKER:
// return new ContainerDirectionalBreaker(player.inventory, tile);
// case RANGED_COLLECTOR:
// return new ContainerRangedCollector(player.inventory, tile);
// case MINER:
// return new ContainerMiner(player.inventory, tile);
// case LASER_RELAY_ITEM_WHITELIST:
// return new ContainerLaserRelayItemWhitelist(player.inventory, tile);
// case BAG:
// return new ContainerBag(player.getHeldItemMainhand(), player.inventory, false);
// case VOID_BAG:
// return new ContainerBag(player.getHeldItemMainhand(), player.inventory, true);
// case BIO_REACTOR:
// return new ContainerBioReactor(player.inventory, tile);
// case FARMER:
// return new ContainerFarmer(player.inventory, tile);
// case FIREWORK_BOX:
// return new ContainerFireworkBox();
2021-02-27 21:24:26 +01:00
default:
return null;
2014-12-18 19:24:06 +01:00
}
}
@Deprecated
2021-02-26 22:15:48 +01:00
public Object getClientGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
TileEntityBase tile = null;
2019-05-02 09:10:29 +02:00
if (GuiTypes.values()[id].checkTileEntity) {
tile = (TileEntityBase) world.getTileEntity(new BlockPos(x, y, z));
}
2019-05-02 09:10:29 +02:00
switch (GuiTypes.values()[id]) {
2021-02-27 21:24:26 +01:00
case FEEDER:
return new GuiFeeder(player.inventory, tile);
case GIANT_CHEST:
return new GuiGiantChest(player.inventory, tile, 0);
case GIANT_CHEST_PAGE_2:
return new GuiGiantChest(player.inventory, tile, 1);
case GIANT_CHEST_PAGE_3:
return new GuiGiantChest(player.inventory, tile, 2);
case CRAFTER:
return CompatUtil.getCrafterGuiElement(player, world, x, y, z);
case GRINDER:
return new GuiGrinder(player.inventory, tile);
case GRINDER_DOUBLE:
return new GuiGrinder.GuiGrinderDouble(player.inventory, tile);
case FURNACE_DOUBLE:
return new GuiFurnaceDouble(player.inventory, tile);
case INPUTTER:
return new GuiInputter(player.inventory, tile, false);
case INPUTTER_ADVANCED:
return new GuiInputter(player.inventory, tile, true);
case REPAIRER:
return new GuiRepairer(player.inventory, tile);
// case BREAKER:
// return new GuiBreaker(player.inventory, tile);
2021-02-27 21:24:26 +01:00
case DROPPER:
return new GuiDropper(player, tile);
case CANOLA_PRESS:
return new GuiCanolaPress(player.inventory, tile);
case FERMENTING_BARREL:
return new GuiFermentingBarrel(player.inventory, tile);
case COAL_GENERATOR:
return new GuiCoalGenerator(player.inventory, tile);
case OIL_GENERATOR:
return new GuiOilGenerator(player.inventory, tile);
case PHANTOM_PLACER:
return new GuiPhantomPlacer(player.inventory, tile);
case FLUID_COLLECTOR:
return new GuiFluidCollector(player.inventory, tile);
case COFFEE_MACHINE:
return new GuiCoffeeMachine(player.inventory, tile);
case DRILL:
return new GuiDrill(player.inventory);
case FILTER:
return new GuiFilter(player.inventory);
case ENERGIZER:
return new GuiEnergizer(player, tile);
case ENERVATOR:
return new GuiEnervator(player, tile);
case XP_SOLIDIFIER:
return new GuiXPSolidifier(player.inventory, tile);
case CLOUD:
return new GuiSmileyCloud(tile, x, y, z, world);
case BOOK:
if (ItemBooklet.forcedPage != null) {
GuiBooklet gui = BookletUtils.createBookletGuiFromPage(null, ItemBooklet.forcedPage);
ItemBooklet.forcedPage = null;
return gui;
2019-05-02 09:10:29 +02:00
} else {
2021-02-27 21:24:26 +01:00
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
if (data.lastOpenBooklet != null) {
return data.lastOpenBooklet;
} else {
return new GuiMainPage(null);
}
2016-11-11 21:07:18 +01:00
}
2021-02-27 21:24:26 +01:00
case DIRECTIONAL_BREAKER:
return new GuiDirectionalBreaker(player.inventory, tile);
case RANGED_COLLECTOR:
return new GuiRangedCollector(player.inventory, tile);
case MINER:
return new GuiMiner(player.inventory, tile);
case LASER_RELAY_ITEM_WHITELIST:
return new GuiLaserRelayItemWhitelist(player.inventory, tile);
// case BAG:
// return new GuiBag(player.getHeldItemMainhand(), player.inventory, false);
// case VOID_BAG:
// return new GuiBag(player.getHeldItemMainhand(), player.inventory, true);
case BIO_REACTOR:
return new GuiBioReactor(player.inventory, tile);
case FARMER:
return new GuiFarmer(player.inventory, tile);
case FIREWORK_BOX:
return new GuiFireworkBox(tile);
default:
return null;
2014-12-18 19:24:06 +01:00
}
}
@Deprecated
2019-05-02 09:10:29 +02:00
public enum GuiTypes {
FEEDER,
GIANT_CHEST,
2016-06-27 20:19:04 +02:00
GIANT_CHEST_PAGE_2,
GIANT_CHEST_PAGE_3,
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-10-10 02:51:06 +02:00
DIRECTIONAL_BREAKER,
2015-12-09 20:24:45 +01:00
RANGED_COLLECTOR,
MINER,
2016-06-07 23:17:06 +02:00
LASER_RELAY_ITEM_WHITELIST,
FILTER(false),
BAG(false),
2016-09-14 21:42:03 +02:00
VOID_BAG(false),
2016-10-31 18:03:18 +01:00
BIO_REACTOR,
FARMER,
FIREWORK_BOX;
2016-05-19 20:05:12 +02:00
public final boolean checkTileEntity;
2019-05-02 09:10:29 +02:00
GuiTypes() {
this(true);
}
2015-10-03 10:19:40 +02:00
2019-05-02 09:10:29 +02:00
GuiTypes(boolean checkTileEntity) {
2015-10-03 10:19:40 +02:00
this.checkTileEntity = checkTileEntity;
}
}
2021-02-26 22:15:48 +01:00
}