From fd6750ad7c16c749db5ce30b63fb8518e62b3cb7 Mon Sep 17 00:00:00 2001 From: miozune Date: Fri, 2 Dec 2022 19:50:23 +0900 Subject: Rewrite GUIs with ModularUI (#239) * port most of the radio hatch to modularuii * be done with this radio hatch. fuck colors * radio hatch right bar color woooo * spotless hell * final color fix ffs * a bit of tweak * NEI * Windmill * LESU * cleanup * Water Pump, Destructopack, cleanup * Circuit Programmer, Radiation Shutter * Use new MUI method for setOnScrollNumbers Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Co-authored-by: Martin Robertz Former-commit-id: a717aa0117091559dd00bc0a10e54db2025979fc --- .../bartimaeusnek/bartworks/API/ITileWithGUI.java | 54 ----- .../bartworks/API/modularUI/BW_UITextures.java | 56 +++++ .../github/bartimaeusnek/bartworks/GuiHandler.java | 41 ---- .../gui/BW_GUIContainer_HeatedWaterPump.java | 65 ------ .../client/gui/BW_GUIContainer_RadLevel.java | 60 ----- .../client/gui/BW_GUIContainer_Windmill.java | 82 ------- .../gui/GT_GUIContainer_CircuitProgrammer.java | 51 ----- .../client/gui/GT_GUIContainer_Destructopack.java | 53 ----- .../bartworks/client/gui/GT_GUIContainer_LESU.java | 121 ---------- .../client/gui/GT_GUIContainer_RadioHatch.java | 101 -------- .../common/blocks/BW_TileEntityContainer.java | 10 +- .../blocks/BW_TileEntityContainer_Multiple.java | 9 +- .../bartworks/common/items/Circuit_Programmer.java | 115 +++++++++- .../common/items/GT_Destructopack_Item.java | 37 ++- .../classic/BW_TileEntity_HeatedWaterPump.java | 43 +++- .../classic/BW_TileEntity_InfinityTank.java | 8 +- .../classic/BW_TileEntity_LESU_Redux.java | 8 +- .../tileentities/multis/GT_TileEntity_DEHP.java | 8 - .../tileentities/multis/GT_TileEntity_LESU.java | 123 ++++++++-- .../multis/GT_TileEntity_Windmill.java | 104 +++++++-- .../mega/GT_TileEntity_MegaBlastFurnace.java | 8 - .../mega/GT_TileEntity_MegaChemicalReactor.java | 8 - .../mega/GT_TileEntity_MegaDistillTower.java | 8 - .../multis/mega/GT_TileEntity_MegaOilCracker.java | 8 - .../mega/GT_TileEntity_MegaVacuumFreezer.java | 8 - .../tiered/GT_MetaTileEntity_RadioHatch.java | 204 +++++++++++++---- .../bartworks/neiHandler/BW_NEI_BioVatHandler.java | 2 +- .../neiHandler/BW_NEI_RadHatchHandler.java | 9 +- .../container/BW_Container_HeatedWaterPump.java | 195 ---------------- .../server/container/BW_Container_RadioHatch.java | 207 ----------------- .../server/container/BW_Container_Windmill.java | 39 ---- .../container/GT_Container_CircuitProgrammer.java | 255 --------------------- .../container/GT_Container_Item_Destructopack.java | 66 ------ .../server/container/GT_Container_LESU.java | 56 ----- .../server/container/GT_Container_RadioHatch.java | 156 ------------- .../server/container/Slots/BW_DelSlot.java | 39 ---- .../server/container/Slots/BW_FuelSlot.java | 39 ---- .../bartimaeusnek/bartworks/util/BWRecipes.java | 155 ++++++++----- .../openComputers/TileEntity_GTDataServer.java | 8 +- 39 files changed, 727 insertions(+), 1892 deletions(-) delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/ITileWithGUI.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/API/modularUI/BW_UITextures.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_HeatedWaterPump.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RadLevel.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_Windmill.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_CircuitProgrammer.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_Destructopack.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_LESU.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_RadioHatch.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_Windmill.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_CircuitProgrammer.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_Item_Destructopack.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_LESU.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_RadioHatch.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/server/container/Slots/BW_DelSlot.java delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/server/container/Slots/BW_FuelSlot.java (limited to 'src/main/java') diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileWithGUI.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileWithGUI.java deleted file mode 100644 index 38b762fa9a..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileWithGUI.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.API; - -import com.github.bartimaeusnek.bartworks.MainMod; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; - -public interface ITileWithGUI { - - /** - * @return the ID of the GUI, see @link com.github.bartimaeusnek.bartworks.GuiHandler - */ - int getGUIID(); - - /** - * gets called from BW_TileEntityContainer(or _Multiple) when right clicked. - * - * @param tileEntity this tile entity - * @param player the player right clicking it - * @return true always. - */ - default boolean openGUI(TileEntity tileEntity, EntityPlayer player) { - if (!tileEntity.getWorldObj().isRemote) - player.openGui( - MainMod.MOD_ID, - getGUIID(), - tileEntity.getWorldObj(), - tileEntity.xCoord, - tileEntity.yCoord, - tileEntity.zCoord); - return true; - } -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/modularUI/BW_UITextures.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/modularUI/BW_UITextures.java new file mode 100644 index 0000000000..86d9d2c0b8 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/modularUI/BW_UITextures.java @@ -0,0 +1,56 @@ +package com.github.bartimaeusnek.bartworks.API.modularUI; + +import static com.github.bartimaeusnek.bartworks.MainMod.MOD_ID; + +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class BW_UITextures { + + public static final AdaptableUITexture BACKGROUND_BROWN = + AdaptableUITexture.of(MOD_ID, "GUI/background/brown", 176, 166, 3); + public static final UITexture BACKGROUND_CIRCUIT_PROGRAMMER = + UITexture.fullImage(MOD_ID, "GUI/background/circuit_programmer"); + + public static final AdaptableUITexture SLOT_BROWN = AdaptableUITexture.of(MOD_ID, "GUI/slot/brown", 18, 18, 1); + + public static final UITexture OVERLAY_SLOT_DISH = UITexture.fullImage(MOD_ID, "GUI/overlay_slot/dish"); + public static final UITexture OVERLAY_SLOT_DNA_FLASK = UITexture.fullImage(MOD_ID, "GUI/overlay_slot/dna_flask"); + public static final UITexture OVERLAY_SLOT_MODULE = UITexture.fullImage(MOD_ID, "GUI/overlay_slot/module"); + public static final UITexture OVERLAY_SLOT_ROD = UITexture.fullImage(MOD_ID, "GUI/overlay_slot/rod"); + public static final UITexture OVERLAY_SLOT_CROSS = UITexture.fullImage(MOD_ID, "GUI/overlay_slot/cross"); + + public static final UITexture PROGRESSBAR_SIEVERT = UITexture.fullImage(MOD_ID, "GUI/progressbar/sievert"); + public static final UITexture PROGRESSBAR_STORED_EU_116 = + UITexture.fullImage(MOD_ID, "GUI/progressbar/stored_eu_116"); + public static final UITexture PROGRESSBAR_FUEL = UITexture.fullImage(MOD_ID, "GUI/progressbar/fuel"); + + public static final UITexture PICTURE_BW_LOGO_47X21 = UITexture.fullImage(MOD_ID, "GUI/picture/bw_logo_47x21"); + public static final UITexture PICTURE_SIEVERT_CONTAINER = + UITexture.fullImage(MOD_ID, "GUI/picture/sievert_container"); + public static final UITexture PICTURE_DECAY_TIME_CONTAINER = + UITexture.fullImage(MOD_ID, "GUI/picture/decay_time_container"); + public static final UITexture PICTURE_DECAY_TIME_INSIDE = + UITexture.fullImage(MOD_ID, "GUI/picture/decay_time_inside"); + public static final UITexture PICTURE_RADIATION = UITexture.fullImage(MOD_ID, "GUI/picture/radiation"); + public static final UITexture PICTURE_WINDMILL_EMPTY = UITexture.fullImage(MOD_ID, "GUI/picture/windmill_empty"); + public static final UITexture[] PICTURE_WINDMILL_ROTATING = IntStream.range(0, 4) + .mapToObj(i -> + UITexture.partly(MOD_ID, "GUI/picture/windmill_rotating", 32, 128, 0, i * 32, 32, (i + 1) * 32)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture PICTURE_STORED_EU_FRAME = UITexture.fullImage(MOD_ID, "GUI/picture/stored_eu_frame"); + public static final UITexture PICTURE_RADIATION_SHUTTER_FRAME = + UITexture.fullImage(MOD_ID, "GUI/picture/radiation_shutter_frame"); + public static final AdaptableUITexture PICTURE_RADIATION_SHUTTER_INSIDE = + AdaptableUITexture.of(MOD_ID, "GUI/picture/radiation_shutter_inside", 51, 48, 1); + + public static final AdaptableUITexture TAB_TITLE_BROWN = + AdaptableUITexture.of(MOD_ID, "GUI/tab/title_brown", 28, 28, 4); + public static final AdaptableUITexture TAB_TITLE_DARK_BROWN = + AdaptableUITexture.of(MOD_ID, "GUI/tab/title_dark_brown", 28, 28, 4); + public static final AdaptableUITexture TAB_TITLE_ANGULAR_BROWN = + AdaptableUITexture.of(MOD_ID, "GUI/tab/title_angular_brown", 28, 28, 4); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java index d074e32c53..28dbaf5250 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java @@ -23,17 +23,7 @@ package com.github.bartimaeusnek.bartworks; import com.github.bartimaeusnek.bartworks.API.SideReference; -import com.github.bartimaeusnek.bartworks.client.gui.BW_GUIContainer_HeatedWaterPump; -import com.github.bartimaeusnek.bartworks.client.gui.BW_GUIContainer_RadLevel; -import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_CircuitProgrammer; -import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_Destructopack; -import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; -import com.github.bartimaeusnek.bartworks.server.container.BW_Container_HeatedWaterPump; -import com.github.bartimaeusnek.bartworks.server.container.BW_Container_RadioHatch; -import com.github.bartimaeusnek.bartworks.server.container.GT_Container_CircuitProgrammer; -import com.github.bartimaeusnek.bartworks.server.container.GT_Container_Item_Destructopack; import cpw.mods.fml.common.network.IGuiHandler; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; @@ -41,43 +31,12 @@ public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch (ID) { - case 0: - return new GT_Container_Item_Destructopack(player.inventory); - case 1: - return new GT_Container_CircuitProgrammer(player.inventory); - case 2: { - if (world.getTileEntity(x, y, z) instanceof IGregTechTileEntity) { - IGregTechTileEntity te = (IGregTechTileEntity) world.getTileEntity(x, y, z); - return new BW_Container_RadioHatch(player.inventory, te.getMetaTileEntity()); - } - } - case 3: - return new BW_Container_HeatedWaterPump( - (BW_TileEntity_HeatedWaterPump) world.getTileEntity(x, y, z), player); - } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (SideReference.Side.Client) { - switch (ID) { - case 0: - return new GT_GUIContainer_Destructopack(player.inventory); - case 1: - return new GT_GUIContainer_CircuitProgrammer(player.inventory); - case 2: { - if (world.getTileEntity(x, y, z) instanceof IGregTechTileEntity) { - IGregTechTileEntity te = (IGregTechTileEntity) world.getTileEntity(x, y, z); - return new BW_GUIContainer_RadLevel( - new BW_Container_RadioHatch(player.inventory, te.getMetaTileEntity())); - } - } - case 3: - return new BW_GUIContainer_HeatedWaterPump(new BW_Container_HeatedWaterPump( - (BW_TileEntity_HeatedWaterPump) world.getTileEntity(x, y, z), player)); - } } else return getServerGuiElement(ID, player, world, x, y, z); return null; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_HeatedWaterPump.java deleted file mode 100644 index d92ed0012f..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_HeatedWaterPump.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.client.gui; - -import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.server.container.BW_Container_HeatedWaterPump; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.inventory.Container; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - -public class BW_GUIContainer_HeatedWaterPump extends GuiContainer { - private static final ResourceLocation furnaceGuiTextures = - new ResourceLocation(MainMod.MOD_ID + ":textures/GUI/GUIheatedPump.png"); - final BW_Container_HeatedWaterPump container; - - public BW_GUIContainer_HeatedWaterPump(Container p_i1072_1_) { - super(p_i1072_1_); - this.container = (BW_Container_HeatedWaterPump) p_i1072_1_; - } - - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(BW_GUIContainer_HeatedWaterPump.furnaceGuiTextures); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - // this.drawString(this.fontRendererObj, "Fuel:" + container.fuel + " Water:" + container.water, k, l, - // 0xffffff); - - if (this.container.fuel > 0) { - this.mc.getTextureManager().bindTexture(BW_GUIContainer_HeatedWaterPump.furnaceGuiTextures); - int ik = Math.max(this.container.maxfuel, 200); - int i1 = ((this.container.fuel * 13) / ik); - this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 13 - i1, 14, i1 + 1); - } - - // if (this.container.water > 0){ - // this.mc.getTextureManager().bindTexture( new ResourceLocation("textures/blocks/water_still.png")); - // this.drawTexturedModalRect(k+85,l+32,32,32,18,18); - // } - - } -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RadLevel.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RadLevel.java deleted file mode 100644 index 6d234b69dd..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RadLevel.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.client.gui; - -import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.server.container.BW_Container_RadioHatch; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.inventory.Container; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class BW_GUIContainer_RadLevel extends GuiContainer { - final BW_Container_RadioHatch container; - - public BW_GUIContainer_RadLevel(Container p_i1072_1_) { - super(p_i1072_1_); - this.container = (BW_Container_RadioHatch) p_i1072_1_; - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - GL11.glColor3f(1, 1, 1); - this.mc.getTextureManager().bindTexture(new ResourceLocation(MainMod.MOD_ID, "textures/GUI/GUI_RSC.png")); - this.drawTexturedModalRect(this.guiLeft - 79, this.guiTop, 0, 0, 256, 165); - } - - @Override - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - int y = 51 + (this.container.coverage / 2 - 3); - int x = -63; - if (this.container.coverage != 100 && this.container.coverage != 0) - Gui.drawRect(x, y, x + 51, y + 1, 0xFF60D82E); - Gui.drawRect(x, 48, x + 51, y, 0xFF8B8B8B); - this.fontRendererObj.drawString(Byte.toString(this.container.coverage), 88 - 79, 50, 16448255); - } -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_Windmill.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_Windmill.java deleted file mode 100644 index 5b6c40c20a..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_Windmill.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.client.gui; - -import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.server.container.BW_Container_Windmill; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_Container_MultiMachine; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_LanguageManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; - -@SideOnly(Side.CLIENT) -public class BW_GUIContainer_Windmill extends GT_GUIContainerMetaTile_Machine { - - public BW_GUIContainer_Windmill(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new BW_Container_Windmill(aInventoryPlayer, aTileEntity), ""); - } - - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - if (!(this.mContainer instanceof GT_Container_MultiMachine)) return; - - if ((this.mContainer.mDisplayErrorCode & 64) != 0) - this.fontRendererObj.drawString(this.trans("138", "Incomplete Structure."), 92, 22, 16448255); - } - - public String trans(String aKey, String aEnglish) { - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); - } - - private static final int DIVIDER = 125; - private byte last = 0; - - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - this.mc.getTextureManager().bindTexture(new ResourceLocation(MainMod.MOD_ID, "textures/GUI/GUI_Windmill.png")); - - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer.mMaxProgressTime > 0) { - if (System.currentTimeMillis() / DIVIDER % 40 == 30) - this.drawTexturedModalRect(x + 85, y + 27, 176, (last = 96), 32, 32); - else if (System.currentTimeMillis() / DIVIDER % 40 == 20) - this.drawTexturedModalRect(x + 85, y + 27, 176, (last = 64), 32, 32); - else if (System.currentTimeMillis() / DIVIDER % 40 == 10) - this.drawTexturedModalRect(x + 85, y + 27, 176, (last = 32), 32, 32); - else if (System.currentTimeMillis() / DIVIDER % 40 == 0) - this.drawTexturedModalRect(x + 85, y + 27, 176, (last = 0), 32, 32); - else this.drawTexturedModalRect(x + 85, y + 27, 176, last, 32, 32); - } - - // Soft Mallet - if (this.mContainer.mDisplayErrorCode == 0) { - if (this.mContainer.mActive == 0) { - this.drawTexturedModalRect(x + 66, y + 66, 176, 128, 15, 15); - } - } - } -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_CircuitProgrammer.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_CircuitProgrammer.java deleted file mode 100644 index e575474b72..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_CircuitProgrammer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.client.gui; - -import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.server.container.GT_Container_CircuitProgrammer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class GT_GUIContainer_CircuitProgrammer extends GuiContainer { - - public static final ResourceLocation texture = - new ResourceLocation(MainMod.MOD_ID, "textures/GUI/GUI_CircuitP.png"); - - public GT_GUIContainer_CircuitProgrammer(InventoryPlayer p_i1072_1_) { - super(new GT_Container_CircuitProgrammer(p_i1072_1_)); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().getTextureManager().bindTexture(GT_GUIContainer_CircuitProgrammer.texture); - this.drawTexturedModalRect(this.guiLeft - 79, this.guiTop, 0, 0, 256, 165); - } -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_Destructopack.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_Destructopack.java deleted file mode 100644 index 7b050d64b7..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_Destructopack.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.client.gui; - -import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.server.container.GT_Container_Item_Destructopack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class GT_GUIContainer_Destructopack extends GuiContainer { - public static final ResourceLocation texture = - new ResourceLocation(MainMod.MOD_ID, "textures/GT2/gui/Destructopack.png"); - - public GT_GUIContainer_Destructopack(InventoryPlayer inventory) { - super(new GT_Container_Item_Destructopack(inventory)); - } - - @Override - public void drawGuiContainerBackgroundLayer(float f, int j, int i) { - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().getTextureManager().bindTexture(GT_GUIContainer_Destructopack.texture); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 175, 165); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) {} -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_LESU.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_LESU.java deleted file mode 100644 index acab43a06e..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_LESU.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.client.gui; - -import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; -import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_LESU; -import com.github.bartimaeusnek.bartworks.server.container.GT_Container_LESU; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_GUIContainer; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import java.awt.*; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class GT_GUIContainer_LESU extends GT_GUIContainer { - - public static final ResourceLocation texture = new ResourceLocation(MainMod.MOD_ID, "textures/GT2/gui/LESU.png"); - protected GT_Container_LESU mContainer; - private final GT_TileEntity_LESU c; - - public GT_GUIContainer_LESU(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_LESU(aInventoryPlayer, aTileEntity), GT_GUIContainer_LESU.texture.getResourceDomain()); - this.mContainer = ((GT_Container_LESU) this.inventorySlots); - this.c = ((GT_TileEntity_LESU) (this.mContainer.mTileEntity.getMetaTileEntity())); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.drawString(this.fontRendererObj, "L.E.S.U.", 11, 8, 16448255); - if (this.mContainer != null) { - String percell = String.valueOf(ConfigHandler.energyPerCell).substring(1); - this.drawString( - this.fontRendererObj, "EU: " + GT_Utility.formatNumbers(this.mContainer.mEnergy), 11, 16, 16448255); - this.drawString( - this.fontRendererObj, - "MAX: " - + (this.c.getBaseMetaTileEntity().isActive() - ? GT_Utility.formatNumbers(this.mContainer.mOutput) + percell - : Integer.toString(0)), - 11, - 24, - 16448255); - this.drawString( - this.fontRendererObj, - "MAX EU/t IN: " + GT_Utility.formatNumbers(this.mContainer.mInput), - 11, - 32, - 16448255); - this.drawString( - this.fontRendererObj, - "EU/t OUT: " + GT_Utility.formatNumbers(this.mContainer.mOutput), - 11, - 40, - 16448255); - this.drawString( - this.fontRendererObj, - "AMP/t IN/OUT: " - + GT_Utility.formatNumbers( - this.c.getBaseMetaTileEntity().getInputAmperage()), - 11, - 48, - 16448255); - if (this.c.maxEUStore() >= Long.MAX_VALUE - 1) { - this.drawString( - this.fontRendererObj, - StatCollector.translateToLocal("tooltip.LESU.0.name"), - 11, - 56, - Color.YELLOW.getRGB()); - } - if (!this.c.getBaseMetaTileEntity().isActive()) { - this.drawString( - this.fontRendererObj, - StatCollector.translateToLocal("tooltip.LESU.1.name"), - 11, - 56, - Color.RED.getRGB()); - } - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - Minecraft.getMinecraft().getTextureManager().bindTexture(GT_GUIContainer_LESU.texture); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer != null) { - long tScale = this.mContainer.mEnergy / Math.max(1, this.c.maxEUStore() / 116); - this.drawTexturedModalRect(x + 8, y + 73, 0, 251, (int) tScale, 5); - } - } -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java deleted file mode 100644 index b77417131c..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.client.gui; - -import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; -import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.server.container.GT_Container_RadioHatch; -import com.github.bartimaeusnek.bartworks.util.MathUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class GT_GUIContainer_RadioHatch extends GT_GUIContainerMetaTile_Machine { - private static int maxSv; - private final String mName; - - public GT_GUIContainer_RadioHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { - super( - new GT_Container_RadioHatch(aInventoryPlayer, aTileEntity), - MainMod.MOD_ID + ":textures/GUI/RadHatch.png"); - this.mName = "Radio Hatch"; - this.mContainer.detectAndSendChanges(); - GT_GUIContainer_RadioHatch.maxSv = BioVatLogicAdder.RadioHatch.getMaxSv(); - } - - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - - long timer = ((GT_Container_RadioHatch) this.mContainer).teTimer; - double maxT = ((GT_Container_RadioHatch) this.mContainer).decayTime; - double rem = maxT - timer % maxT; - - this.fontRendererObj.drawString(this.mName, 5, 4, 4210752); - this.mc.getTextureManager().bindTexture(new ResourceLocation(MainMod.MOD_ID + ":textures/GUI/RadHatch.png")); - if (((GT_Container_RadioHatch) this.mContainer).mass > 0) { - GL11.glColor3f( - ((GT_Container_RadioHatch) this.mContainer).r / 255f, - ((GT_Container_RadioHatch) this.mContainer).g / 255f, - ((GT_Container_RadioHatch) this.mContainer).b / 255f); - this.drawTexturedModalRect(124, 18, 124, 18, 16, 48); - } - GL11.glColor3f(1f, 1f, 1f); - if (((GT_Container_RadioHatch) this.mContainer).mass <= 0) { - this.drawTexturedModalRect(124, 18, 176, 0, 16, 48); - } else { - this.drawTexturedModalRect(124, 18, 176, 0, 16, 48 - MathUtils.ceilInt(48 * (rem / maxT))); - } - this.drawTexturedModalRect( - 65, - 13, - 192, - 0, - (48 * (((GT_Container_RadioHatch) this.mContainer).sv)) / (GT_GUIContainer_RadioHatch.maxSv), - 16); - - this.fontRendererObj.drawString( - StatCollector.translateToLocalFormatted( - "BW.NEI.display.radhatch.1", ((GT_Container_RadioHatch) this.mContainer).mass), - 65, - 62, - 4210752); - this.fontRendererObj.drawString( - StatCollector.translateToLocalFormatted( - "BW.NEI.display.radhatch.0", ((GT_Container_RadioHatch) this.mContainer).sv), - 60, - 72, - 4210752); - } - - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java index e14ff9f491..7b10ace417 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java @@ -25,9 +25,10 @@ package com.github.bartimaeusnek.bartworks.common.blocks; import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; import com.github.bartimaeusnek.bartworks.API.ITileDropsContent; import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; -import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; +import com.gtnewhorizons.modularui.api.UIInfos; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ic2.api.tile.IWrenchable; @@ -98,8 +99,11 @@ public class BW_TileEntityContainer extends BlockContainer implements ITileAddsI if (!player.isSneaking()) { if (tile instanceof IHasGui) { return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); - } else if (tile instanceof ITileWithGUI) { - return worldObj.isRemote || ((ITileWithGUI) tile).openGUI(tile, player); + } else if (tile instanceof ITileWithModularUI) { + if (!worldObj.isRemote) { + UIInfos.TILE_MODULAR_UI.open(player, worldObj, x, y, z); + } + return true; } } return false; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java index 61429f10e1..184e02dc00 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java @@ -22,8 +22,9 @@ package com.github.bartimaeusnek.bartworks.common.blocks; -import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; import com.github.bartimaeusnek.bartworks.MainMod; +import com.gtnewhorizons.modularui.api.UIInfos; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ic2.api.tile.IWrenchable; @@ -90,8 +91,10 @@ public class BW_TileEntityContainer_Multiple extends BlockContainer { TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof IHasGui) { return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); - } else if (tile instanceof ITileWithGUI) { - return worldObj.isRemote || ((ITileWithGUI) tile).openGUI(tile, player); + } else if (tile instanceof ITileWithModularUI) { + if (!worldObj.isRemote) { + UIInfos.TILE_MODULAR_UI.open(player, worldObj, x, y, z); + } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java index fde6eaa2f4..bfc0a9d239 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java @@ -22,13 +22,32 @@ package com.github.bartimaeusnek.bartworks.common.items; +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.IItemWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.items.GT_Generic_Item; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import java.util.List; @@ -37,10 +56,11 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -public class Circuit_Programmer extends GT_Generic_Item implements IElectricItem { +public class Circuit_Programmer extends GT_Generic_Item implements IElectricItem, IItemWithModularUI { private static final int COST_PER_USE = 100; @@ -73,11 +93,12 @@ public class Circuit_Programmer extends GT_Generic_Item implements IElectricItem @Override public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { if (ElectricItem.manager.use(aStack, COST_PER_USE, aPlayer)) { - aPlayer.openGui(MainMod.instance, 1, aWorld, 0, 0, 0); + GT_UIInfos.openPlayerHeldItemUI(aPlayer); } return aStack; } + @Override @SideOnly(Side.CLIENT) @SuppressWarnings("unchecked") public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { @@ -92,11 +113,13 @@ public class Circuit_Programmer extends GT_Generic_Item implements IElectricItem } } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister aIconRegister) { this.mIcon = aIconRegister.registerIcon("bartworks:CircuitProgrammer"); } + @Override public int getTier(ItemStack var1) { return 1; } @@ -125,4 +148,92 @@ public class Circuit_Programmer extends GT_Generic_Item implements IElectricItem public double getTransferLimit(ItemStack itemStack) { return GT_Values.V[1]; } + + private static final String NBT_KEY_HAS_CHIP = "HasChip"; + private static final String NBT_KEY_CHIP_CONFIG = "ChipConfig"; + + @Override + public ModularWindow createWindow(UIBuildContext buildContext, ItemStack heldStack) { + ModularWindow.Builder builder = ModularWindow.builder(256, 166); + builder.setBackground(BW_UITextures.BACKGROUND_CIRCUIT_PROGRAMMER); + builder.bindPlayerInventory(buildContext.getPlayer(), new Pos2d(86, 83), ModularUITextures.ITEM_SLOT); + + ItemStackHandler inventoryHandler = new ItemStackHandler(1) { + @Override + public int getSlotLimit(int slot) { + return 1; + } + }; + SlotWidget circuitSlotWidget = new SlotWidget(new BaseSlot(inventoryHandler, 0) { + @Override + public void putStack(ItemStack stack) { + if (isLVCircuit(stack)) { + stack = createRealCircuit(0); + } + ((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(getSlotIndex(), stack); + this.onSlotChanged(); + } + }); + + ItemStack initialStack = null; + NBTTagCompound tag = heldStack.getTagCompound(); + if (tag != null && tag.getBoolean(NBT_KEY_HAS_CHIP)) { + initialStack = createRealCircuit(tag.getByte(NBT_KEY_CHIP_CONFIG)); + } + circuitSlotWidget.getMcSlot().putStack(initialStack); + + builder.widget(circuitSlotWidget + .setChangeListener(widget -> { + ItemStack stack = widget.getMcSlot().getStack(); + ItemStack heldItem = widget.getContext().getPlayer().getHeldItem(); + NBTTagCompound tag2 = heldItem.getTagCompound(); + if (tag2 == null) { + tag2 = new NBTTagCompound(); + } + + if (stack != null) { + tag2.setBoolean(NBT_KEY_HAS_CHIP, true); + tag2.setByte(NBT_KEY_CHIP_CONFIG, (byte) stack.getItemDamage()); + } else { + tag2.setBoolean(NBT_KEY_HAS_CHIP, false); + } + heldItem.setTagCompound(tag2); + }) + .setFilter(stack -> isProgrammedCircuit(stack) || isLVCircuit(stack)) + .setBackground(ModularUITextures.ITEM_SLOT, GT_UITextures.OVERLAY_SLOT_INT_CIRCUIT) + .setPos(122, 60)); + + for (int i = 0; i < 24; i++) { + final int index = i; + builder.widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + if (circuitSlotWidget.getMcSlot().getHasStack() + && isProgrammedCircuit( + circuitSlotWidget.getMcSlot().getStack())) { + circuitSlotWidget.getMcSlot().putStack(createRealCircuit(index + 1)); + } + }) + .setPos(32 + (i % 12) * 18, 21 + (i / 12) * 18) + .setSize(18, 18)); + } + + return builder.build(); + } + + private ItemStack createRealCircuit(int config) { + return ItemList.Circuit_Integrated.getWithDamage(1, config); + } + + private boolean isProgrammedCircuit(ItemStack stack) { + return stack.getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem()); + } + + private boolean isLVCircuit(ItemStack stack) { + return BW_Util.checkStackAndPrefix(stack) + && GT_OreDictUnificator.getAssociation(stack).mPrefix.equals(OrePrefixes.circuit) + && GT_OreDictUnificator.getAssociation(stack) + .mMaterial + .mMaterial + .equals(Materials.Basic); + } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java index c116290257..714cc51f2e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java @@ -22,10 +22,21 @@ package com.github.bartimaeusnek.bartworks.common.items; +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.screen.IItemWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.items.GT_Generic_Item; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; @@ -33,7 +44,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class GT_Destructopack_Item extends GT_Generic_Item { +public class GT_Destructopack_Item extends GT_Generic_Item implements IItemWithModularUI { public GT_Destructopack_Item() { super("GT2Destructopack", "Destructopack", "Mobile Trash Bin"); @@ -52,7 +63,7 @@ public class GT_Destructopack_Item extends GT_Generic_Item { @Override public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - aPlayer.openGui(MainMod.instance, 0, aWorld, 0, 0, 0); + GT_UIInfos.openPlayerHeldItemUI(aPlayer); return aStack; } @@ -60,4 +71,26 @@ public class GT_Destructopack_Item extends GT_Generic_Item { public void registerIcons(IIconRegister aIconRegister) { this.mIcon = aIconRegister.registerIcon("bartworks:gt.GT2Destructopack"); } + + @Override + public ModularWindow createWindow(UIBuildContext buildContext, ItemStack heldStack) { + ModularWindow.Builder builder = ModularWindow.builder(176, 166); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + builder.bindPlayerInventory(buildContext.getPlayer()); + + builder.widget(new SlotWidget(new BaseSlot(new ItemStackHandler(), 0) { + @Override + public void putStack(ItemStack stack) { + onSlotChanged(); + } + }) + .setBackground(ModularUITextures.ITEM_SLOT, BW_UITextures.OVERLAY_SLOT_CROSS) + .setPos(79, 16)) + .widget(new DrawableWidget() + .setDrawable(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT) + .setSize(17, 17) + .setPos(152, 63)); + + return builder.build(); + } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java index ec740107da..6bf5546ce6 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java @@ -25,9 +25,17 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.classic; import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; import com.github.bartimaeusnek.bartworks.API.ITileDropsContent; import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; -import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; +import com.github.bartimaeusnek.bartworks.API.modularUI.BW_UITextures; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.forge.InvWrapper; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; import java.util.Arrays; @@ -47,7 +55,7 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDropsContent, IFluidHandler, IFluidTank, - ITileWithGUI, + ITileWithModularUI, ITileAddsInformation, ITileHasDifferentTextureSides { @@ -88,7 +96,7 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity } private boolean checkPreUpdate() { - return this.worldObj.isRemote || ((this.fuelstack == null || this.fuelstack.stackSize <= 0) && this.fuel <= 0); + return (this.fuelstack == null || this.fuelstack.stackSize <= 0) && this.fuel <= 0; } private void fixUnderlflow() { @@ -117,7 +125,10 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity @Override public void updateEntity() { + if (this.worldObj.isRemote) return; + pushWaterToAdjacentTiles(); + fakestack.setStackDisplayName(outputstack.amount + "L Water"); if (checkPreUpdate()) return; fixUnderlflow(); @@ -279,11 +290,6 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity return ret; } - @Override - public int getGUIID() { - return 3; - } - @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { return 0; @@ -340,4 +346,25 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity par1IconRegister.registerIcon(MainMod.MOD_ID + ":heatedWaterPumpSide"); } } + + @Override + public ModularWindow createWindow(UIBuildContext buildContext) { + ModularWindow.Builder builder = ModularWindow.builder(176, 166); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + builder.bindPlayerInventory(buildContext.getPlayer()); + final IItemHandlerModifiable invWrapper = new InvWrapper(this); + + builder.widget(new SlotWidget(invWrapper, 0) + .setFilter(stack -> TileEntityFurnace.getItemBurnTime(stack) > 0) + .setPos(55, 52)) + .widget(SlotWidget.phantom(invWrapper, 1).disableInteraction().setPos(85, 32)) + .widget(new ProgressBar() + .setProgress(() -> (float) fuel / maxfuel) + .setTexture(BW_UITextures.PROGRESSBAR_FUEL, 14) + .setDirection(ProgressBar.Direction.UP) + .setPos(56, 36) + .setSize(14, 14)); + + return builder.build(); + } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java index 7f25dd52c2..2fcf82d36c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java @@ -22,7 +22,6 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.classic; -import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; import gregtech.api.util.GT_Utility; import java.util.ArrayList; import net.minecraft.nbt.NBTTagCompound; @@ -31,7 +30,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; -public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank, IFluidHandler, ITileWithGUI { +public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank, IFluidHandler { final ArrayList INTERNALTANKS = new ArrayList<>(); @@ -154,9 +153,4 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank } return ret; } - - @Override - public int getGUIID() { - return 4; - } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_LESU_Redux.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_LESU_Redux.java index 141cc4760c..e5a07a9505 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_LESU_Redux.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_LESU_Redux.java @@ -25,7 +25,6 @@ // import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; // import com.github.bartimaeusnek.bartworks.API.ITileDropsContent; // import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; -// import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; // import com.github.bartimaeusnek.bartworks.MainMod; // import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; // import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; @@ -51,7 +50,7 @@ // // // public class BW_TileEntity_LESU_Redux extends TileEntity implements ITileHasDifferentTextureSides, -// ITileAddsInformation, ITileWithGUI, ITileDropsContent, IEnergyConnected { +// ITileAddsInformation, ITileDropsContent, IEnergyConnected { // // public ConnectedBlocksChecker connectedcells; // public ItemStack[] circuits = new ItemStack[5]; @@ -83,11 +82,6 @@ // } //