diff --git a/gradle.properties b/gradle.properties index d1afd94..789862a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,6 +21,10 @@ forgeVersion = 10.13.4.1614 # Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty developmentEnvironmentUserName = Developer +# Enables using modern java syntax (up to version 17) via Jabel, while still targetting JVM 8. +# See https://github.com/bsideup/jabel for details on how this works. +enableModernJavaSyntax = true + # Define a source file of your project with: # public static final String VERSION = "GRADLETOKEN_VERSION"; # The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/WCTGuiHandler.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/WCTGuiHandler.java index 442ad0d..cd2d0d2 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/WCTGuiHandler.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/WCTGuiHandler.java @@ -30,70 +30,61 @@ public class WCTGuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) { - final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless() - .getWirelessTerminalHandler(RandomUtils.getWirelessTerm(player.inventory)); - if (wh != null) { - final WirelessTerminalGuiObject obj = new WirelessTerminalGuiObject( - wh, - RandomUtils.getWirelessTerm(player.inventory), - player, - world, - x, - y, - z); - if (obj != null) { - final IPortableCell terminal = obj; - - if (guiId == Reference.GUI_WCT) { - return updateGui( - new ContainerWirelessCraftingTerminal(player, player.inventory), - world, - x, - y, - z, - ForgeDirection.UNKNOWN, - obj); - } - - if (guiId == Reference.GUI_CRAFTING_STATUS) { - return updateGui( - new ContainerCraftingStatus(player.inventory, terminal), - world, - x, - y, - z, - ForgeDirection.UNKNOWN, - obj); - } - - if (guiId == Reference.GUI_CRAFT_AMOUNT) { - return updateGui( - new ContainerCraftAmount(player, terminal), - world, - x, - y, - z, - ForgeDirection.UNKNOWN, - obj); - } - - if (guiId == Reference.GUI_CRAFT_CONFIRM) { - return updateGui( - new ContainerCraftConfirm(player, terminal), - world, - x, - y, - z, - ForgeDirection.UNKNOWN, - obj); - } - } - } if (guiId == Reference.GUI_MAGNET) { return new ContainerMagnet(player, player.inventory); } - return null; + final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless() + .getWirelessTerminalHandler(RandomUtils.getWirelessTerm(player.inventory)); + if (wh == null) { + return null; + } + + final WirelessTerminalGuiObject term = new WirelessTerminalGuiObject( + wh, + RandomUtils.getWirelessTerm(player.inventory), + player, + world, + x, + y, + z); + + return switch (guiId) { + case Reference.GUI_WCT -> updateGui( + new ContainerWirelessCraftingTerminal(player, player.inventory), + world, + x, + y, + z, + ForgeDirection.UNKNOWN, + term); + case Reference.GUI_CRAFTING_STATUS -> updateGui( + new ContainerCraftingStatus(player.inventory, term), + world, + x, + y, + z, + ForgeDirection.UNKNOWN, + term); + + case Reference.GUI_CRAFT_AMOUNT -> updateGui( + new ContainerCraftAmount(player, term), + world, + x, + y, + z, + ForgeDirection.UNKNOWN, + term); + case Reference.GUI_CRAFT_CONFIRM -> updateGui( + new ContainerCraftConfirm(player, term), + world, + x, + y, + z, + ForgeDirection.UNKNOWN, + term); + default -> null; + }; } @Override diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/reference/Reference.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/reference/Reference.java index ed4d4ab..062df8c 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/reference/Reference.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/reference/Reference.java @@ -22,10 +22,9 @@ public class Reference { public static boolean WCT_HASCHECKEDVERSION = false; // Gui IDs - private static int ae2wctGuiIndex = 0; - public static final int GUI_WCT = ++ae2wctGuiIndex; - public static final int GUI_CRAFTING_STATUS = ++ae2wctGuiIndex; - public static final int GUI_CRAFT_AMOUNT = ++ae2wctGuiIndex; - public static final int GUI_CRAFT_CONFIRM = ++ae2wctGuiIndex; - public static final int GUI_MAGNET = ++ae2wctGuiIndex; + public static final int GUI_WCT = 0; + public static final int GUI_CRAFTING_STATUS = 1; + public static final int GUI_CRAFT_AMOUNT = 2; + public static final int GUI_CRAFT_CONFIRM = 3; + public static final int GUI_MAGNET = 4; }