aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/interfaces
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2022-11-26 01:45:28 +0900
committerGitHub <noreply@github.com>2022-11-25 17:45:28 +0100
commit9a2741128a78bb52eba50a631126e090a5a2abd8 (patch)
treea90f47aa94951acb4050e45dc3ed60698e79cf32 /src/main/java/gregtech/api/interfaces
parent51537482fefc4f9c6d3fbd93d119c333a63dcd7b (diff)
downloadGT5-Unofficial-9a2741128a78bb52eba50a631126e090a5a2abd8.tar.gz
GT5-Unofficial-9a2741128a78bb52eba50a631126e090a5a2abd8.tar.bz2
GT5-Unofficial-9a2741128a78bb52eba50a631126e090a5a2abd8.zip
Rewrite GUIs with ModularUI (#1381)
* Base work for ModularUI compat * Remove useless interface * Add almost all the widgets * Invert method * Refactor NEI stack placement positions * NEI handlers on ModularUI * Add some more docs * AdvDebugStructureWriter * Fix NEI progressbar not working * PrimitiveBlastFurnace * clean * derp * clean * spotlessApply * Boilers * Buffers * clean * N by N slots containers * Fix boilers not having bucket interaction Put opening UI to individual MetaTEs * Maintenance Hatch * clean * spotlessApply * Add dependency * IndustrialApiary * Adapt to ModularUI change * Base work for covers & fix crash with MP * Fix crash with server * Rewrite base work for covers * Send initial cover data on cover GUI open so that the time of showing incorrect data will be eliminated * Covers part 1 * Rename package: ModularUI -> modularui * Rename class: GT_UIInfo -> GT_UIInfos * Fix build * Covers part2 * Fix missing client check with tile UI & fix title overlap * CoverTabLine * Move cover window creators to inner class * Fix crash with null base TE * Close GUI when tile is broken * Color cover window with tile colorization * Change signature of addUIWidgets * FluidFilter cover, FluidDisplaySlotWidget, BasicTank, BasicGenerator, Output Hatch, MicrowaveEnergyTransmitter, Teleporter, DigitalChest, DigitalTank * Add title tab * Move package: modularui -> modularui/widget * Programmed circuit + IConfigurationCircuitSupport * clean * VolumetricFlask * Remove integrated circuit overlay from recipe input slots * Input Hatch & Quadruple Input Hatch * Multiblock * Deprecate old cover GUI * BasicMachines * Finish BasicMachine & NEI * Expand DTPF NEI to 9 slots * Fix ME input bus on MP * Move AESlotWidget to public class * Move GT_Recipe_Map constructors with mNEIUnificateOutput to setter method * Move SteamTexture.Variant to outer enum * Switch to remote repository * oops * Update MUI * Update MUI * Minor refactor for change amount buttons * Display items and fluids that exceed usual count * blah * use +=, why didn't I do this * Update MUI * Move ModularUI to Base (#1510) * Move ModularUI to Base * Move most of the ModularUI functionality to `BaseTileEntity` (and `CoverableTileEntity`) * `CommonMetaTileEntity` delegates ato the MetaTileEntity * Added several interfaces (with defaults) to indicate if a tile/metatile override/implement certain behaviors. * Moved `IConfigurationCircuitSupport` interface such that it will work with BaseTileEntity or a MetaTileEntity * Address reviews Co-authored-by: miozune <miozune@gmail.com> * Update MUI * Minor changes to NEI * Return :facepalm: * IGetTabIconSet override * Some more changes to NEI * Merge texture getter interfaces to new class GUITextureSet * Remove BBF structure picture as it's auto-buildable now * Make unified title tab style of texture angular * Expose some boiler texture getters for addon * Fix crash with cover GUI on pipe * Lower the number of recipe per page for DTPF & update MUI * Update MUI * Fix crash with middle-clicking slot on circuit selection GUI * Fix circuit selection window not syncing item from base machine * Merge GT_NEI_AssLineHandler into GT_NEI_DefaultHandler * Update MUI * Add in TecTech multi message * Allow changing the way of binding player inventory * Update MUI * Update MUI * Update MUI * Update MUI * Update MUI * Make MUI non-transitive to allow addons to use their own version * Force enable mixin * Format fluid amount tooltip * Add GUITextureSet.STEAM * Add guard against null ModularWindow creation * Add constructors for Muffler Hatch with inventory * Fix output slot on digital chest and tank allowing insertion * Don't log null ModularWindow * Add default implementation for IHasWorldObjectAndCoords#openGUI * Make openGTTileEntityUI accept MultiTE & cleanup Co-authored-by: Jason Mitchell <mitchej@gmail.com>
Diffstat (limited to 'src/main/java/gregtech/api/interfaces')
-rw-r--r--src/main/java/gregtech/api/interfaces/IConfigurationCircuitSupport.java (renamed from src/main/java/gregtech/api/interfaces/metatileentity/IConfigurationCircuitSupport.java)4
-rw-r--r--src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java64
-rw-r--r--src/main/java/gregtech/api/interfaces/modularui/IAddGregtechLogo.java7
-rw-r--r--src/main/java/gregtech/api/interfaces/modularui/IAddInventorySlots.java14
-rw-r--r--src/main/java/gregtech/api/interfaces/modularui/IAddUIWidgets.java8
-rw-r--r--src/main/java/gregtech/api/interfaces/modularui/IBindPlayerInventoryUI.java9
-rw-r--r--src/main/java/gregtech/api/interfaces/modularui/IGetGUITextureSet.java9
-rw-r--r--src/main/java/gregtech/api/interfaces/modularui/IGetTitleColor.java10
-rw-r--r--src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java11
-rw-r--r--src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java6
-rw-r--r--src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java12
11 files changed, 146 insertions, 8 deletions
diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IConfigurationCircuitSupport.java b/src/main/java/gregtech/api/interfaces/IConfigurationCircuitSupport.java
index 59a70b450d..b2d32b2fc4 100644
--- a/src/main/java/gregtech/api/interfaces/metatileentity/IConfigurationCircuitSupport.java
+++ b/src/main/java/gregtech/api/interfaces/IConfigurationCircuitSupport.java
@@ -1,11 +1,11 @@
-package gregtech.api.interfaces.metatileentity;
+package gregtech.api.interfaces;
import gregtech.api.GregTech_API;
import java.util.List;
import net.minecraft.item.ItemStack;
/**
- * Implement this interface if your metatileentity supports configuration circuits
+ * Implement this interface if your tileentity (or metatileentity) supports configuration circuits
* to resolve recipe conflicts.
*/
public interface IConfigurationCircuitSupport {
diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java
index 29b0a56a89..59d048e618 100644
--- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java
+++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java
@@ -1,14 +1,18 @@
package gregtech.api.interfaces.metatileentity;
+import com.gtnewhorizons.modularui.api.forge.ItemStackHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.enums.Dyes;
import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.modularui.IGetGUITextureSet;
import gregtech.api.interfaces.tileentity.IGearEnergyTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.interfaces.tileentity.IGregtechWailaProvider;
import gregtech.api.interfaces.tileentity.IMachineBlockUpdateable;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.GT_Config;
+import gregtech.api.util.GT_Util;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -38,7 +42,8 @@ public interface IMetaTileEntity
IFluidHandler,
IGearEnergyTileEntity,
IMachineBlockUpdateable,
- IGregtechWailaProvider {
+ IGregtechWailaProvider,
+ IGetGUITextureSet {
/**
* This determines the BaseMetaTileEntity belonging to this MetaTileEntity by using the Meta ID of the Block itself.
* <p/>
@@ -193,13 +198,28 @@ public interface IMetaTileEntity
/**
* @return the Server Side Container
+ * @deprecated Use ModularUI
*/
- Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity);
+ @Deprecated
+ default Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ throw new UnsupportedOperationException();
+ }
/**
* @return the Client Side GUI Container
+ * @deprecated Use ModularUI
+ */
+ @Deprecated
+ default Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * For back compatibility, you need to override this if this MetaTileEntity uses ModularUI.
*/
- Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity);
+ default boolean useModularUI() {
+ return false;
+ }
/**
* From new ISidedInventory
@@ -406,6 +426,17 @@ public interface IMetaTileEntity
void onColorChangeClient(byte aColor);
+ /**
+ * @return Actual color shown on GUI
+ */
+ default int getGUIColorization() {
+ if (getBaseMetaTileEntity() != null) {
+ return getBaseMetaTileEntity().getGUIColorization();
+ } else {
+ return GT_Util.getRGBInt(Dyes.MACHINE_METAL.getRGBA());
+ }
+ }
+
int getLightOpacity();
boolean allowGeneralRedstoneOutput();
@@ -461,4 +492,31 @@ public interface IMetaTileEntity
default void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) {
/* do nothing */
}
+
+ default int getGUIWidth() {
+ return 176;
+ }
+
+ default int getGUIHeight() {
+ return 166;
+ }
+
+ /*
+ * ModularUI Support
+ */
+ default ItemStackHandler getInventoryHandler() {
+ return null;
+ }
+
+ default String getLocalName() {
+ return "Unknown";
+ }
+
+ default boolean doesBindPlayerInventory() {
+ return true;
+ }
+
+ default int getTextColorOrDefault(String textType, int defaultColor) {
+ return defaultColor;
+ }
}
diff --git a/src/main/java/gregtech/api/interfaces/modularui/IAddGregtechLogo.java b/src/main/java/gregtech/api/interfaces/modularui/IAddGregtechLogo.java
new file mode 100644
index 0000000000..d90d310dc8
--- /dev/null
+++ b/src/main/java/gregtech/api/interfaces/modularui/IAddGregtechLogo.java
@@ -0,0 +1,7 @@
+package gregtech.api.interfaces.modularui;
+
+import com.gtnewhorizons.modularui.api.screen.ModularWindow;
+
+public interface IAddGregtechLogo {
+ default void addGregTechLogo(ModularWindow.Builder builder) {}
+}
diff --git a/src/main/java/gregtech/api/interfaces/modularui/IAddInventorySlots.java b/src/main/java/gregtech/api/interfaces/modularui/IAddInventorySlots.java
new file mode 100644
index 0000000000..70e33aa2c8
--- /dev/null
+++ b/src/main/java/gregtech/api/interfaces/modularui/IAddInventorySlots.java
@@ -0,0 +1,14 @@
+package gregtech.api.interfaces.modularui;
+
+import com.gtnewhorizons.modularui.api.drawable.IDrawable;
+import com.gtnewhorizons.modularui.api.screen.ModularWindow;
+
+public interface IAddInventorySlots {
+ default void add1by1Slot(ModularWindow.Builder builder, IDrawable... background) {}
+
+ default void add2by2Slots(ModularWindow.Builder builder, IDrawable... background) {}
+
+ default void add3by3Slots(ModularWindow.Builder builder, IDrawable... background) {}
+
+ default void add4by4Slots(ModularWindow.Builder builder, IDrawable... background) {}
+}
diff --git a/src/main/java/gregtech/api/interfaces/modularui/IAddUIWidgets.java b/src/main/java/gregtech/api/interfaces/modularui/IAddUIWidgets.java
new file mode 100644
index 0000000000..7b70fd724c
--- /dev/null
+++ b/src/main/java/gregtech/api/interfaces/modularui/IAddUIWidgets.java
@@ -0,0 +1,8 @@
+package gregtech.api.interfaces.modularui;
+
+import com.gtnewhorizons.modularui.api.screen.ModularWindow;
+import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
+
+public interface IAddUIWidgets {
+ default void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) {}
+}
diff --git a/src/main/java/gregtech/api/interfaces/modularui/IBindPlayerInventoryUI.java b/src/main/java/gregtech/api/interfaces/modularui/IBindPlayerInventoryUI.java
new file mode 100644
index 0000000000..426a24ad38
--- /dev/null
+++ b/src/main/java/gregtech/api/interfaces/modularui/IBindPlayerInventoryUI.java
@@ -0,0 +1,9 @@
+package gregtech.api.interfaces.modularui;
+
+import com.gtnewhorizons.modularui.api.screen.ModularWindow;
+import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
+
+public interface IBindPlayerInventoryUI {
+
+ void bindPlayerInventoryUI(ModularWindow.Builder builder, UIBuildContext buildContext);
+}
diff --git a/src/main/java/gregtech/api/interfaces/modularui/IGetGUITextureSet.java b/src/main/java/gregtech/api/interfaces/modularui/IGetGUITextureSet.java
new file mode 100644
index 0000000000..409523b008
--- /dev/null
+++ b/src/main/java/gregtech/api/interfaces/modularui/IGetGUITextureSet.java
@@ -0,0 +1,9 @@
+package gregtech.api.interfaces.modularui;
+
+import gregtech.api.gui.modularui.GUITextureSet;
+
+public interface IGetGUITextureSet {
+ default GUITextureSet getGUITextureSet() {
+ return null;
+ }
+}
diff --git a/src/main/java/gregtech/api/interfaces/modularui/IGetTitleColor.java b/src/main/java/gregtech/api/interfaces/modularui/IGetTitleColor.java
new file mode 100644
index 0000000000..a1f79d1568
--- /dev/null
+++ b/src/main/java/gregtech/api/interfaces/modularui/IGetTitleColor.java
@@ -0,0 +1,10 @@
+package gregtech.api.interfaces.modularui;
+
+import gregtech.api.enums.Dyes;
+import gregtech.api.util.GT_Util;
+
+public interface IGetTitleColor {
+ default int getTitleColor() {
+ return GT_Util.getRGBaInt(Dyes.dyeWhite.getRGBA());
+ }
+}
diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java
index ddbb550dfc..3bcf441128 100644
--- a/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java
+++ b/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java
@@ -1,5 +1,8 @@
package gregtech.api.interfaces.tileentity;
+import gregtech.api.enums.Dyes;
+import gregtech.api.util.GT_Util;
+
public interface IColoredTileEntity {
/**
* @return 0 - 15 are Colors, while -1 means uncolored
@@ -12,4 +15,12 @@ public interface IColoredTileEntity {
* @param aColor the Color you want to set it to. -1 for reset.
*/
byte setColorization(byte aColor);
+
+ /**
+ * @return Actual color shown on GUI
+ */
+ default int getGUIColorization() {
+ return GT_Util.getRGBInt(
+ (getColorization() != -1 ? Dyes.get(getColorization()) : Dyes.MACHINE_METAL).getRGBA());
+ }
}
diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java
index ad2af44e9e..b389c8be6c 100644
--- a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java
+++ b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java
@@ -4,6 +4,8 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.interfaces.IDescribable;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.modularui.IAddInventorySlots;
+import gregtech.api.interfaces.modularui.IGetGUITextureSet;
import gregtech.common.blocks.GT_Block_Machines;
import java.util.ArrayList;
import java.util.List;
@@ -34,7 +36,9 @@ public interface IGregTechTileEntity
IDigitalChest,
IDescribable,
IMachineBlockUpdateable,
- IGregtechWailaProvider {
+ IGregtechWailaProvider,
+ IGetGUITextureSet,
+ IAddInventorySlots {
/**
* gets the Error displayed on the GUI
*/
diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java b/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java
index 2464816045..7f31d17d11 100644
--- a/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java
+++ b/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java
@@ -164,11 +164,19 @@ public interface IHasWorldObjectAndCoords {
/**
* Opens the GUI with this ID of this MetaTileEntity
+ * @deprecated Use ModularUI
*/
- boolean openGUI(EntityPlayer aPlayer, int aID);
+ @Deprecated
+ default boolean openGUI(EntityPlayer aPlayer, int aID) {
+ return false;
+ }
/**
* Opens the GUI with the ID = 0 of this TileEntity
+ * @deprecated Use ModularUI
*/
- boolean openGUI(EntityPlayer aPlayer);
+ @Deprecated
+ default boolean openGUI(EntityPlayer aPlayer) {
+ return false;
+ }
}