diff options
author | miozune <miozune@gmail.com> | 2022-11-26 01:45:28 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-25 17:45:28 +0100 |
commit | 9a2741128a78bb52eba50a631126e090a5a2abd8 (patch) | |
tree | a90f47aa94951acb4050e45dc3ed60698e79cf32 /src/main/java/gregtech/api/net | |
parent | 51537482fefc4f9c6d3fbd93d119c333a63dcd7b (diff) | |
download | GT5-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/net')
3 files changed, 36 insertions, 38 deletions
diff --git a/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java b/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java index 9f32ad4bae..62ff6bd7e9 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java +++ b/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java @@ -2,6 +2,7 @@ package gregtech.api.net; import com.google.common.io.ByteArrayDataInput; import gregtech.api.enums.GT_Values; +import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.common.GT_Proxy; import io.netty.buffer.ByteBuf; @@ -103,7 +104,11 @@ public class GT_Packet_GtTileEntityGuiRequest extends GT_Packet_New { parentGuiId); GT_Values.NW.sendToPlayer(packet, player); } else if (guiId == 0) { - gtTile.openGUI(player); + if (gtTile.getMetaTileEntity() != null && gtTile.getMetaTileEntity().useModularUI()) { + GT_UIInfos.openGTTileEntityUI(gtTile, player); + } else { + gtTile.openGUI(player); + } } } } diff --git a/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit.java b/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit.java index 0561b18ac1..eff095b0fc 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit.java +++ b/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit.java @@ -2,9 +2,10 @@ package gregtech.api.net; import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.common.network.ByteBufUtils; -import gregtech.api.interfaces.metatileentity.IConfigurationCircuitSupport; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.IConfigurationCircuitSupport; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IHasInventory; +import gregtech.api.metatileentity.BaseTileEntity; import gregtech.api.util.GT_Utility; import gregtech.api.util.ISerializableObject; import io.netty.buffer.ByteBuf; @@ -35,6 +36,10 @@ public class GT_Packet_SetConfigurationCircuit extends GT_Packet_New { this(tile.getXCoord(), tile.getYCoord(), tile.getZCoord(), circuit); } + public GT_Packet_SetConfigurationCircuit(BaseTileEntity tile, ItemStack circuit) { + this(tile.getXCoord(), tile.getYCoord(), tile.getZCoord(), circuit); + } + public GT_Packet_SetConfigurationCircuit(int x, short y, int z, ItemStack circuit) { super(false); @@ -84,18 +89,18 @@ public class GT_Packet_SetConfigurationCircuit extends GT_Packet_New { @Override public void process(IBlockAccess aWorld) { - World world = DimensionManager.getWorld(dimId); + final World world = DimensionManager.getWorld(dimId); if (world == null) return; - TileEntity tile = world.getTileEntity(mX, mY, mZ); - if (!(tile instanceof IGregTechTileEntity) || ((IGregTechTileEntity) tile).isDead()) return; - IMetaTileEntity mte = ((IGregTechTileEntity) tile).getMetaTileEntity(); - if (!(mte instanceof IConfigurationCircuitSupport)) return; - IConfigurationCircuitSupport machine = (IConfigurationCircuitSupport) mte; + + final TileEntity tile = world.getTileEntity(mX, mY, mZ); + if (!(tile instanceof BaseTileEntity) || ((BaseTileEntity) tile).isDead()) return; + + final IConfigurationCircuitSupport machine = ((BaseTileEntity) tile).getConfigurationCircuitSupport(); + if (machine == null) return; if (!machine.allowSelectCircuit()) return; machine.getConfigurationCircuits().stream() .filter(stack -> GT_Utility.areStacksEqual(stack, circuit)) .findFirst() - .ifPresent(stack -> - ((IGregTechTileEntity) tile).setInventorySlotContents(machine.getCircuitSlot(), stack)); + .ifPresent(stack -> ((IHasInventory) tile).setInventorySlotContents(machine.getCircuitSlot(), stack)); } } diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java index e190648bef..65194a7390 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java +++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java @@ -188,35 +188,23 @@ public class GT_Packet_TileEntityCoverGUI extends GT_Packet_New { IGregTechTileEntity gtTile = ((IGregTechTileEntity) tile); gtTile.setCoverDataAtSide(side, coverData); // Set it client side to read later. - GuiScreen gui = (GuiScreen) getCoverGUI(side, thePlayer, thePlayer.worldObj, gtTile); - // If it's one of this mod's covers, tell it to exit to the GUI with the specified ID (-1 is ignored) - if (gui instanceof GT_GUICover) { - ((GT_GUICover) gui).setParentGuiId(parentGuiId); + GT_CoverBehaviorBase<?> cover = gtTile.getCoverBehaviorAtSideNew(side); + if (cover.hasCoverGUI()) { + GuiScreen gui = (GuiScreen) cover.getClientGUI( + side, + gtTile.getCoverIDAtSide(side), + gtTile.getComplexCoverDataAtSide(side), + gtTile, + thePlayer, + thePlayer.worldObj); + // If it's one of this mod's covers, tell it to exit to the GUI with the specified ID (-1 is + // ignored) + if (gui instanceof GT_GUICover) { + ((GT_GUICover) gui).setParentGuiId(parentGuiId); + } + Minecraft.getMinecraft().displayGuiScreen(gui); } - Minecraft.getMinecraft().displayGuiScreen(gui); } } } - - /** - * Gets the specified cover's GUI object, if one exists - * @param aSide Block side (0 through 5) - * @param aPlayer Current player - * @param aWorld Current world - * @param aGtTile IGregTechTileEntity instance - * @return The specified cover's GUI, if one exists - */ - private Object getCoverGUI(byte aSide, EntityPlayer aPlayer, World aWorld, IGregTechTileEntity aGtTile) { - GT_CoverBehaviorBase<?> cover = aGtTile.getCoverBehaviorAtSideNew(aSide); - if (cover.hasCoverGUI()) { - return cover.getClientGUI( - aSide, - aGtTile.getCoverIDAtSide(aSide), - aGtTile.getComplexCoverDataAtSide(aSide), - aGtTile, - aPlayer, - aWorld); - } - return null; - } } |