From 1f4e765ab2830698a0039947bfe4926b193c4b43 Mon Sep 17 00:00:00 2001 From: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Date: Sat, 23 Sep 2023 16:51:24 +0300 Subject: [PATCH 1/7] some docs on a few methods --- .../java/gregtech/api/logic/FluidInventoryLogic.java | 11 ++++++++++- .../java/gregtech/api/logic/ItemInventoryLogic.java | 6 ++++++ .../java/gregtech/api/logic/MuTEProcessingLogic.java | 12 ++++++++++++ .../java/gregtech/api/logic/ProcessingLogic.java | 5 +++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/logic/FluidInventoryLogic.java b/src/main/java/gregtech/api/logic/FluidInventoryLogic.java index d5b82538690..88c0c954ec9 100644 --- a/src/main/java/gregtech/api/logic/FluidInventoryLogic.java +++ b/src/main/java/gregtech/api/logic/FluidInventoryLogic.java @@ -240,12 +240,21 @@ public Map getMapOfStoredFluids() { return map; } + /** + * Return a scrollable widget with only the inventory. + */ + @Nonnull public Widget getGuiPart() { return getGUIPart(DEFAULT_COLUMNS_PER_ROW); } + /** + * Return a scrollable widget with only the inventory. + */ + @Nonnull public Widget getGUIPart(int columnsPerRow) { - final Scrollable scrollable = new Scrollable().setVerticalScroll(); + final Scrollable scrollable = new Scrollable(); + scrollable.setVerticalScroll(); for (int rows = 0; rows * 4 < inventory.getTanks(); rows++) { final int columnsToMake = Math.min(inventory.getTanks() - rows * 4, 4); for (int column = 0; column < columnsToMake; column++) { diff --git a/src/main/java/gregtech/api/logic/ItemInventoryLogic.java b/src/main/java/gregtech/api/logic/ItemInventoryLogic.java index 13fb8fe3a88..69005216b84 100644 --- a/src/main/java/gregtech/api/logic/ItemInventoryLogic.java +++ b/src/main/java/gregtech/api/logic/ItemInventoryLogic.java @@ -239,11 +239,17 @@ public void update(boolean shouldSort) { } } + /** + * Return a scrollable widget with only the inventory. + */ @Nonnull public Widget getGuiPart() { return getGUIPart(DEFAULT_COLUMNS_PER_ROW); } + /** + * Return a scrollable widget with only the inventory. + */ @Nonnull public Widget getGUIPart(int columnsPerRow) { final Scrollable scrollable = new Scrollable(); diff --git a/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java b/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java index ae3abcc9e4b..50501ad7203 100644 --- a/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java +++ b/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java @@ -10,6 +10,10 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.Scrollable; + import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -251,5 +255,13 @@ public void loadFromNBT(@Nonnull NBTTagCompound logicNBT) { } } + /** + * Returns a gui part, which will be displayed in a separate tab on the machine's gui. + */ + @Nonnull + public Widget getGUIPart(ModularWindow.Builder builder) { + return new Scrollable(); + } + // #endregion } diff --git a/src/main/java/gregtech/api/logic/ProcessingLogic.java b/src/main/java/gregtech/api/logic/ProcessingLogic.java index 61cf2599ec8..3ac7f286b2a 100644 --- a/src/main/java/gregtech/api/logic/ProcessingLogic.java +++ b/src/main/java/gregtech/api/logic/ProcessingLogic.java @@ -5,6 +5,11 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.Scrollable; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; From 3dad8d79ac086c932fc84994c77a8ff00a0ef98a Mon Sep 17 00:00:00 2001 From: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Date: Mon, 25 Sep 2023 21:03:16 +0300 Subject: [PATCH 2/7] innitial GUI class --- src/main/java/gregtech/api/gui/GUIHost.java | 31 ++++++++++++++++ .../java/gregtech/api/gui/GUIProvider.java | 37 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/main/java/gregtech/api/gui/GUIHost.java create mode 100644 src/main/java/gregtech/api/gui/GUIProvider.java diff --git a/src/main/java/gregtech/api/gui/GUIHost.java b/src/main/java/gregtech/api/gui/GUIHost.java new file mode 100644 index 00000000000..b3c40efd5ff --- /dev/null +++ b/src/main/java/gregtech/api/gui/GUIHost.java @@ -0,0 +1,31 @@ +package gregtech.api.gui; + +import java.util.Objects; + +import javax.annotation.Nonnull; + +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; + +public interface GUIHost> extends ITileWithModularUI { + + @Nonnull + @Override + default ModularWindow createWindow(UIBuildContext uiContext) { + GUIProvider gui = getGUI(); + return gui.openGUI(Objects.requireNonNull(uiContext)); + } + + default int getWidth() { + return 170; + } + + default int getHeight() { + return 100; + } + + @Nonnull + GUIProvider getGUI(); + +} diff --git a/src/main/java/gregtech/api/gui/GUIProvider.java b/src/main/java/gregtech/api/gui/GUIProvider.java new file mode 100644 index 00000000000..5acc67de9ae --- /dev/null +++ b/src/main/java/gregtech/api/gui/GUIProvider.java @@ -0,0 +1,37 @@ +package gregtech.api.gui; + +import java.util.Objects; + +import javax.annotation.Nonnull; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; + +public abstract class GUIProvider> { + + protected final T host; + + public GUIProvider(T host) { + this.host = host; + } + + @Nonnull + public ModularWindow openGUI(@Nonnull UIBuildContext uiContext) { + Builder builder = Objects.requireNonNull(ModularWindow.builder(host.getWidth(), host.getHeight())); + if (shouldBindPlayerInventory()) { + builder.bindPlayerInventory(uiContext.getPlayer()); + } + attachSynchHandlers(builder, uiContext); + addWidgets(builder, uiContext); + return Objects.requireNonNull(builder.build()); + } + + protected abstract void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext); + + protected abstract void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext); + + protected boolean shouldBindPlayerInventory() { + return true; + } +} From 39e5b136e7c03dcbfb63ca11499a0d14e23a6185 Mon Sep 17 00:00:00 2001 From: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Date: Mon, 25 Sep 2023 22:49:22 +0300 Subject: [PATCH 3/7] try to implement guis --- src/main/java/gregtech/api/gui/GUIHost.java | 6 ++-- .../java/gregtech/api/gui/GUIProvider.java | 4 +-- .../api/logic/MuTEProcessingLogic.java | 10 +++--- .../gregtech/api/logic/ProcessingLogic.java | 5 --- .../api/metatileentity/BaseTileEntity.java | 23 ------------- .../metatileentity/CommonMetaTileEntity.java | 23 +++++++++++++ .../machine/MultiTileBasicMachine.java | 15 +++++++-- .../base/ComplexParallelController.java | 4 +-- .../multiblock/base/Controller.java | 12 +++---- .../multiblock/base/StackableController.java | 4 +-- .../base/StackableModularController.java | 4 +-- .../common/gui/MachineGUIProvider.java | 33 +++++++++++++++++++ 12 files changed, 91 insertions(+), 52 deletions(-) create mode 100644 src/main/java/gregtech/common/gui/MachineGUIProvider.java diff --git a/src/main/java/gregtech/api/gui/GUIHost.java b/src/main/java/gregtech/api/gui/GUIHost.java index b3c40efd5ff..96eb6ddd9cb 100644 --- a/src/main/java/gregtech/api/gui/GUIHost.java +++ b/src/main/java/gregtech/api/gui/GUIHost.java @@ -13,8 +13,8 @@ public interface GUIHost> extends ITileWithModularUI { @Nonnull @Override default ModularWindow createWindow(UIBuildContext uiContext) { - GUIProvider gui = getGUI(); - return gui.openGUI(Objects.requireNonNull(uiContext)); + GUIProvider gui = getGUI(); + return gui.openGUI(Objects.requireNonNull(uiContext)); } default int getWidth() { @@ -27,5 +27,5 @@ default int getHeight() { @Nonnull GUIProvider getGUI(); - + } diff --git a/src/main/java/gregtech/api/gui/GUIProvider.java b/src/main/java/gregtech/api/gui/GUIProvider.java index 5acc67de9ae..53f01efdef6 100644 --- a/src/main/java/gregtech/api/gui/GUIProvider.java +++ b/src/main/java/gregtech/api/gui/GUIProvider.java @@ -5,11 +5,11 @@ import javax.annotation.Nonnull; import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; public abstract class GUIProvider> { - + protected final T host; public GUIProvider(T host) { diff --git a/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java b/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java index 50501ad7203..98e4af73b9b 100644 --- a/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java +++ b/src/main/java/gregtech/api/logic/MuTEProcessingLogic.java @@ -10,15 +10,15 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.widget.Widget; -import com.gtnewhorizons.modularui.common.widget.Scrollable; - import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.fluids.FluidStack; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.Scrollable; + import gregtech.api.enums.InventoryType; import gregtech.api.logic.interfaces.ProcessingLogicHost; import gregtech.api.recipe.check.CheckRecipeResult; @@ -255,7 +255,7 @@ public void loadFromNBT(@Nonnull NBTTagCompound logicNBT) { } } - /** + /** * Returns a gui part, which will be displayed in a separate tab on the machine's gui. */ @Nonnull diff --git a/src/main/java/gregtech/api/logic/ProcessingLogic.java b/src/main/java/gregtech/api/logic/ProcessingLogic.java index 3ac7f286b2a..61cf2599ec8 100644 --- a/src/main/java/gregtech/api/logic/ProcessingLogic.java +++ b/src/main/java/gregtech/api/logic/ProcessingLogic.java @@ -5,11 +5,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; -import com.gtnewhorizons.modularui.api.widget.Widget; -import com.gtnewhorizons.modularui.common.widget.Scrollable; - import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java index 957ba6ff133..b78d62b043e 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java @@ -603,29 +603,6 @@ public boolean useModularUI() { return false; } - @Override - public ModularWindow createWindow(UIBuildContext buildContext) { - if (!useModularUI()) return null; - - buildContext.setValidator(getValidator()); - final ModularWindow.Builder builder = ModularWindow.builder(getGUIWidth(), getGUIHeight()); - builder.setBackground(getGUITextureSet().getMainBackground()); - builder.setGuiTint(getGUIColorization()); - if (doesBindPlayerInventory()) { - bindPlayerInventoryUI(builder, buildContext); - } - addUIWidgets(builder, buildContext); - addTitleToUI(builder); - addCoverTabs(builder, buildContext); - final IConfigurationCircuitSupport csc = getConfigurationCircuitSupport(); - if (csc != null && csc.allowSelectCircuit()) { - addConfigurationCircuitSlot(builder); - } else { - addGregTechLogo(builder); - } - return builder.build(); - } - /* * IC2 Energy Compat */ diff --git a/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java index acb3e75235a..5a2e88b2420 100644 --- a/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java @@ -314,4 +314,27 @@ public GUITextureSet getGUITextureSet() { public ItemStack getMachineCraftingIcon() { return getMetaTileEntity() != null ? getMetaTileEntity().getMachineCraftingIcon() : null; } + + @Override + public ModularWindow createWindow(UIBuildContext buildContext) { + if (!useModularUI()) return null; + + buildContext.setValidator(getValidator()); + final ModularWindow.Builder builder = ModularWindow.builder(getGUIWidth(), getGUIHeight()); + builder.setBackground(getGUITextureSet().getMainBackground()); + builder.setGuiTint(getGUIColorization()); + if (doesBindPlayerInventory()) { + bindPlayerInventoryUI(builder, buildContext); + } + addUIWidgets(builder, buildContext); + addTitleToUI(builder); + addCoverTabs(builder, buildContext); + final IConfigurationCircuitSupport csc = getConfigurationCircuitSupport(); + if (csc != null && csc.allowSelectCircuit()) { + addConfigurationCircuitSlot(builder); + } else { + addGregTechLogo(builder); + } + return builder.build(); + } } diff --git a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java index fbacb8944c5..d295b870b13 100644 --- a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java +++ b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java @@ -32,6 +32,8 @@ import gregtech.api.enums.*; import gregtech.api.enums.GT_Values.NBT; import gregtech.api.enums.Textures.BlockIcons.CustomIcon; +import gregtech.api.gui.GUIHost; +import gregtech.api.gui.GUIProvider; import gregtech.api.interfaces.ITexture; import gregtech.api.logic.FluidInventoryLogic; import gregtech.api.logic.ItemInventoryLogic; @@ -48,9 +50,10 @@ import gregtech.api.task.tasks.ProcessingTask; import gregtech.api.util.GT_Utility; import gregtech.client.GT_SoundLoop; +import gregtech.common.gui.MachineGUIProvider; -public abstract class MultiTileBasicMachine

> extends TickableMultiTileEntity - implements IMultiTileMachine, ProcessingLogicHost

, PowerLogicHost { +public abstract class MultiTileBasicMachine

, G extends GUIHost & ProcessingLogicHost

& PowerLogicHost> + extends TickableMultiTileEntity implements IMultiTileMachine, ProcessingLogicHost

, PowerLogicHost, GUIHost { protected static final int ACTIVE = B[0]; protected static final int TICKS_BETWEEN_RECIPE_CHECKS = 5 * TickTime.SECOND; @@ -92,6 +95,8 @@ public abstract class MultiTileBasicMachine

> ex protected boolean processingUpdate = false; @Nonnull protected PowerLogic power = createPowerLogic(); + @Nonnull + protected GUIProvider guiProvider = createGUIProvider(); @SideOnly(Side.CLIENT) protected GT_SoundLoop activitySoundLoop; @@ -772,4 +777,10 @@ protected PowerLogic createPowerLogic() { return new PowerLogic().setMaxAmperage(1) .setType(PowerLogic.RECEIVER); } + + // @SuppressWarnings("unchecked") + @Nonnull + protected GUIProvider createGUIProvider() { + return new MachineGUIProvider(this); + } } diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/ComplexParallelController.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/ComplexParallelController.java index 08c65c1d17a..779037eb7e4 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/ComplexParallelController.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/ComplexParallelController.java @@ -18,8 +18,8 @@ import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; -public abstract class ComplexParallelController, P extends ComplexParallelProcessingLogic

> - extends Controller { +public abstract class ComplexParallelController, P extends ComplexParallelProcessingLogic

> + extends Controller { protected int maxComplexParallels = 0; protected int currentComplexParallels = 0; diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java index def59d2f656..8be9d467879 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java @@ -87,9 +87,9 @@ /** * Multi Tile Entities - or MuTEs - don't have dedicated hatches, but their casings can become hatches. */ -public abstract class Controller, P extends MuTEProcessingLogic

> - extends MultiTileBasicMachine

implements IAlignment, IMultiBlockController, IDescribable, IMTE_AddToolTips, - ISurvivalConstructable, ControllerWithOptionalFeatures { +public abstract class Controller, P extends MuTEProcessingLogic

> + extends MultiTileBasicMachine> implements IAlignment, IMultiBlockController, IDescribable, + IMTE_AddToolTips, ISurvivalConstructable, ControllerWithOptionalFeatures { public static final String ALL_INVENTORIES_NAME = "all"; protected static final int AUTO_OUTPUT_FREQUENCY_TICK = 20; @@ -157,7 +157,7 @@ public Controller() { * other instances, even for those of the same class. */ @Override - public abstract IStructureDefinition getStructureDefinition(); + public abstract IStructureDefinition getStructureDefinition(); /** * Checks the Machine. @@ -392,8 +392,8 @@ protected final Integer survivalBuildPiece(String piece, ItemStack trigger, int } @SuppressWarnings("unchecked") - private IStructureDefinition> getCastedStructureDefinition() { - return (IStructureDefinition>) getStructureDefinition(); + private IStructureDefinition> getCastedStructureDefinition() { + return (IStructureDefinition>) getStructureDefinition(); } @Override diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/StackableController.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/StackableController.java index 93d67d620c5..51feb363dd2 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/StackableController.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/StackableController.java @@ -6,8 +6,8 @@ import gregtech.api.logic.MuTEProcessingLogic; -public abstract class StackableController, P extends MuTEProcessingLogic

> - extends Controller { +public abstract class StackableController, P extends MuTEProcessingLogic

> + extends Controller { protected static String STACKABLE_STOP = "STACKABLE_STOP"; protected static String STACKABLE_MIDDLE = "STACKABLE_MIDDLE"; diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/StackableModularController.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/StackableModularController.java index 0595936ddcc..1dfd4971510 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/StackableModularController.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/StackableModularController.java @@ -10,8 +10,8 @@ import gregtech.api.multitileentity.interfaces.UpgradableModularMuTE; import gregtech.api.util.GT_StructureUtilityMuTE.UpgradeCasings; -public abstract class StackableModularController, P extends MuTEProcessingLogic

> - extends StackableController implements UpgradableModularMuTE { +public abstract class StackableModularController, P extends MuTEProcessingLogic

> + extends StackableController implements UpgradableModularMuTE { protected double durationMultiplier = 1; protected double euTickMultiplier = 1; diff --git a/src/main/java/gregtech/common/gui/MachineGUIProvider.java b/src/main/java/gregtech/common/gui/MachineGUIProvider.java new file mode 100644 index 00000000000..d019eae4b89 --- /dev/null +++ b/src/main/java/gregtech/common/gui/MachineGUIProvider.java @@ -0,0 +1,33 @@ +package gregtech.common.gui; + +import javax.annotation.Nonnull; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; + +import gregtech.api.gui.GUIHost; +import gregtech.api.gui.GUIProvider; +import gregtech.api.logic.MuTEProcessingLogic; +import gregtech.api.logic.interfaces.PowerLogicHost; +import gregtech.api.logic.interfaces.ProcessingLogicHost; + +public class MachineGUIProvider & ProcessingLogicHost> & PowerLogicHost> + extends GUIProvider { + + public MachineGUIProvider(G host) { + super(host); + } + + @Override + protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'attachSynchHandlers'"); + } + + @Override + protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'addWidgets'"); + } + +} From 8090cadd42f6b866b3303ad5dab9aaa328ae002d Mon Sep 17 00:00:00 2001 From: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Date: Mon, 25 Sep 2023 23:16:12 +0300 Subject: [PATCH 4/7] almost working - fix comflict --- src/main/java/gregtech/api/gui/GUIHost.java | 6 +-- .../java/gregtech/api/gui/GUIProvider.java | 5 ++- .../interfaces/IMultiBlockController.java | 6 ++- .../machine/MultiTileBasicMachine.java | 17 +++++--- .../multiblock/base/Controller.java | 7 +--- .../multiblock/base/MultiBlockPart.java | 42 +++++++++++-------- .../common/gui/MachineGUIProvider.java | 6 +-- .../gregtech/common/gui/PartGUIProvider.java | 32 ++++++++++++++ 8 files changed, 83 insertions(+), 38 deletions(-) create mode 100644 src/main/java/gregtech/common/gui/PartGUIProvider.java diff --git a/src/main/java/gregtech/api/gui/GUIHost.java b/src/main/java/gregtech/api/gui/GUIHost.java index 96eb6ddd9cb..dabeede67d3 100644 --- a/src/main/java/gregtech/api/gui/GUIHost.java +++ b/src/main/java/gregtech/api/gui/GUIHost.java @@ -8,12 +8,12 @@ import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -public interface GUIHost> extends ITileWithModularUI { +public interface GUIHost extends ITileWithModularUI { @Nonnull @Override default ModularWindow createWindow(UIBuildContext uiContext) { - GUIProvider gui = getGUI(); + GUIProvider gui = getGUI(); return gui.openGUI(Objects.requireNonNull(uiContext)); } @@ -26,6 +26,6 @@ default int getHeight() { } @Nonnull - GUIProvider getGUI(); + GUIProvider getGUI(); } diff --git a/src/main/java/gregtech/api/gui/GUIProvider.java b/src/main/java/gregtech/api/gui/GUIProvider.java index 53f01efdef6..6fec4aa52af 100644 --- a/src/main/java/gregtech/api/gui/GUIProvider.java +++ b/src/main/java/gregtech/api/gui/GUIProvider.java @@ -8,11 +8,12 @@ import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -public abstract class GUIProvider> { +public abstract class GUIProvider { + @Nonnull protected final T host; - public GUIProvider(T host) { + public GUIProvider(@Nonnull T host) { this.host = host; } diff --git a/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java b/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java index 435fecdc73e..4423b32d181 100644 --- a/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java +++ b/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java @@ -12,6 +12,8 @@ import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import gregtech.api.enums.InventoryType; +import gregtech.api.gui.GUIHost; +import gregtech.api.gui.GUIProvider; import gregtech.api.logic.FluidInventoryLogic; import gregtech.api.logic.ItemInventoryLogic; import gregtech.api.logic.interfaces.FluidInventoryLogicHost; @@ -20,7 +22,7 @@ import gregtech.api.multitileentity.enums.MultiTileCasingPurpose; public interface IMultiBlockController - extends IMultiTileEntity, FluidInventoryLogicHost, ItemInventoryLogicHost, UpgradableMuTE, PowerLogicHost { + extends IMultiTileEntity, FluidInventoryLogicHost, ItemInventoryLogicHost, UpgradableMuTE, PowerLogicHost, GUIHost { boolean checkStructure(boolean aForceReset); @@ -40,6 +42,8 @@ public interface IMultiBlockController ModularWindow createWindowGUI(UIBuildContext buildContext); + PowerLogic getPowerLogic(); + UUID registerItemInventory(int slots, int tier, @Nonnull InventoryType type, boolean isUpgradeInventory); ItemInventoryLogic unregisterItemInventory(@Nonnull UUID id, @Nonnull InventoryType type); diff --git a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java index d295b870b13..3afcbdccce5 100644 --- a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java +++ b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java @@ -52,8 +52,8 @@ import gregtech.client.GT_SoundLoop; import gregtech.common.gui.MachineGUIProvider; -public abstract class MultiTileBasicMachine

, G extends GUIHost & ProcessingLogicHost

& PowerLogicHost> - extends TickableMultiTileEntity implements IMultiTileMachine, ProcessingLogicHost

, PowerLogicHost, GUIHost { +public abstract class MultiTileBasicMachine

> + extends TickableMultiTileEntity implements IMultiTileMachine, ProcessingLogicHost

, PowerLogicHost, GUIHost { protected static final int ACTIVE = B[0]; protected static final int TICKS_BETWEEN_RECIPE_CHECKS = 5 * TickTime.SECOND; @@ -96,7 +96,7 @@ public abstract class MultiTileBasicMachine

, G @Nonnull protected PowerLogic power = createPowerLogic(); @Nonnull - protected GUIProvider guiProvider = createGUIProvider(); + protected GUIProvider guiProvider = createGUIProvider(); @SideOnly(Side.CLIENT) protected GT_SoundLoop activitySoundLoop; @@ -738,6 +738,7 @@ public boolean isInputSeparated() { return false; } + @Nonnull @Override public VoidingMode getVoidMode() { return voidingMode; @@ -778,9 +779,13 @@ protected PowerLogic createPowerLogic() { .setType(PowerLogic.RECEIVER); } - // @SuppressWarnings("unchecked") @Nonnull - protected GUIProvider createGUIProvider() { - return new MachineGUIProvider(this); + protected GUIProvider createGUIProvider() { + return new MachineGUIProvider<>(this); + } + + @Nonnull + public GUIProvider getGUI() { + return guiProvider; } } diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java index 8be9d467879..bf18a365bc0 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java @@ -88,7 +88,7 @@ * Multi Tile Entities - or MuTEs - don't have dedicated hatches, but their casings can become hatches. */ public abstract class Controller, P extends MuTEProcessingLogic

> - extends MultiTileBasicMachine> implements IAlignment, IMultiBlockController, IDescribable, + extends MultiTileBasicMachine

implements IAlignment, IMultiBlockController, IDescribable, IMTE_AddToolTips, ISurvivalConstructable, ControllerWithOptionalFeatures { public static final String ALL_INVENTORIES_NAME = "all"; @@ -1175,11 +1175,6 @@ public Pos2d getRecipeLockingButtonPos() { return new Pos2d(0, 0); } - @Override - public ModularWindow createWindowGUI(UIBuildContext buildContext) { - return createWindow(buildContext); - } - @Override public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, int z) { diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java index fa125d088b0..29c6b029cd2 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java @@ -34,6 +34,8 @@ import gregtech.api.enums.GT_Values.NBT; import gregtech.api.enums.InventoryType; import gregtech.api.fluid.FluidTankGT; +import gregtech.api.gui.GUIHost; +import gregtech.api.gui.GUIProvider; import gregtech.api.interfaces.ITexture; import gregtech.api.logic.FluidInventoryLogic; import gregtech.api.logic.ItemInventoryLogic; @@ -49,11 +51,12 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; import gregtech.common.covers.CoverInfo; +import gregtech.common.gui.PartGUIProvider; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; public abstract class MultiBlockPart extends NonTickableMultiTileEntity - implements IMultiBlockPart, IMTE_HasModes, PowerLogicHost, IMultiTileEntity.IMTE_AddToolTips { + implements IMultiBlockPart, IMTE_HasModes, PowerLogicHost, IMultiTileEntity.IMTE_AddToolTips, GUIHost { public static final int NOTHING = 0, ENERGY_IN = B[0], ENERGY_OUT = B[1], FLUID_IN = B[2], FLUID_OUT = B[3], ITEM_IN = B[4], ITEM_OUT = B[5]; @@ -72,6 +75,9 @@ public abstract class MultiBlockPart extends NonTickableMultiTileEntity protected int mLockedInventoryIndex = 0; protected FluidTankGT configurationTank = new FluidTankGT(); + @Nonnull + protected final GUIProvider guiProvider = createGUIProvider(); + /** * What Part Tier is this part? All Basic Casings are Tier 1, and will allow: Energy, Item, Fluid input/output. Some * of the more advanced modes can be set to require a higher tier part. @@ -599,22 +605,6 @@ protected Fluid getLockedFluid() { return null; } - @Override - public ModularWindow createWindow(UIBuildContext buildContext) { - if (isServerSide()) { - issueClientUpdate(); - } - System.out.println("MultiBlockPart::createWindow"); - if ((modeSelected(NOTHING, ENERGY_IN, ENERGY_OUT) || mode == NOTHING) && canOpenControllerGui()) { - IMultiBlockController controller = getTarget(false); - if (controller == null) { - return super.createWindow(buildContext); - } - return controller.createWindowGUI(buildContext); - } - return super.createWindow(buildContext); - } - @Override public void addUIWidgets(Builder builder, UIBuildContext buildContext) { super.addUIWidgets(builder, buildContext); @@ -696,4 +686,22 @@ public ForgeDirection getPowerOutputSide() { if (!modeSelected(ENERGY_OUT)) return ForgeDirection.UNKNOWN; return facing; } + + @Nonnull + protected GUIProvider createGUIProvider() { + return new PartGUIProvider<>(this); + } + + @Override + @Nonnull + public GUIProvider getGUI() { + IMultiBlockController controller = getTarget(false); + if (controller == null) return guiProvider; + if (!modeSelected(NOTHING, ENERGY_IN, ENERGY_OUT)) return guiProvider; + if (!canOpenControllerGui()) return guiProvider; + GUIProvider controllerGUI = controller.getGUI(); + return controllerGUI; + } + + } diff --git a/src/main/java/gregtech/common/gui/MachineGUIProvider.java b/src/main/java/gregtech/common/gui/MachineGUIProvider.java index d019eae4b89..d99322eb1f8 100644 --- a/src/main/java/gregtech/common/gui/MachineGUIProvider.java +++ b/src/main/java/gregtech/common/gui/MachineGUIProvider.java @@ -11,10 +11,10 @@ import gregtech.api.logic.interfaces.PowerLogicHost; import gregtech.api.logic.interfaces.ProcessingLogicHost; -public class MachineGUIProvider & ProcessingLogicHost> & PowerLogicHost> - extends GUIProvider { +public class MachineGUIProvider> & PowerLogicHost> + extends GUIProvider { - public MachineGUIProvider(G host) { + public MachineGUIProvider(@Nonnull T host) { super(host); } diff --git a/src/main/java/gregtech/common/gui/PartGUIProvider.java b/src/main/java/gregtech/common/gui/PartGUIProvider.java new file mode 100644 index 00000000000..d71e7c05559 --- /dev/null +++ b/src/main/java/gregtech/common/gui/PartGUIProvider.java @@ -0,0 +1,32 @@ +package gregtech.common.gui; + +import javax.annotation.Nonnull; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; + +import gregtech.api.gui.GUIHost; +import gregtech.api.gui.GUIProvider; +import gregtech.api.logic.interfaces.FluidInventoryLogicHost; +import gregtech.api.logic.interfaces.ItemInventoryLogicHost; +import gregtech.api.logic.interfaces.PowerLogicHost; + +public class PartGUIProvider extends GUIProvider { + + public PartGUIProvider(@Nonnull T host) { + super(host); + } + + @Override + protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'attachSynchHandlers'"); + } + + @Override + protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'addWidgets'"); + } + +} From a32ee83eae5500fa60d377e9b4caf4ef16c6c355 Mon Sep 17 00:00:00 2001 From: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Date: Wed, 27 Sep 2023 21:08:58 +0300 Subject: [PATCH 5/7] add UIBuildContext to getGUI method --- src/main/java/gregtech/api/gui/GUIHost.java | 11 ++++++++--- .../machine/MultiTileBasicMachine.java | 3 ++- .../multiblock/base/MultiBlockPart.java | 7 +++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/gregtech/api/gui/GUIHost.java b/src/main/java/gregtech/api/gui/GUIHost.java index dabeede67d3..134a9725da8 100644 --- a/src/main/java/gregtech/api/gui/GUIHost.java +++ b/src/main/java/gregtech/api/gui/GUIHost.java @@ -4,6 +4,7 @@ import javax.annotation.Nonnull; +import com.gtnewhorizons.modularui.api.math.Size; import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -13,10 +14,14 @@ public interface GUIHost extends ITileWithModularUI { @Nonnull @Override default ModularWindow createWindow(UIBuildContext uiContext) { - GUIProvider gui = getGUI(); - return gui.openGUI(Objects.requireNonNull(uiContext)); + Objects.requireNonNull(uiContext); + GUIProvider gui = getGUI(uiContext); + return gui.openGUI(uiContext); } + /** + * Width of the GUI when its being displayed + */ default int getWidth() { return 170; } @@ -26,6 +31,6 @@ default int getHeight() { } @Nonnull - GUIProvider getGUI(); + GUIProvider getGUI(@Nonnull UIBuildContext uiContext); } diff --git a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java index 3afcbdccce5..47ba1ad813e 100644 --- a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java +++ b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java @@ -26,6 +26,7 @@ import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -785,7 +786,7 @@ protected GUIProvider createGUIProvider() { } @Nonnull - public GUIProvider getGUI() { + public GUIProvider getGUI(@Nonnull UIBuildContext uiContext) { return guiProvider; } } diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java index 29c6b029cd2..f30b0ac7f46 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java @@ -668,13 +668,11 @@ public String getInventoryName() { if (modeSelected(ITEM_IN, ITEM_OUT)) { InventoryType type = modeSelected(ITEM_IN) ? InventoryType.Input : InventoryType.Output; ItemInventoryLogic itemLogic = controller.getItemLogic(type, lockedInventory); - if (itemLogic == null) return ""; return itemLogic.getDisplayName(); } if (modeSelected(FLUID_IN, FLUID_OUT)) { InventoryType type = modeSelected(FLUID_IN) ? InventoryType.Input : InventoryType.Output; FluidInventoryLogic fluidLogic = controller.getFluidLogic(type, lockedInventory); - if (fluidLogic == null) return ""; return fluidLogic.getDisplayName(); } return ""; @@ -694,12 +692,13 @@ protected GUIProvider createGUIProvider() { @Override @Nonnull - public GUIProvider getGUI() { + public GUIProvider getGUI(@Nonnull UIBuildContext uiContext) { IMultiBlockController controller = getTarget(false); if (controller == null) return guiProvider; if (!modeSelected(NOTHING, ENERGY_IN, ENERGY_OUT)) return guiProvider; if (!canOpenControllerGui()) return guiProvider; - GUIProvider controllerGUI = controller.getGUI(); + if (uiContext.getPlayer().isSneaking()) return guiProvider; + GUIProvider controllerGUI = controller.getGUI(uiContext); return controllerGUI; } From bfb06f36e91e6ba15b9fef950f35704938fb892e Mon Sep 17 00:00:00 2001 From: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Date: Sat, 14 Oct 2023 18:03:30 +0300 Subject: [PATCH 6/7] make it compile --- src/main/java/gregtech/api/gui/GUIHost.java | 23 +- .../tileentity/IMachineProgress.java | 8 + .../logic/interfaces/ProcessingLogicHost.java | 34 ++ .../machine/MultiTileBasicMachine.java | 20 +- .../multiblock/base/Controller.java | 200 +-------- .../multiblock/base/MultiBlockPart.java | 12 + .../ComplexParallelMachineGUIProvider.java | 32 ++ .../common/gui/MachineGUIProvider.java | 422 +++++++++++++++++- .../multiblock/AdvChemicalProcessor.java | 8 +- .../machines/multiblock/CokeOven.java | 2 +- .../machines/multiblock/LaserEngraver.java | 3 +- 11 files changed, 550 insertions(+), 214 deletions(-) create mode 100644 src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java diff --git a/src/main/java/gregtech/api/gui/GUIHost.java b/src/main/java/gregtech/api/gui/GUIHost.java index 134a9725da8..9d63151ebd6 100644 --- a/src/main/java/gregtech/api/gui/GUIHost.java +++ b/src/main/java/gregtech/api/gui/GUIHost.java @@ -9,6 +9,8 @@ import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import net.minecraft.item.ItemStack; + public interface GUIHost extends ITileWithModularUI { @Nonnull @@ -27,10 +29,29 @@ default int getWidth() { } default int getHeight() { - return 100; + return 192; } @Nonnull GUIProvider getGUI(@Nonnull UIBuildContext uiContext); + ItemStack getAsItem(); + + String getMachineName(); + + default boolean hasItemInput() { + return true; + } + + default boolean hasItemOutput() { + return true; + } + + default boolean hasFluidInput() { + return true; + } + + default boolean hasFluidOutput() { + return true; + } } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java b/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java index 2723689e83d..517f4a0cd39 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java @@ -46,6 +46,14 @@ public interface IMachineProgress extends IHasWorldObjectAndCoords { */ boolean isAllowedToWork(); + default void setAllowedToWork(Boolean allowedToWork) { + if (allowedToWork) { + enableWorking(); + } else { + disableWorking(); + } + } + /** * used to control Machines via Redstone Signal Strength by special Covers In case of 0 the Machine is very likely * doing nothing, or is just not being controlled at all. diff --git a/src/main/java/gregtech/api/logic/interfaces/ProcessingLogicHost.java b/src/main/java/gregtech/api/logic/interfaces/ProcessingLogicHost.java index 52ac7ec9253..b8291c98439 100644 --- a/src/main/java/gregtech/api/logic/interfaces/ProcessingLogicHost.java +++ b/src/main/java/gregtech/api/logic/interfaces/ProcessingLogicHost.java @@ -18,6 +18,40 @@ public interface ProcessingLogicHost

> boolean isInputSeparated(); + void setInputSeparation(Boolean inputSeparation); + + default boolean supportsInputSeparation() { + return true; + } + + default boolean getDefaultInputSeparationMode() { + return false; + } + + boolean isRecipeLockingEnabled(); + + void setRecipeLocking(Boolean recipeLocked); + + default boolean supportsSingleRecipeLocking() { + return true; + } + + default boolean getDefaultRecipeLockingMode() { + return false; + } + + default boolean supportsBatchMode() { + return true; + } + + void setBatchMode(Boolean batchMode); + + boolean isBatchModeEnabled(); + + default boolean getDefaultBatchMode() { + return false; + } + /** * Get what the machine can void or not */ diff --git a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java index 47ba1ad813e..4dc3e8fef9e 100644 --- a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java +++ b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java @@ -656,19 +656,19 @@ public void setBooleans(int booleans) { setActive((booleans & ACTIVE) == ACTIVE); } - protected boolean hasItemInput() { + public boolean hasItemInput() { return true; } - protected boolean hasItemOutput() { + public boolean hasItemOutput() { return true; } - protected boolean hasFluidInput() { + public boolean hasFluidInput() { return true; } - protected boolean hasFluidOutput() { + public boolean hasFluidOutput() { return true; } @@ -789,4 +789,16 @@ protected GUIProvider createGUIProvider() { public GUIProvider getGUI(@Nonnull UIBuildContext uiContext) { return guiProvider; } + + @Override + public ItemStack getAsItem() { + return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()).getItem(getMultiTileEntityID()); + } + + @Override + public String getMachineName() { + return StatCollector.translateToLocal(getAsItem().getUnlocalizedName()); + } + + } diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java index bf18a365bc0..cbec71b839b 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java @@ -89,7 +89,7 @@ */ public abstract class Controller, P extends MuTEProcessingLogic

> extends MultiTileBasicMachine

implements IAlignment, IMultiBlockController, IDescribable, - IMTE_AddToolTips, ISurvivalConstructable, ControllerWithOptionalFeatures { + IMTE_AddToolTips, ISurvivalConstructable { public static final String ALL_INVENTORIES_NAME = "all"; protected static final int AUTO_OUTPUT_FREQUENCY_TICK = 20; @@ -915,171 +915,6 @@ protected void addTitleTextStyle(ModularWindow.Builder builder, String title) { // leave empty } - @Override - public int getGUIHeight() { - return 192; - } - - protected Widget getGregTechLogo() { - return new DrawableWidget().setDrawable(getGUITextureSet().getGregTechLogo()) - .setSize(17, 17); - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - if (isServerSide()) { - for (UpgradeCasing tPart : upgradeCasings) { - if (!(tPart instanceof Inventory)) continue; - tPart.issueClientUpdate(); - } - } - int page = 0; - TabContainer tabs = new TabContainer().setButtonSize(20, 24); - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0, 1f, 0.5f), - new ItemDrawable(getStackForm(1)).withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0.5f, 1f, 1f), - new ItemDrawable(getStackForm(1)).withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip(getLocalName()) - .setPos(20 * (page - 1), -20)) - .addPage(createMainPage(builder).setSize(getGUIWidth(), getGUIHeight())); - if (hasItemInput()) { - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), - GT_UITextures.PICTURE_ITEM_IN.withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), - GT_UITextures.PICTURE_ITEM_IN.withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip("Item Input Inventory") - .setPos(20 * (page - 1), -20)) - .addPage( - new MultiChildWidget().addChild( - controllerItemInput.getAllInventoryLogics() - .getGuiPart() - .setSize(18 * 4 + 4, 18 * 5) - .setPos(52, 7)) - .addChild(getGregTechLogo().setPos(147, 86)) - .setSize(getGUIWidth(), getGUIHeight())); - } - - if (hasItemOutput()) { - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), - GT_UITextures.PICTURE_ITEM_OUT.withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), - GT_UITextures.PICTURE_ITEM_OUT.withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip("Item Output Inventory") - .setPos(20 * (page - 1), -20)) - .addPage( - new MultiChildWidget().addChild( - controllerItemOutput.getAllInventoryLogics() - .getGuiPart() - .setSize(18 * 4 + 4, 18 * 5) - .setPos(52, 7)) - .addChild(getGregTechLogo().setPos(147, 86)) - .setSize(getGUIWidth(), getGUIHeight())); - } - - if (hasFluidInput()) { - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), - GT_UITextures.PICTURE_FLUID_IN.withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), - GT_UITextures.PICTURE_FLUID_IN.withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip("Fluid Input Tanks") - .setPos(20 * (page - 1), -20)) - .addPage( - new MultiChildWidget().addChild( - controllerFluidInput.getAllInventoryLogics() - .getGuiPart() - .setSize(18 * 4 + 4, 18 * 5) - .setPos(52, 7)) - .addChild(getGregTechLogo().setPos(147, 86)) - .setSize(getGUIWidth(), getGUIHeight())); - } - - if (hasFluidOutput()) { - tabs.addTabButton( - new TabButton(page++) - .setBackground( - false, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), - GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) - .withOffset(2, 4)) - .setBackground( - true, - ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), - GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) - .withOffset(2, 4)) - .addTooltip("Fluid Output Tanks") - .setPos(20 * (page - 1), -20)) - .addPage( - new MultiChildWidget().addChild( - controllerFluidOutput.getAllInventoryLogics() - .getGuiPart() - .setSize(18 * 4 + 4, 18 * 5) - .setPos(52, 7)) - .addChild(getGregTechLogo().setPos(147, 86)) - .setSize(getGUIWidth(), getGUIHeight())); - } - builder.widget(tabs); - } - - protected MultiChildWidget createMainPage(IWidgetBuilder builder) { - MultiChildWidget page = new MultiChildWidget(); - page.addChild( - new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) - .setPos(7, 4) - .setSize(160, 75)) - .addChild(createButtons(builder)); - return page; - } - - protected MultiChildWidget createButtons(IWidgetBuilder builder) { - MultiChildWidget buttons = new MultiChildWidget(); - buttons.setSize(16, 167) - .setPos(7, 86); - buttons.addChild(createPowerSwitchButton(builder)) - .addChild(createVoidExcessButton(builder)) - .addChild(createInputSeparationButton(builder)) - .addChild(createBatchModeButton(builder)) - .addChild(createLockToSingleRecipeButton(builder)); - - return buttons; - } - - @Override - public Pos2d getPowerSwitchButtonPos() { - return new Pos2d(144, 0); - } - @Override public boolean supportsVoidProtection() { return true; @@ -1105,31 +940,21 @@ public boolean canDumpFluidToME() { return false; } - @Override - public Pos2d getVoidingModeButtonPos() { - return new Pos2d(54, 0); - } - @Override public boolean supportsInputSeparation() { return true; } @Override - public boolean isInputSeparationEnabled() { + public boolean isInputSeparated() { return separateInputs; } @Override - public void setInputSeparation(boolean enabled) { + public void setInputSeparation(Boolean enabled) { this.separateInputs = enabled; } - @Override - public Pos2d getInputSeparationButtonPos() { - return new Pos2d(36, 0); - } - @Override public boolean supportsBatchMode() { return true; @@ -1141,15 +966,10 @@ public boolean isBatchModeEnabled() { } @Override - public void setBatchMode(boolean mode) { + public void setBatchMode(Boolean mode) { this.batchMode = mode; } - @Override - public Pos2d getBatchModeButtonPos() { - return new Pos2d(18, 0); - } - @Override public boolean supportsSingleRecipeLocking() { return false; @@ -1161,20 +981,10 @@ public boolean isRecipeLockingEnabled() { } @Override - public void setRecipeLocking(boolean enabled) { + public void setRecipeLocking(Boolean enabled) { this.recipeLock = enabled; } - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - @Override - public Pos2d getRecipeLockingButtonPos() { - return new Pos2d(0, 0); - } - @Override public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, int z) { diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java index f30b0ac7f46..e352bf15ea0 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java @@ -23,6 +23,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; @@ -41,6 +42,7 @@ import gregtech.api.logic.ItemInventoryLogic; import gregtech.api.logic.PowerLogic; import gregtech.api.logic.interfaces.PowerLogicHost; +import gregtech.api.multitileentity.MultiTileEntityRegistry; import gregtech.api.multitileentity.base.NonTickableMultiTileEntity; import gregtech.api.multitileentity.enums.MultiTileCasingPurpose; import gregtech.api.multitileentity.interfaces.IMultiBlockController; @@ -702,5 +704,15 @@ public GUIProvider getGUI(@Nonnull UIBuildContext uiContext) { return controllerGUI; } + @Override + public ItemStack getAsItem() { + return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()).getItem(getMultiTileEntityID()); + } + + @Override + public String getMachineName() { + return StatCollector.translateToLocal(getAsItem().getUnlocalizedName()); + } + } diff --git a/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java b/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java new file mode 100644 index 00000000000..f28b0c997c6 --- /dev/null +++ b/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java @@ -0,0 +1,32 @@ +package gregtech.common.gui; + +import javax.annotation.Nonnull; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; + +import gregtech.api.gui.GUIHost; +import gregtech.api.logic.ComplexParallelProcessingLogic; +import gregtech.api.logic.interfaces.PowerLogicHost; +import gregtech.api.logic.interfaces.ProcessingLogicHost; + +/** + * Default GUI class for machines with complex parallel + */ +public class ComplexParallelMachineGUIProvider> & PowerLogicHost> + extends MachineGUIProvider { + + public ComplexParallelMachineGUIProvider(@Nonnull T host) { + super(host); + } + + @Override + protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + + } + + @Override + protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + + } +} diff --git a/src/main/java/gregtech/common/gui/MachineGUIProvider.java b/src/main/java/gregtech/common/gui/MachineGUIProvider.java index d99322eb1f8..e8d75555f71 100644 --- a/src/main/java/gregtech/common/gui/MachineGUIProvider.java +++ b/src/main/java/gregtech/common/gui/MachineGUIProvider.java @@ -1,33 +1,447 @@ package gregtech.common.gui; +import static gregtech.api.metatileentity.BaseTileEntity.BUTTON_FORBIDDEN_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + import javax.annotation.Nonnull; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import com.gtnewhorizons.modularui.common.widget.TabButton; +import com.gtnewhorizons.modularui.common.widget.TabContainer; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.VoidingMode; import gregtech.api.gui.GUIHost; import gregtech.api.gui.GUIProvider; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.GUITextureSet; import gregtech.api.logic.MuTEProcessingLogic; import gregtech.api.logic.interfaces.PowerLogicHost; import gregtech.api.logic.interfaces.ProcessingLogicHost; +import gregtech.api.multitileentity.multiblock.casing.UpgradeCasing; +import gregtech.common.tileentities.casings.upgrade.Inventory; +import net.minecraft.util.StatCollector; +/** + * Default GUI a machine will use to show its information + */ public class MachineGUIProvider> & PowerLogicHost> extends GUIProvider { + private static final int LOGO_SIZE = 17; + protected static final Pos2d POWER_SWITCH_BUTTON_DEFAULT_POS = new Pos2d(144, 0); + protected static final Pos2d VOIDING_MODE_BUTTON_DEFAULT_POS = new Pos2d(54, 0); + protected static final Pos2d INPUT_SEPARATION_BUTTON_DEFAULT_POS = new Pos2d(36, 0); + protected static final Pos2d BATCH_MODE_BUTTON_DEFAULT_POS = new Pos2d(18, 0); + protected static final Pos2d RECIPE_LOCKING_BUTTON_DEFAULT_POS = new Pos2d(0, 0); + public MachineGUIProvider(@Nonnull T host) { super(host); } @Override protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'attachSynchHandlers'"); + } @Override protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'addWidgets'"); + int page = 0; + MultiChildWidget mainTab = new MultiChildWidget(); + mainTab.setSize(host.getWidth(), host.getHeight()); + createMainTab(mainTab, builder, uiContext); + TabContainer tabs = new TabContainer().setButtonSize(20, 24); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0, 1f, 0.5f), + new ItemDrawable(host.getAsItem()).withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0.5f, 1f, 1f), + new ItemDrawable(host.getAsItem()).withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip(host.getMachineName()) + .setPos(20 * (page - 1), -20)) + .addPage(mainTab); + if (host.hasItemInput()) { + MultiChildWidget itemInputTab = new MultiChildWidget(); + itemInputTab.setSize(host.getWidth(), host.getHeight()); + createItemInputTab(itemInputTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_ITEM_IN.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_ITEM_IN.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Item Input Inventory") + .setPos(20 * (page - 1), -20)) + .addPage( + itemInputTab + .addChild(getLogo().setPos(147, 86))); + } + + if (host.hasItemOutput()) { + MultiChildWidget itemOutputTab = new MultiChildWidget(); + itemOutputTab.setSize(host.getWidth(), host.getHeight()); + createItemOutputTab(itemOutputTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_ITEM_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_ITEM_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Item Output Inventory") + .setPos(20 * (page - 1), -20)) + .addPage( + itemOutputTab + .addChild(getLogo().setPos(147, 86))); + } + + if (host.hasFluidInput()) { + MultiChildWidget fluidInputTab = new MultiChildWidget(); + fluidInputTab.setSize(host.getWidth(), host.getHeight()); + createFluidInputTab(fluidInputTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_FLUID_IN.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_FLUID_IN.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Fluid Input Tanks") + .setPos(20 * (page - 1), -20)) + .addPage( + fluidInputTab + .addChild(getLogo().setPos(147, 86))); + } + + if (host.hasFluidOutput()) { + MultiChildWidget fluidOutputTab = new MultiChildWidget(); + fluidOutputTab.setSize(host.getWidth(), host.getHeight()); + createFluidOutputTab(fluidOutputTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Fluid Output Tanks") + .setPos(20 * (page - 1), -20)) + .addPage( + fluidOutputTab + .addChild(getLogo().setPos(147, 86))); + } + builder.widget(tabs); + } + + protected void createMainTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { + MultiChildWidget buttons = new MultiChildWidget(); + buttons.setSize(16, 167) + .setPos(7, 86); + buttons.addChild(createPowerSwitchButton(builder)) + .addChild(createVoidExcessButton(builder)) + .addChild(createInputSeparationButton(builder)) + .addChild(createBatchModeButton(builder)) + .addChild(createLockToSingleRecipeButton(builder)); + tab.addChild( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setPos(7, 4) + .setSize(160, 75)) + .addChild(buttons); + } + + protected void createItemInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { + } + protected void createItemOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { + + } + + protected void createFluidInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { + + } + + protected void createFluidOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { + + } + + protected void createPowerTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { + + } + + + /** + * Should return the logo you want to use that is pasted on each tab. Default is the GT logo. + */ + @Nonnull + protected Widget getLogo() { + DrawableWidget logo = new DrawableWidget(); + logo.setDrawable(GUITextureSet.DEFAULT.getGregTechLogo()).setSize(LOGO_SIZE, LOGO_SIZE); + return logo; + } + + protected Pos2d getPowerSwitchButtonPos() { + return POWER_SWITCH_BUTTON_DEFAULT_POS; + } + + protected ButtonWidget createPowerSwitchButton(IWidgetBuilder builder) { + ButtonWidget button = new ButtonWidget(); + button.setOnClick((clickData, widget) -> { + if (host.isAllowedToWork()) { + host.disableWorking(); + } else { + host.enableWorking(); + } + }) + .setPlayClickSoundResource( + () -> host.isAllowedToWork() ? SoundResource.GUI_BUTTON_UP.resourceLocation + : SoundResource.GUI_BUTTON_DOWN.resourceLocation) + .setBackground(() -> { + if (host.isAllowedToWork()) { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED, + GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_ON }; + } else { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, + GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF }; + } + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(host::isAllowedToWork, host::setAllowedToWork), builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.power_switch")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(getPowerSwitchButtonPos()) + .setSize(16, 16); + return button; + } + + @Nonnull + protected Pos2d getVoidingModeButtonPos() { + return VOIDING_MODE_BUTTON_DEFAULT_POS; + } + + @Nonnull + protected ButtonWidget createVoidExcessButton(IWidgetBuilder builder) { + ButtonWidget button = new ButtonWidget(); + button.setOnClick((clickData, widget) -> { + if (host.supportsVoidProtection()) { + Set allowed = host.getAllowedVoidingModes(); + switch (clickData.mouseButton) { + case 0 -> host.setVoidingMode(host.getVoidingMode().nextInCollection(allowed)); + case 1 -> host.setVoidingMode(host.getVoidingMode().previousInCollection(allowed)); + } + widget.notifyTooltipChange(); + } + }) + .setPlayClickSound(host.supportsVoidProtection()) + .setBackground(() -> { + List ret = new ArrayList<>(); + ret.add(host.getVoidingMode().buttonTexture); + ret.add(host.getVoidingMode().buttonOverlay); + if (!host.supportsVoidProtection()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_FORBIDDEN); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer( + new FakeSyncWidget.IntegerSyncer( + () -> host.getVoidingMode().ordinal(), + val -> host.setVoidingMode(VoidingMode.fromOrdinal(val))), + builder) + .dynamicTooltip( + () -> Arrays.asList( + StatCollector.translateToLocal("GT5U.gui.button.voiding_mode"), + StatCollector.translateToLocal(host.getVoidingMode().getTransKey()))) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(getVoidingModeButtonPos()) + .setSize(16, 16); + if (!host.supportsVoidProtection()) { + button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); + } + return button; + } + + @Nonnull + protected Pos2d getInputSeparationButtonPos() { + return INPUT_SEPARATION_BUTTON_DEFAULT_POS; + } + + protected ButtonWidget createInputSeparationButton(IWidgetBuilder builder) { + ButtonWidget button = new ButtonWidget(); + button.setOnClick((clickData, widget) -> { + if (host.supportsInputSeparation()) { + host.setInputSeparation(!host.isInputSeparated()); + } + }) + .setPlayClickSound(host.supportsInputSeparation()) + .setBackground(() -> { + List ret = new ArrayList<>(); + if (host.isInputSeparated()) { + ret.add(GT_UITextures.BUTTON_STANDARD_PRESSED); + if (host.supportsInputSeparation()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_ON); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_ON_DISABLED); + } + } else { + ret.add(GT_UITextures.BUTTON_STANDARD); + if (host.supportsInputSeparation()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_OFF); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_OFF_DISABLED); + } + } + if (!host.supportsInputSeparation()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_FORBIDDEN); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(host::isInputSeparated, host::setInputSeparation), + builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.input_separation")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(getInputSeparationButtonPos()) + .setSize(16, 16); + if (!host.supportsInputSeparation()) { + button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); + } + return button; + } + + @Nonnull + protected Pos2d getBatchModeButtonPos() { + return BATCH_MODE_BUTTON_DEFAULT_POS; + } + + protected ButtonWidget createBatchModeButton(IWidgetBuilder builder) { + ButtonWidget button = new ButtonWidget(); + button.setOnClick((clickData, widget) -> { + if (host.supportsBatchMode()) { + host.setBatchMode(!host.isBatchModeEnabled()); + } + }) + .setPlayClickSound(host.supportsBatchMode()) + .setBackground(() -> { + List ret = new ArrayList<>(); + if (host.isBatchModeEnabled()) { + ret.add(GT_UITextures.BUTTON_STANDARD_PRESSED); + if (host.supportsBatchMode()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_ON); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_ON_DISABLED); + } + } else { + ret.add(GT_UITextures.BUTTON_STANDARD); + if (host.supportsBatchMode()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_OFF); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_OFF_DISABLED); + } + } + if (!host.supportsBatchMode()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_FORBIDDEN); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(host::isBatchModeEnabled, host::setBatchMode), builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.batch_mode")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(getBatchModeButtonPos()) + .setSize(16, 16); + if (!host.supportsBatchMode()) { + button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); + } + return button; + } + + @Nonnull + protected Pos2d getRecipeLockingButtonPos() { + return RECIPE_LOCKING_BUTTON_DEFAULT_POS; + } + + protected ButtonWidget createLockToSingleRecipeButton(IWidgetBuilder builder) { + ButtonWidget button = new ButtonWidget(); + button.setOnClick((clickData, widget) -> { + if (host.supportsSingleRecipeLocking()) { + host.setRecipeLocking(!host.isRecipeLockingEnabled()); + } + }) + .setPlayClickSound(host.supportsSingleRecipeLocking()) + .setBackground(() -> { + List ret = new ArrayList<>(); + if (host.isRecipeLockingEnabled()) { + ret.add(GT_UITextures.BUTTON_STANDARD_PRESSED); + if (host.supportsSingleRecipeLocking()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_LOCKED); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_LOCKED_DISABLED); + } + } else { + ret.add(GT_UITextures.BUTTON_STANDARD); + if (host.supportsSingleRecipeLocking()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED_DISABLED); + } + } + if (!host.supportsSingleRecipeLocking()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_FORBIDDEN); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(host::isRecipeLockingEnabled, host::setRecipeLocking), + builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.lock_recipe")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(getRecipeLockingButtonPos()) + .setSize(16, 16); + if (!host.supportsSingleRecipeLocking()) { + button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); + } + return button; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java index cc29fca4e64..55ccb78928d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java @@ -97,11 +97,6 @@ public AdvChemicalProcessor() { setMaxComplexParallels(1, false); } - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map_LargeChemicalReactor.sChemicalRecipes; - } - @Override public void readMultiTileNBT(NBTTagCompound nbt) { super.readMultiTileNBT(nbt); @@ -379,9 +374,8 @@ protected void setMaxComplexParallels(int parallel, boolean stopMachine) { onStructureChange(); } - @Override protected MultiChildWidget createMainPage(IWidgetBuilder builder) { - MultiChildWidget child = super.createMainPage(builder); + MultiChildWidget child = new MultiChildWidget(); for (int i = 0; i < MAX_PROCESSES; i++) { final int processIndex = i; child.addChild( diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/CokeOven.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/CokeOven.java index 7aea3c4edc2..06fc7b42b1f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/CokeOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/CokeOven.java @@ -103,7 +103,7 @@ public IStructureDefinition getStructureDefinition() { } @Override - protected boolean hasFluidInput() { + public boolean hasFluidInput() { return false; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/LaserEngraver.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/LaserEngraver.java index b35e4a3d5df..6d30fe2d7d8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/LaserEngraver.java +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/LaserEngraver.java @@ -233,9 +233,8 @@ public IStructureDefinition getStructureDefinition() { return STRUCTURE_DEFINITION; } - @Override protected MultiChildWidget createMainPage(IWidgetBuilder builder) { - MultiChildWidget child = super.createMainPage(builder); + MultiChildWidget child = new MultiChildWidget(); for (int i = 0; i < MAX_PROCESSES; i++) { final int processIndex = i; child.addChild( From 914671c0dd72c314aa8882837d6db6297cbe3d64 Mon Sep 17 00:00:00 2001 From: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Date: Mon, 23 Oct 2023 19:53:55 +0300 Subject: [PATCH 7/7] sketch gui - fix conflict --- src/main/java/gregtech/api/gui/GUIHost.java | 5 +- .../interfaces/IMultiBlockController.java | 4 - .../machine/MultiTileBasicMachine.java | 8 +- .../multiblock/base/Controller.java | 45 ++----- .../multiblock/base/MultiBlockPart.java | 8 +- .../ComplexParallelMachineGUIProvider.java | 2 +- .../common/gui/MachineGUIProvider.java | 125 ++++++++++++------ .../gregtech/common/gui/PartGUIProvider.java | 5 +- .../multiblock/AdvChemicalProcessor.java | 1 - 9 files changed, 114 insertions(+), 89 deletions(-) diff --git a/src/main/java/gregtech/api/gui/GUIHost.java b/src/main/java/gregtech/api/gui/GUIHost.java index 9d63151ebd6..bbb94317c47 100644 --- a/src/main/java/gregtech/api/gui/GUIHost.java +++ b/src/main/java/gregtech/api/gui/GUIHost.java @@ -4,13 +4,12 @@ import javax.annotation.Nonnull; -import com.gtnewhorizons.modularui.api.math.Size; +import net.minecraft.item.ItemStack; + import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import net.minecraft.item.ItemStack; - public interface GUIHost extends ITileWithModularUI { @Nonnull diff --git a/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java b/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java index 4423b32d181..71052b0a586 100644 --- a/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java +++ b/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java @@ -8,12 +8,8 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraftforge.common.util.ForgeDirection; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; - import gregtech.api.enums.InventoryType; import gregtech.api.gui.GUIHost; -import gregtech.api.gui.GUIProvider; import gregtech.api.logic.FluidInventoryLogic; import gregtech.api.logic.ItemInventoryLogic; import gregtech.api.logic.interfaces.FluidInventoryLogicHost; diff --git a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java index 4dc3e8fef9e..6442d296628 100644 --- a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java +++ b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java @@ -53,8 +53,8 @@ import gregtech.client.GT_SoundLoop; import gregtech.common.gui.MachineGUIProvider; -public abstract class MultiTileBasicMachine

> - extends TickableMultiTileEntity implements IMultiTileMachine, ProcessingLogicHost

, PowerLogicHost, GUIHost { +public abstract class MultiTileBasicMachine

> extends TickableMultiTileEntity + implements IMultiTileMachine, ProcessingLogicHost

, PowerLogicHost, GUIHost { protected static final int ACTIVE = B[0]; protected static final int TICKS_BETWEEN_RECIPE_CHECKS = 5 * TickTime.SECOND; @@ -792,7 +792,8 @@ public GUIProvider getGUI(@Nonnull UIBuildContext uiContext) { @Override public ItemStack getAsItem() { - return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()).getItem(getMultiTileEntityID()); + return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()) + .getItem(getMultiTileEntityID()); } @Override @@ -800,5 +801,4 @@ public String getMachineName() { return StatCollector.translateToLocal(getAsItem().getUnlocalizedName()); } - } diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java index cbec71b839b..42c4b9cbfe7 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java @@ -43,30 +43,20 @@ import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; import com.gtnewhorizon.structurelib.util.Vec3Impl; -import com.gtnewhorizons.modularui.api.ModularUITextures; -import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; -import com.gtnewhorizons.modularui.api.math.Pos2d; import com.gtnewhorizons.modularui.api.screen.*; -import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; -import com.gtnewhorizons.modularui.api.widget.Widget; -import com.gtnewhorizons.modularui.common.widget.DrawableWidget; -import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; -import com.gtnewhorizons.modularui.common.widget.TabButton; -import com.gtnewhorizons.modularui.common.widget.TabContainer; import cpw.mods.fml.common.network.NetworkRegistry; import gregtech.api.enums.GT_Values.NBT; import gregtech.api.enums.InventoryType; import gregtech.api.enums.VoidingMode; -import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.IDescribable; import gregtech.api.interfaces.fluid.IFluidStore; -import gregtech.api.interfaces.modularui.ControllerWithOptionalFeatures; import gregtech.api.logic.ControllerFluidLogic; import gregtech.api.logic.ControllerItemLogic; import gregtech.api.logic.FluidInventoryLogic; import gregtech.api.logic.ItemInventoryLogic; import gregtech.api.logic.MuTEProcessingLogic; +import gregtech.api.logic.PowerLogic; import gregtech.api.multitileentity.enums.MultiTileCasingPurpose; import gregtech.api.multitileentity.interfaces.IMultiBlockController; import gregtech.api.multitileentity.interfaces.IMultiBlockPart; @@ -77,10 +67,8 @@ import gregtech.api.net.GT_Packet_MultiTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.GT_Waila; -import gregtech.common.tileentities.casings.upgrade.Inventory; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; @@ -88,8 +76,8 @@ * Multi Tile Entities - or MuTEs - don't have dedicated hatches, but their casings can become hatches. */ public abstract class Controller, P extends MuTEProcessingLogic

> - extends MultiTileBasicMachine

implements IAlignment, IMultiBlockController, IDescribable, - IMTE_AddToolTips, ISurvivalConstructable { + extends MultiTileBasicMachine

+ implements IAlignment, IMultiBlockController, IDescribable, IMTE_AddToolTips, ISurvivalConstructable { public static final String ALL_INVENTORIES_NAME = "all"; protected static final int AUTO_OUTPUT_FREQUENCY_TICK = 20; @@ -867,6 +855,15 @@ public void changeItemInventoryDisplayName(@Nullable UUID id, @Nullable String d // #endregion Item + // #region Energy + + @Override + public PowerLogic getPowerLogic() { + return getPowerLogic(ForgeDirection.UNKNOWN); + } + + // #endregion Energy + @Override protected void updateSlots() { controllerItemInput.getAllInventoryLogics() @@ -887,24 +884,6 @@ public boolean useModularUI() { return true; } - @Override - public ModularWindow createWindow(UIBuildContext buildContext) { - System.out.println("MultiBlockController::createWindow"); - if (!useModularUI()) return null; - - buildContext.setValidator(getValidator()); - final ModularWindow.Builder builder = ModularWindow.builder(getGUIWidth(), getGUIHeight()); - builder.setBackground(getGUITextureSet().getMainBackground()); - builder.setGuiTint(getGUIColorization()); - if (doesBindPlayerInventory()) { - bindPlayerInventoryUI(builder, buildContext); - } - addUIWidgets(builder, buildContext); - addTitleToUI(builder); - addCoverTabs(builder, buildContext); - return builder.build(); - } - @Override public boolean hasGui(ForgeDirection side) { return true; diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java index e352bf15ea0..d970f2b631c 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java @@ -27,7 +27,6 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.common.widget.*; @@ -699,14 +698,16 @@ public GUIProvider getGUI(@Nonnull UIBuildContext uiContext) { if (controller == null) return guiProvider; if (!modeSelected(NOTHING, ENERGY_IN, ENERGY_OUT)) return guiProvider; if (!canOpenControllerGui()) return guiProvider; - if (uiContext.getPlayer().isSneaking()) return guiProvider; + if (uiContext.getPlayer() + .isSneaking()) return guiProvider; GUIProvider controllerGUI = controller.getGUI(uiContext); return controllerGUI; } @Override public ItemStack getAsItem() { - return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()).getItem(getMultiTileEntityID()); + return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()) + .getItem(getMultiTileEntityID()); } @Override @@ -714,5 +715,4 @@ public String getMachineName() { return StatCollector.translateToLocal(getAsItem().getUnlocalizedName()); } - } diff --git a/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java b/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java index f28b0c997c6..89b42c8500f 100644 --- a/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java +++ b/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java @@ -19,7 +19,7 @@ public class ComplexParallelMachineGUIProvider { private static final int LOGO_SIZE = 17; + @Nonnull protected static final Pos2d POWER_SWITCH_BUTTON_DEFAULT_POS = new Pos2d(144, 0); + @Nonnull protected static final Pos2d VOIDING_MODE_BUTTON_DEFAULT_POS = new Pos2d(54, 0); + @Nonnull protected static final Pos2d INPUT_SEPARATION_BUTTON_DEFAULT_POS = new Pos2d(36, 0); + @Nonnull protected static final Pos2d BATCH_MODE_BUTTON_DEFAULT_POS = new Pos2d(18, 0); + @Nonnull protected static final Pos2d RECIPE_LOCKING_BUTTON_DEFAULT_POS = new Pos2d(0, 0); public MachineGUIProvider(@Nonnull T host) { @@ -58,12 +65,13 @@ public MachineGUIProvider(@Nonnull T host) { @Override protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { - + } @Override protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { int page = 0; + builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); MultiChildWidget mainTab = new MultiChildWidget(); mainTab.setSize(host.getWidth(), host.getHeight()); createMainTab(mainTab, builder, uiContext); @@ -101,9 +109,7 @@ protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiCo .withOffset(2, 4)) .addTooltip("Item Input Inventory") .setPos(20 * (page - 1), -20)) - .addPage( - itemInputTab - .addChild(getLogo().setPos(147, 86))); + .addPage(itemInputTab.addChild(getLogo().setPos(147, 86))); } if (host.hasItemOutput()) { @@ -124,9 +130,7 @@ protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiCo .withOffset(2, 4)) .addTooltip("Item Output Inventory") .setPos(20 * (page - 1), -20)) - .addPage( - itemOutputTab - .addChild(getLogo().setPos(147, 86))); + .addPage(itemOutputTab.addChild(getLogo().setPos(147, 86))); } if (host.hasFluidInput()) { @@ -147,9 +151,7 @@ protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiCo .withOffset(2, 4)) .addTooltip("Fluid Input Tanks") .setPos(20 * (page - 1), -20)) - .addPage( - fluidInputTab - .addChild(getLogo().setPos(147, 86))); + .addPage(fluidInputTab.addChild(getLogo().setPos(147, 86))); } if (host.hasFluidOutput()) { @@ -170,14 +172,31 @@ protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiCo .withOffset(2, 4)) .addTooltip("Fluid Output Tanks") .setPos(20 * (page - 1), -20)) - .addPage( - fluidOutputTab - .addChild(getLogo().setPos(147, 86))); + .addPage(fluidOutputTab.addChild(getLogo().setPos(147, 86))); } + MultiChildWidget powerInfoTab = new MultiChildWidget(); + powerInfoTab.setSize(host.getWidth(), host.getHeight()); + createPowerTab(powerInfoTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Power Information") + .setPos(20 * (page - 1), -20)) + .addPage(powerInfoTab.addChild(getLogo().setPos(147, 86))); builder.widget(tabs); } - protected void createMainTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { + protected void createMainTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { MultiChildWidget buttons = new MultiChildWidget(); buttons.setSize(16, 167) .setPos(7, 86); @@ -193,34 +212,61 @@ protected void createMainTab(@Nonnull MultiChildWidget tab, @Nonnull Builder bui .addChild(buttons); } - protected void createItemInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { - + protected void createItemInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getItemLogic(InventoryType.Input, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); } - protected void createItemOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { - + protected void createItemOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getItemLogic(InventoryType.Output, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); } - protected void createFluidInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { - + protected void createFluidInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getFluidLogic(InventoryType.Input, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); } - protected void createFluidOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { - + protected void createFluidOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getFluidLogic(InventoryType.Output, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); } - protected void createPowerTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { - + protected void createPowerTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + PowerLogic power = host.getPowerLogic(); + tab.addChild( + TextWidget.dynamicString(() -> power.getStoredEnergy() + "/" + power.getCapacity() + " EU") + .setPos(10, 30)) + .addChild( + TextWidget.dynamicString(() -> power.getVoltage() + " EU/t" + "(" + power.getMaxAmperage() + " A)") + .setPos(10, 60)); } - /** * Should return the logo you want to use that is pasted on each tab. Default is the GT logo. */ @Nonnull protected Widget getLogo() { DrawableWidget logo = new DrawableWidget(); - logo.setDrawable(GUITextureSet.DEFAULT.getGregTechLogo()).setSize(LOGO_SIZE, LOGO_SIZE); + logo.setDrawable(GUITextureSet.DEFAULT.getGregTechLogo()) + .setSize(LOGO_SIZE, LOGO_SIZE); return logo; } @@ -269,8 +315,12 @@ protected ButtonWidget createVoidExcessButton(IWidgetBuilder builder) { if (host.supportsVoidProtection()) { Set allowed = host.getAllowedVoidingModes(); switch (clickData.mouseButton) { - case 0 -> host.setVoidingMode(host.getVoidingMode().nextInCollection(allowed)); - case 1 -> host.setVoidingMode(host.getVoidingMode().previousInCollection(allowed)); + case 0 -> host.setVoidingMode( + host.getVoidingMode() + .nextInCollection(allowed)); + case 1 -> host.setVoidingMode( + host.getVoidingMode() + .previousInCollection(allowed)); } widget.notifyTooltipChange(); } @@ -287,13 +337,16 @@ protected ButtonWidget createVoidExcessButton(IWidgetBuilder builder) { }) .attachSyncer( new FakeSyncWidget.IntegerSyncer( - () -> host.getVoidingMode().ordinal(), + () -> host.getVoidingMode() + .ordinal(), val -> host.setVoidingMode(VoidingMode.fromOrdinal(val))), builder) .dynamicTooltip( () -> Arrays.asList( StatCollector.translateToLocal("GT5U.gui.button.voiding_mode"), - StatCollector.translateToLocal(host.getVoidingMode().getTransKey()))) + StatCollector.translateToLocal( + host.getVoidingMode() + .getTransKey()))) .setTooltipShowUpDelay(TOOLTIP_DELAY) .setPos(getVoidingModeButtonPos()) .setSize(16, 16); @@ -338,9 +391,7 @@ protected ButtonWidget createInputSeparationButton(IWidgetBuilder builder) { } return ret.toArray(new IDrawable[0]); }) - .attachSyncer( - new FakeSyncWidget.BooleanSyncer(host::isInputSeparated, host::setInputSeparation), - builder) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(host::isInputSeparated, host::setInputSeparation), builder) .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.input_separation")) .setTooltipShowUpDelay(TOOLTIP_DELAY) .setPos(getInputSeparationButtonPos()) diff --git a/src/main/java/gregtech/common/gui/PartGUIProvider.java b/src/main/java/gregtech/common/gui/PartGUIProvider.java index d71e7c05559..7600444f712 100644 --- a/src/main/java/gregtech/common/gui/PartGUIProvider.java +++ b/src/main/java/gregtech/common/gui/PartGUIProvider.java @@ -11,7 +11,8 @@ import gregtech.api.logic.interfaces.ItemInventoryLogicHost; import gregtech.api.logic.interfaces.PowerLogicHost; -public class PartGUIProvider extends GUIProvider { +public class PartGUIProvider + extends GUIProvider { public PartGUIProvider(@Nonnull T host) { super(host); @@ -28,5 +29,5 @@ protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiCo // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'addWidgets'"); } - + } diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java index 55ccb78928d..a253f6ac1ea 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java @@ -50,7 +50,6 @@ import gregtech.api.multitileentity.multiblock.base.ComplexParallelController; import gregtech.api.multitileentity.multiblock.casing.Glasses; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_StructureUtility; import gregtech.api.util.GT_StructureUtilityMuTE; import gregtech.common.tileentities.machines.multiblock.logic.AdvChemicalProcessorProcessingLogic;