From 52288e8f956231a2a97e50c56baccbdfb7a4cda4 Mon Sep 17 00:00:00 2001 From: serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Sun, 10 Dec 2023 01:12:01 -0600 Subject: [PATCH 01/55] stuff --- .../SimpleMachineMetaTileEntity.java | 119 +++++- .../api/recipes/RecipeMapBuilder.java | 177 ++++++++- .../java/gregtech/api/recipes/RecipeMaps.java | 6 +- .../gregtech/api/recipes/ui/RecipeMapUI.java | 340 ++++++++++++++---- 4 files changed, 561 insertions(+), 81 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 5ecd01baa1a..bc9fff4c2d3 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -1,5 +1,19 @@ package gregtech.api.metatileentity; +import com.cleanroommc.modularui.api.IThemeApi; +import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.manager.GuiCreationContext; +import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.value.BoolValue; +import com.cleanroommc.modularui.value.sync.BooleanSyncValue; +import com.cleanroommc.modularui.value.sync.GuiSyncManager; + +import com.cleanroommc.modularui.value.sync.SyncHandlers; +import com.cleanroommc.modularui.widget.Widget; +import com.cleanroommc.modularui.widgets.ItemSlot; + +import com.cleanroommc.modularui.widgets.ToggleButton; + import gregtech.api.GTValues; import gregtech.api.capability.GregtechTileCapabilities; import gregtech.api.capability.IActiveOutputSide; @@ -21,6 +35,8 @@ import gregtech.api.gui.widgets.ToggleButtonWidget; import gregtech.api.items.itemhandlers.GTItemStackHandler; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.mui.GTGuiTextures; +import gregtech.api.mui.GTGuis; import gregtech.api.recipes.RecipeMap; import gregtech.api.util.GTTransferUtils; import gregtech.api.util.GTUtility; @@ -478,6 +494,104 @@ public void clearMachineInventory(@NotNull List<@NotNull ItemStack> itemBuffer) clearInventory(itemBuffer, chargerInventory); } + @Override + public boolean usesMui2() { + RecipeMap recipeMap = getRecipeMap(); + if (recipeMap == null) return false; + return recipeMap.getRecipeMapUI().usesMui2(); + } + + @Override + public ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManager guiSyncManager, + boolean isClient) { + RecipeMap workableRecipeMap = workable.getRecipeMap(); + int yOffset = 0; + if (workableRecipeMap.getMaxInputs() >= 6 || workableRecipeMap.getMaxFluidInputs() >= 6 || + workableRecipeMap.getMaxOutputs() >= 6 || workableRecipeMap.getMaxFluidOutputs() >= 6) { + yOffset = FONT_HEIGHT; + } + + ModularPanel panel = GTGuis.createPanel(this, 176, 166 + yOffset); + Widget widget = workableRecipeMap.getRecipeMapUI().buildWidget(workable::getProgressPercent, importItems, + exportItems, importFluids, exportFluids, yOffset); + + panel.child(widget) + .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) + .child(new ItemSlot() + .slot(SyncHandlers.itemSlot(chargerInventory, 0)) + // todo block shift-clicking into this slot + .pos(79, 62 + yOffset) + .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY) + .tooltip(t -> t.addLine(IKey.lang("gregtech.gui.charger_slot.tooltip", GTValues.VNF[getTier()], + GTValues.VNF[getTier()])))) + .child(new Widget<>() + .size(18, 18) + .pos(79, 42 + yOffset) + .background(GTGuiTextures.INDICATOR_NO_ENERGY) + // todo this isnt synced, and flicker appears on ui open even when it has enough energy + .setEnabledIf($ -> workable.isHasNotEnoughEnergy())) + .bindPlayerInventory(); + + int leftButtonStartX = 7; + + if (exportItems.getSlots() > 0) { + BooleanSyncValue outputValue = new BooleanSyncValue(() -> autoOutputItems, val -> autoOutputItems = val); + guiSyncManager.syncValue("item_output", outputValue); + + ToggleButton outputButton = new ToggleButton(); + outputButton.value( + new BoolValue.Dynamic(outputValue::getBoolValue, val -> { + outputValue.setBoolValue(val); + outputButton.markTooltipDirty(); + })) + .overlay(GTGuiTextures.BUTTON_ITEM_OUTPUT) + .tooltipBuilder(t -> t.addLine(outputValue.getBoolValue() ? + IKey.lang("gregtech.gui.item_auto_output.tooltip.enabled") : + IKey.lang("gregtech.gui.item_auto_output.tooltip.disabled"))); + + panel.child(outputButton.pos(leftButtonStartX, 62 + yOffset)); + leftButtonStartX += 18; + } + + if (exportFluids.getTanks() > 0) { + BooleanSyncValue outputValue = new BooleanSyncValue(() -> autoOutputFluids, val -> autoOutputFluids = val); + guiSyncManager.syncValue("fluid_output", outputValue); + + ToggleButton outputButton = new ToggleButton(); + outputButton.value( + new BoolValue.Dynamic(outputValue::getBoolValue, val -> { + outputValue.setBoolValue(val); + outputButton.markTooltipDirty(); + })) + .overlay(GTGuiTextures.BUTTON_FLUID_OUTPUT) + .tooltipBuilder(t -> t.addLine(outputValue.getBoolValue() ? + IKey.lang("gregtech.gui.fluid_auto_output.tooltip.enabled") : + IKey.lang("gregtech.gui.fluid_auto_output.tooltip.disabled"))); + + panel.child(outputButton.pos(leftButtonStartX, 62 + yOffset)); + } + + if (exportItems.getSlots() + exportFluids.getTanks() <= 9) { + panel.child(new Widget<>() + .size(17) + .pos(152, 63 + yOffset) + .background(GTGuiTextures.getLogo())); + + if (hasGhostCircuitInventory() && circuitInventory != null) { + panel.child(new gregtech.api.mui.widget.GhostCircuitSlotWidget() + .pos(124, 62 + yOffset) + .slot(SyncHandlers.itemSlot(circuitInventory, 0)) + .background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY)); + } + } + return panel; + } + + @Override + protected ModularUI createUI(EntityPlayer entityPlayer) { + return createGuiTemplate(entityPlayer).build(getHolder(), entityPlayer); + } + protected ModularUI.Builder createGuiTemplate(EntityPlayer player) { RecipeMap workableRecipeMap = workable.getRecipeMap(); int yOffset = 0; @@ -557,11 +671,6 @@ protected void getCircuitSlotTooltip(SlotWidget widget) { widget.setTooltipText("gregtech.gui.configurator_slot.tooltip", configString); } - @Override - protected ModularUI createUI(EntityPlayer entityPlayer) { - return createGuiTemplate(entityPlayer).build(getHolder(), entityPlayer); - } - @Override public void addInformation(ItemStack stack, @Nullable World player, List tooltip, boolean advanced) { super.addInformation(stack, player, tooltip, advanced); diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index 2aa466d5f67..0132059ffba 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -1,5 +1,7 @@ package gregtech.api.recipes; +import com.cleanroommc.modularui.drawable.UITexture; + import gregtech.api.gui.resources.TextureArea; import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.recipes.ui.RecipeMapUI; @@ -11,6 +13,7 @@ import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap; import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,8 +26,6 @@ public class RecipeMapBuilder> { private final String unlocalizedName; private final B defaultRecipeBuilder; - private final Byte2ObjectMap slotOverlays = new Byte2ObjectArrayMap<>(); - private int itemInputs; private boolean modifyItemInputs = true; private int itemOutputs; @@ -51,6 +52,24 @@ public class RecipeMapBuilder> { private boolean sortToBack; + /* MUI 1 */ + + private final Byte2ObjectMap slotOverlays = new Byte2ObjectArrayMap<>(); + + private @Nullable TextureArea progressBar; + private @Nullable ProgressWidget.MoveType moveType; + + private @Nullable TextureArea specialTexture; + + /* MUI 2 */ + + private final Byte2ObjectMap slotOverlayTextures = new Byte2ObjectArrayMap<>(); + + private boolean usesMui2 = false; + private @Nullable UITexture progressTexture; + private @Nullable com.cleanroommc.modularui.widgets.ProgressWidget.Direction progressDirection; + private @Nullable UITexture specialTextureNew; + /** * @param unlocalizedName the name of the recipemap * @param defaultRecipeBuilder the default recipe builder of the recipemap @@ -143,19 +162,35 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip } /** + * @deprecated in favor of the MUI2 method. * @param progressBar the progress bar texture to use * @return this */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull RecipeMapBuilder progressBar(@Nullable TextureArea progressBar) { this.progressBar = progressBar; return this; } /** + * @param progressBar the progress bar texture to use + * @return this + */ + public @NotNull RecipeMapBuilder progressBar(@Nullable UITexture progressBar) { + this.usesMui2 = true; + this.progressTexture = progressBar; + return this; + } + + /** + * @deprecated in favor of the MUI2 method. * @param progressBar the progress bar texture to use * @param moveType the progress bar move type to use * @return this */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull RecipeMapBuilder progressBar(@Nullable TextureArea progressBar, @Nullable ProgressWidget.MoveType moveType) { this.progressBar = progressBar; @@ -164,10 +199,26 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip } /** + * @param progressBar the progress bar texture to use + * @param moveType the progress bar move type to use + * @return this + */ + public @NotNull RecipeMapBuilder progressBar(@Nullable UITexture progressBar, + @Nullable com.cleanroommc.modularui.widgets.ProgressWidget.Direction moveType) { + this.usesMui2 = true; + this.progressTexture = progressBar; + this.progressDirection = moveType; + return this; + } + + /** + * @deprecated in favor of the MUI2 method. * @param texture the texture to use * @param isOutput if the slot is an output slot * @return this */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull RecipeMapBuilder itemSlotOverlay(@NotNull TextureArea texture, boolean isOutput) { this.slotOverlays.put(computeOverlayKey(isOutput, false, false), texture); this.slotOverlays.put(computeOverlayKey(isOutput, false, true), texture); @@ -175,11 +226,26 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip } /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @return this + */ + public @NotNull RecipeMapBuilder itemSlotOverlay(@NotNull UITexture texture, boolean isOutput) { + this.usesMui2 = true; + this.slotOverlayTextures.put(computeOverlayKey(isOutput, false, false), texture); + this.slotOverlayTextures.put(computeOverlayKey(isOutput, false, true), texture); + return this; + } + + /** + * @deprecated in favor of the MUI2 method. * @param texture the texture to use * @param isOutput if the slot is an output slot * @param isLastSlot if the slot is the last slot * @return this */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull RecipeMapBuilder itemSlotOverlay(@NotNull TextureArea texture, boolean isOutput, boolean isLastSlot) { this.slotOverlays.put(computeOverlayKey(isOutput, false, isLastSlot), texture); @@ -187,10 +253,26 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip } /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @param isLastSlot if the slot is the last slot + * @return this + */ + public @NotNull RecipeMapBuilder itemSlotOverlay(@NotNull UITexture texture, boolean isOutput, + boolean isLastSlot) { + this.usesMui2 = true; + this.slotOverlayTextures.put(computeOverlayKey(isOutput, false, isLastSlot), texture); + return this; + } + + /** + * @deprecated in favor of the MUI2 method. * @param texture the texture to use * @param isOutput if the slot is an output slot * @return this */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull RecipeMapBuilder fluidSlotOverlay(@NotNull TextureArea texture, boolean isOutput) { this.slotOverlays.put(computeOverlayKey(isOutput, true, false), texture); this.slotOverlays.put(computeOverlayKey(isOutput, true, true), texture); @@ -198,17 +280,50 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip } /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @return this + */ + public @NotNull RecipeMapBuilder fluidSlotOverlay(@NotNull UITexture texture, boolean isOutput) { + this.usesMui2 = true; + this.slotOverlayTextures.put(computeOverlayKey(isOutput, true, false), texture); + this.slotOverlayTextures.put(computeOverlayKey(isOutput, true, true), texture); + return this; + } + + /** + * @deprecated in favor of the MUI2 method. * @param texture the texture to use * @param isOutput if the slot is an output slot * @param isLastSlot if the slot is the last slot * @return this */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull RecipeMapBuilder fluidSlotOverlay(@NotNull TextureArea texture, boolean isOutput, boolean isLastSlot) { this.slotOverlays.put(computeOverlayKey(isOutput, true, isLastSlot), texture); return this; } + /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @param isLastSlot if the slot is the last slot + * @return this + */ + public @NotNull RecipeMapBuilder fluidSlotOverlay(@NotNull UITexture texture, boolean isOutput, + boolean isLastSlot) { + this.usesMui2 = true; + this.slotOverlayTextures.put(computeOverlayKey(isOutput, true, isLastSlot), texture); + return this; + } + + /** + * @deprecated in favor of the MUI2 method. + */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull RecipeMapBuilder specialTexture(@NotNull TextureArea texture, int x, int y, int width, int height) { this.specialTexture = texture; @@ -216,6 +331,26 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } + public @NotNull RecipeMapBuilder specialTexture(@NotNull UITexture texture, int x, int y, int width, + int height) { + this.usesMui2 = true; + this.specialTextureNew = texture; + this.specialTextureLocation = new int[] { x, y, width, height }; + return this; + } + + /** + * @apiNote Only needed if you do not set textures using MUI2 methods, i.e. the ones that accept + * {@link com.cleanroommc.modularui.drawable.UITexture}. + *
+ * Marked experimental since this method will disappear once MUI2 is fully supported by all GTCEu UIs. + */ + @ApiStatus.Experimental + public @NotNull RecipeMapBuilder usesMui2() { + this.usesMui2 = true; + return this; + } + /** * @param recipeMapUIFunction the custom function for creating the RecipeMap's ui * @return this @@ -232,17 +367,33 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip private @NotNull RecipeMapUI buildUI(@NotNull RecipeMap recipeMap) { RecipeMapUI ui = new RecipeMapUI<>(recipeMap, modifyItemInputs, modifyItemOutputs, modifyFluidInputs, modifyFluidOutputs, isGenerator); - if (progressBar != null) { - ui.setProgressBarTexture(progressBar); - } - if (moveType != null) { - ui.setProgressBarMoveType(moveType); - } - if (specialTexture != null && specialTextureLocation != null) { - ui.setSpecialTexture(specialTexture, specialTextureLocation); - } - for (var entry : slotOverlays.byte2ObjectEntrySet()) { - ui.setSlotOverlay(entry.getByteKey(), entry.getValue()); + if (usesMui2) { + ui.setUsesMui2(); + if (progressTexture != null) { + ui.setProgressBarTexture(progressTexture); + } + if (progressDirection != null) { + ui.setProgressBarDirection(progressDirection); + } + if (specialTextureNew != null && specialTextureLocation != null) { + ui.setSpecialTexture(specialTextureNew, specialTextureLocation); + } + for (var entry : slotOverlayTextures.byte2ObjectEntrySet()) { + ui.setSlotOverlay(entry.getByteKey(), entry.getValue()); + } + } else { + if (progressBar != null) { + ui.setProgressBarTexture(progressBar); + } + if (moveType != null) { + ui.setProgressBarMoveType(moveType); + } + if (specialTexture != null && specialTextureLocation != null) { + ui.setSpecialTexture(specialTexture, specialTextureLocation); + } + for (var entry : slotOverlays.byte2ObjectEntrySet()) { + ui.setSlotOverlay(entry.getByteKey(), entry.getValue()); + } } return ui; diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index 0f17d0609e3..879899b935d 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -4,6 +4,8 @@ import gregtech.api.gui.GuiTextures; import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.gui.widgets.ProgressWidget.MoveType; +import gregtech.api.mui.GTGuiTextures; +import gregtech.api.recipes.builders.AssemblerRecipeBuilder; import gregtech.api.recipes.builders.AssemblyLineRecipeBuilder; import gregtech.api.recipes.builders.BlastRecipeBuilder; import gregtech.api.recipes.builders.CircuitAssemblerRecipeBuilder; @@ -77,8 +79,8 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(2) .itemOutputs(1) - .itemSlotOverlay(GuiTextures.FURNACE_OVERLAY_1, false) - .progressBar(GuiTextures.PROGRESS_BAR_ARROW) + .itemSlotOverlay(GTGuiTextures.FURNACE_OVERLAY_1, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW) .sound(GTSoundEvents.FURNACE) .build(); diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index a6d66d3e62e..5f7149d80b8 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -1,5 +1,17 @@ package gregtech.api.recipes.ui; +import com.cleanroommc.modularui.api.drawable.IDrawable; +import com.cleanroommc.modularui.drawable.UITexture; + +import com.cleanroommc.modularui.value.sync.SyncHandlers; +import com.cleanroommc.modularui.widget.ParentWidget; + +import com.cleanroommc.modularui.widget.Widget; + +import com.cleanroommc.modularui.widgets.FluidSlot; + +import com.cleanroommc.modularui.widgets.ItemSlot; + import gregtech.api.capability.impl.FluidTankList; import gregtech.api.gui.GuiTextures; import gregtech.api.gui.ModularUI; @@ -8,6 +20,8 @@ import gregtech.api.gui.widgets.RecipeProgressWidget; import gregtech.api.gui.widgets.SlotWidget; import gregtech.api.gui.widgets.TankWidget; +import gregtech.api.mui.GTGuiTextures; +import gregtech.api.mui.GTGuis; import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMap; @@ -26,8 +40,6 @@ @ApiStatus.Experimental public class RecipeMapUI> { - private final Byte2ObjectMap slotOverlays = new Byte2ObjectOpenHashMap<>(); - private final R recipeMap; private final boolean modifyItemInputs; private final boolean modifyItemOutputs; @@ -36,12 +48,26 @@ public class RecipeMapUI> { private final boolean isGenerator; + private int @Nullable [] specialTexturePosition; + private boolean isJEIVisible = true; + + /* MUI 1 */ + + private final Byte2ObjectMap slotOverlays = new Byte2ObjectOpenHashMap<>(); + private TextureArea progressBarTexture = GuiTextures.PROGRESS_BAR_ARROW; private ProgressWidget.MoveType moveType = ProgressWidget.MoveType.HORIZONTAL; private @Nullable TextureArea specialTexture; - private int @Nullable [] specialTexturePosition; - private boolean isJEIVisible = true; + /* MUI 2 */ + + private final Byte2ObjectMap slotTextureOverlays = new Byte2ObjectOpenHashMap<>(); + + private boolean usesMui2 = false; + private UITexture progressTexture = GTGuiTextures.PROGRESS_BAR_ARROW; + private com.cleanroommc.modularui.widgets.ProgressWidget.Direction progressDirection = + com.cleanroommc.modularui.widgets.ProgressWidget.Direction.RIGHT; + private @Nullable UITexture specialTextureNew; /** * @param recipeMap the recipemap corresponding to this ui @@ -106,6 +132,8 @@ public static byte computeOverlayKey(boolean isOutput, boolean isFluid, boolean return new int[] { itemSlotsToLeft, itemSlotsToDown }; } + /* MUI 1 */ + /** * Create a JEI UI Template * @@ -116,6 +144,8 @@ public static byte computeOverlayKey(boolean isOutput, boolean isFluid, boolean * @param yOffset the y offset for the gui * @return the populated builder */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { ModularUI.Builder builder = ModularUI.defaultBuilder(yOffset); @@ -140,6 +170,8 @@ public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, * @param yOffset the y offset for the gui * @return the populated builder */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public ModularUI.Builder createUITemplate(DoubleSupplier progressSupplier, IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { @@ -166,6 +198,8 @@ public ModularUI.Builder createUITemplate(DoubleSupplier progressSupplier, IItem * @param yOffset the y offset for the gui * @return the populated builder */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public ModularUI.Builder createUITemplateNoOutputs(DoubleSupplier progressSupplier, IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, @@ -188,6 +222,8 @@ public ModularUI.Builder createUITemplateNoOutputs(DoubleSupplier progressSuppli * @param isOutputs if slots should be output slots * @param yOffset the y offset for the gui */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") protected void addInventorySlotGroup(@NotNull ModularUI.Builder builder, @NotNull IItemHandlerModifiable itemHandler, @NotNull FluidTankList fluidHandler, boolean isOutputs, int yOffset) { @@ -249,6 +285,8 @@ protected void addInventorySlotGroup(@NotNull ModularUI.Builder builder, * @param isFluid if the slot is a fluid slot * @param isOutputs if slots should be output slots */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") protected void addSlot(ModularUI.Builder builder, int x, int y, int slotIndex, IItemHandlerModifiable itemHandler, FluidTankList fluidHandler, boolean isFluid, boolean isOutputs) { if (!isFluid) { @@ -261,24 +299,11 @@ protected void addSlot(ModularUI.Builder builder, int x, int y, int slotIndex, I } } - /** - * @param isOutput if the slot is an output slot - * @param isFluid if the slot is a fluid slot - * @param isLast if the slot is the last slot of its type - * @return the overlays for a slot - */ - protected TextureArea[] getOverlaysForSlot(boolean isOutput, boolean isFluid, boolean isLast) { - TextureArea base = isFluid ? GuiTextures.FLUID_SLOT : GuiTextures.SLOT; - byte overlayKey = computeOverlayKey(isOutput, isFluid, isLast); - if (slotOverlays.containsKey(overlayKey)) { - return new TextureArea[] { base, slotOverlays.get(overlayKey) }; - } - return new TextureArea[] { base }; - } - /** * @return the height used to determine size of background texture in JEI */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public int getPropertyHeightShift() { int maxPropertyCount = 0; if (shouldShiftWidgets()) { @@ -295,14 +320,35 @@ public int getPropertyHeightShift() { /** * @return widgets should be shifted */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") private boolean shouldShiftWidgets() { return recipeMap.getMaxInputs() + recipeMap.getMaxOutputs() >= 6 || recipeMap.getMaxFluidInputs() + recipeMap.getMaxFluidOutputs() >= 6; } + /** + * @param isOutput if the slot is an output slot + * @param isFluid if the slot is a fluid slot + * @param isLast if the slot is the last slot of its type + * @return the overlays for a slot + */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") + protected TextureArea[] getOverlaysForSlot(boolean isOutput, boolean isFluid, boolean isLast) { + TextureArea base = isFluid ? GuiTextures.FLUID_SLOT : GuiTextures.SLOT; + byte overlayKey = computeOverlayKey(isOutput, isFluid, isLast); + if (slotOverlays.containsKey(overlayKey)) { + return new TextureArea[] { base, slotOverlays.get(overlayKey) }; + } + return new TextureArea[] { base }; + } + /** * @return the progress bar's move type */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull ProgressWidget.MoveType progressBarMoveType() { return moveType; } @@ -310,6 +356,8 @@ private boolean shouldShiftWidgets() { /** * @param moveType the new progress bar move type */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public void setProgressBarMoveType(@NotNull ProgressWidget.MoveType moveType) { this.moveType = moveType; } @@ -317,6 +365,8 @@ public void setProgressBarMoveType(@NotNull ProgressWidget.MoveType moveType) { /** * @return the texture of the progress bar */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull TextureArea progressBarTexture() { return progressBarTexture; } @@ -324,6 +374,8 @@ public void setProgressBarMoveType(@NotNull ProgressWidget.MoveType moveType) { /** * @param progressBarTexture the new progress bar texture */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public void setProgressBarTexture(@NotNull TextureArea progressBarTexture) { this.progressBarTexture = progressBarTexture; } @@ -332,6 +384,8 @@ public void setProgressBarTexture(@NotNull TextureArea progressBarTexture) { * @param progressBarTexture the new progress bar texture * @param moveType the new progress bar move type */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public void setProgressBar(@NotNull TextureArea progressBarTexture, @NotNull ProgressWidget.MoveType moveType) { this.progressBarTexture = progressBarTexture; this.moveType = moveType; @@ -344,6 +398,8 @@ public void setProgressBar(@NotNull TextureArea progressBarTexture, @NotNull Pro * @param width the width of the texture * @param height the height of the texture */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public void setSpecialTexture(@NotNull TextureArea specialTexture, int x, int y, int width, int height) { setSpecialTexture(specialTexture, new int[] { x, y, width, height }); } @@ -352,6 +408,8 @@ public void setSpecialTexture(@NotNull TextureArea specialTexture, int x, int y, * @param specialTexture the special texture to set * @param position the position of the texture: [x, y, width, height] */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public void setSpecialTexture(@NotNull TextureArea specialTexture, int @NotNull [] position) { this.specialTexture = specialTexture; this.specialTexturePosition = position; @@ -360,6 +418,8 @@ public void setSpecialTexture(@NotNull TextureArea specialTexture, int @NotNull /** * @return the special texture */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @Nullable TextureArea specialTexture() { return this.specialTexture; } @@ -377,6 +437,8 @@ public void setSpecialTexture(@NotNull TextureArea specialTexture, int @NotNull * @param builder the builder to add to * @return the updated builder */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull ModularUI.Builder addSpecialTexture(@NotNull ModularUI.Builder builder) { if (specialTexturePosition != null) { builder.image(specialTexturePosition[0], specialTexturePosition[1], @@ -386,48 +448,6 @@ public void setSpecialTexture(@NotNull TextureArea specialTexture, int @NotNull return builder; } - /** - * @return if this ui should be visible in JEI - */ - public boolean isJEIVisible() { - return isJEIVisible; - } - - /** - * @param isJEIVisible if the ui should be visible in JEI - */ - public void setJEIVisible(boolean isJEIVisible) { - this.isJEIVisible = isJEIVisible; - } - - /** - * @return if item input slot amounts can be modified - */ - public boolean canModifyItemInputs() { - return modifyItemInputs; - } - - /** - * @return if item output slot amounts can be modified - */ - public boolean canModifyItemOutputs() { - return modifyItemOutputs; - } - - /** - * @return if fluid input slot amounts can be modified - */ - public boolean canModifyFluidInputs() { - return modifyFluidInputs; - } - - /** - * @return if fluid output slot amounts can be modified - */ - public boolean canModifyFluidOutputs() { - return modifyFluidOutputs; - } - /** * @return if this UI represents an energy generating recipemap */ @@ -439,6 +459,8 @@ public boolean isGenerator() { * @param texture the texture to set * @param isOutput if the slot is an output slot */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public void setItemSlotOverlay(@NotNull TextureArea texture, boolean isOutput) { this.slotOverlays.put(computeOverlayKey(isOutput, false, false), texture); this.slotOverlays.put(computeOverlayKey(isOutput, false, true), texture); @@ -449,6 +471,8 @@ public void setItemSlotOverlay(@NotNull TextureArea texture, boolean isOutput) { * @param isOutput if the slot is an output slot * @param isLastSlot if the slot is the last slot */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public void setItemSlotOverlay(@NotNull TextureArea texture, boolean isOutput, boolean isLastSlot) { this.slotOverlays.put(computeOverlayKey(isOutput, false, isLastSlot), texture); } @@ -457,6 +481,8 @@ public void setItemSlotOverlay(@NotNull TextureArea texture, boolean isOutput, b * @param texture the texture to set * @param isOutput if the slot is an output slot */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public void setFluidSlotOverlay(@NotNull TextureArea texture, boolean isOutput) { this.slotOverlays.put(computeOverlayKey(isOutput, true, false), texture); this.slotOverlays.put(computeOverlayKey(isOutput, true, true), texture); @@ -467,6 +493,8 @@ public void setFluidSlotOverlay(@NotNull TextureArea texture, boolean isOutput) * @param isOutput if the slot is an output slot * @param isLastSlot if the slot is the last slot */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public void setFluidSlotOverlay(@NotNull TextureArea texture, boolean isOutput, boolean isLastSlot) { this.slotOverlays.put(computeOverlayKey(isOutput, true, isLastSlot), texture); } @@ -475,11 +503,201 @@ public void setFluidSlotOverlay(@NotNull TextureArea texture, boolean isOutput, * @param key the key to store the slot's texture with * @param texture the texture to store */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") @ApiStatus.Internal public void setSlotOverlay(byte key, @NotNull TextureArea texture) { this.slotOverlays.put(key, texture); } + /* MUI 2 */ + + public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandlerModifiable importItems, + IItemHandlerModifiable exportItems, FluidTankList importFluids, + FluidTankList exportFluids, int yOffset) { + ParentWidget group = new ParentWidget<>().size(176, 166 + yOffset); + // todo import + group.child(new com.cleanroommc.modularui.widgets.ProgressWidget() + .size(20) + .alignX(0.5f).top(23 + yOffset) + .progress(progressSupplier) + .texture(progressTexture, 20) + .direction(progressDirection)); + addInventorySlotGroup(group, importItems, importFluids, false, yOffset); + addInventorySlotGroup(group, exportItems, exportFluids, true, yOffset); + if (specialTextureNew != null && specialTexturePosition != null) { + group.child(new Widget<>() + .pos(specialTexturePosition[0], specialTexturePosition[1]) + .size(specialTexturePosition[2], specialTexturePosition[3]) + .background(specialTextureNew)); + } + return group; + } + + protected void addInventorySlotGroup(@NotNull ParentWidget group, + @NotNull IItemHandlerModifiable itemHandler, + @NotNull FluidTankList fluidHandler, boolean isOutputs, int yOffset) { + int itemInputsCount = itemHandler.getSlots(); + int fluidInputsCount = fluidHandler.getTanks(); + boolean invertFluids = false; + if (itemInputsCount == 0) { + int tmp = itemInputsCount; + itemInputsCount = fluidInputsCount; + fluidInputsCount = tmp; + invertFluids = true; + } + int[] inputSlotGrid = determineSlotsGrid(itemInputsCount); + int itemSlotsToLeft = inputSlotGrid[0]; + int itemSlotsToDown = inputSlotGrid[1]; + int startInputsX = isOutputs ? 106 : 70 - itemSlotsToLeft * 18; + int startInputsY = 33 - (int) (itemSlotsToDown / 2.0 * 18) + yOffset; + boolean wasGroup = itemHandler.getSlots() + fluidHandler.getTanks() == 12; + if (wasGroup) startInputsY -= 9; + else if (itemHandler.getSlots() >= 6 && fluidHandler.getTanks() >= 2 && !isOutputs) startInputsY -= 9; + for (int i = 0; i < itemSlotsToDown; i++) { + for (int j = 0; j < itemSlotsToLeft; j++) { + int slotIndex = i * itemSlotsToLeft + j; + if (slotIndex >= itemInputsCount) break; + int x = startInputsX + 18 * j; + int y = startInputsY + 18 * i; + addSlot(group, x, y, slotIndex, itemHandler, fluidHandler, invertFluids, isOutputs); + } + } + if (wasGroup) startInputsY += 2; + if (fluidInputsCount > 0 || invertFluids) { + if (itemSlotsToDown >= fluidInputsCount && itemSlotsToLeft < 3) { + int startSpecX = isOutputs ? startInputsX + itemSlotsToLeft * 18 : startInputsX - 18; + for (int i = 0; i < fluidInputsCount; i++) { + int y = startInputsY + 18 * i; + addSlot(group, startSpecX, y, i, itemHandler, fluidHandler, !invertFluids, isOutputs); + } + } else { + int startSpecY = startInputsY + itemSlotsToDown * 18; + for (int i = 0; i < fluidInputsCount; i++) { + int x = isOutputs ? startInputsX + 18 * (i % 3) : + startInputsX + itemSlotsToLeft * 18 - 18 - 18 * (i % 3); + int y = startSpecY + (i / 3) * 18; + addSlot(group, x, y, i, itemHandler, fluidHandler, !invertFluids, isOutputs); + } + } + } + } + + protected void addSlot(ParentWidget group, int x, int y, int slotIndex, IItemHandlerModifiable itemHandler, + FluidTankList fluidHandler, boolean isFluid, boolean isOutputs) { + if (!isFluid) { + group.child(new ItemSlot() + .slot(SyncHandlers.itemSlot(itemHandler, slotIndex) + .accessibility(!isOutputs, true)) + .pos(x, y) + .background(getOverlaysForSlotNew(isOutputs, false, slotIndex == itemHandler.getSlots() - 1))); + } else { + group.child(new FluidSlot() + .syncHandler(SyncHandlers.fluidSlot(fluidHandler.getTankAt(slotIndex)) + .canFillSlot(!isOutputs)) + .alwaysShowFull(true) + .pos(x, y) + .background(getOverlaysForSlotNew(isOutputs, true, slotIndex == fluidHandler.getTanks() - 1))); + } + } + + @ApiStatus.Experimental + protected IDrawable[] getOverlaysForSlotNew(boolean isOutput, boolean isFluid, boolean isLast) { + UITexture base = isFluid ? GTGuiTextures.FLUID_SLOT : GTGuiTextures.SLOT; + byte overlayKey = computeOverlayKey(isOutput, isFluid, isLast); + if (slotTextureOverlays.containsKey(overlayKey)) { + return new UITexture[] { base, slotTextureOverlays.get(overlayKey) }; + } + return new UITexture[] { base }; + } + + /** Marked experimental as this method will be removed when all GTCEu UIs are ported to MUI2. */ + @ApiStatus.Experimental + @ApiStatus.Internal + public void setUsesMui2() { + this.usesMui2 = true; + } + + /** Marked experimental as this method will be removed when all GTCEu UIs are ported to MUI2. */ + @ApiStatus.Experimental + public boolean usesMui2() { + return usesMui2; + } + + /** + * @param progressTexture the new progress bar texture + */ + public void setProgressBarTexture(@NotNull UITexture progressTexture) { + this.progressTexture = progressTexture; + } + + /** + * @param direction the new progress bar move type + */ + public void setProgressBarDirection(@NotNull com.cleanroommc.modularui.widgets.ProgressWidget.Direction direction) { + this.progressDirection = direction; + } + + /** + * @param specialTexture the special texture to set + * @param position the position of the texture: [x, y, width, height] + */ + public void setSpecialTexture(@NotNull UITexture specialTexture, int @NotNull [] position) { + this.specialTextureNew = specialTexture; + this.specialTexturePosition = position; + } + + /** + * @param key the key to store the slot's texture with + * @param texture the texture to store + */ + @ApiStatus.Internal + public void setSlotOverlay(byte key, @NotNull UITexture texture) { + this.slotTextureOverlays.put(key, texture); + } + + /** + * @return if this ui should be visible in JEI + */ + public boolean isJEIVisible() { + return isJEIVisible; + } + + /** + * @param isJEIVisible if the ui should be visible in JEI + */ + public void setJEIVisible(boolean isJEIVisible) { + this.isJEIVisible = isJEIVisible; + } + + /** + * @return if item input slot amounts can be modified + */ + public boolean canModifyItemInputs() { + return modifyItemInputs; + } + + /** + * @return if item output slot amounts can be modified + */ + public boolean canModifyItemOutputs() { + return modifyItemOutputs; + } + + /** + * @return if fluid input slot amounts can be modified + */ + public boolean canModifyFluidInputs() { + return modifyFluidInputs; + } + + /** + * @return if fluid output slot amounts can be modified + */ + public boolean canModifyFluidOutputs() { + return modifyFluidOutputs; + } + /** * @return the UI's recipemap */ From fa6c9b46b64d44a3d6fe3da4d20ca9a80e98229e Mon Sep 17 00:00:00 2001 From: serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Sun, 10 Dec 2023 01:34:07 -0600 Subject: [PATCH 02/55] group slots, fix shift clicking --- .../SimpleMachineMetaTileEntity.java | 4 +- .../gregtech/api/recipes/ui/RecipeMapUI.java | 57 ++++++++++++------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index bc9fff4c2d3..87a80ab50d0 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -12,8 +12,11 @@ import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widgets.ItemSlot; +import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.ToggleButton; +import com.cleanroommc.modularui.widgets.slot.SlotGroup; + import gregtech.api.GTValues; import gregtech.api.capability.GregtechTileCapabilities; import gregtech.api.capability.IActiveOutputSide; @@ -519,7 +522,6 @@ public ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManage .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) .child(new ItemSlot() .slot(SyncHandlers.itemSlot(chargerInventory, 0)) - // todo block shift-clicking into this slot .pos(79, 62 + yOffset) .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY) .tooltip(t -> t.addLine(IKey.lang("gregtech.gui.charger_slot.tooltip", GTValues.VNF[getTier()], diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 5f7149d80b8..9697ab05d05 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -12,6 +12,8 @@ import com.cleanroommc.modularui.widgets.ItemSlot; +import com.cleanroommc.modularui.widgets.slot.SlotGroup; + import gregtech.api.capability.impl.FluidTankList; import gregtech.api.gui.GuiTextures; import gregtech.api.gui.ModularUI; @@ -25,6 +27,7 @@ import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMap; +import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.items.IItemHandlerModifiable; import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; @@ -554,13 +557,20 @@ protected void addInventorySlotGroup(@NotNull ParentWidget group, boolean wasGroup = itemHandler.getSlots() + fluidHandler.getTanks() == 12; if (wasGroup) startInputsY -= 9; else if (itemHandler.getSlots() >= 6 && fluidHandler.getTanks() >= 2 && !isOutputs) startInputsY -= 9; + + SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", itemSlotsToLeft, 1, !isOutputs); + for (int i = 0; i < itemSlotsToDown; i++) { for (int j = 0; j < itemSlotsToLeft; j++) { int slotIndex = i * itemSlotsToLeft + j; if (slotIndex >= itemInputsCount) break; int x = startInputsX + 18 * j; int y = startInputsY + 18 * i; - addSlot(group, x, y, slotIndex, itemHandler, fluidHandler, invertFluids, isOutputs); + if (invertFluids) { + group.child(makeFluidSlot(x, y, slotIndex, fluidHandler, isOutputs)); + } else { + group.child(makeItemSlot(slotGroup, x, y, slotIndex, itemHandler, isOutputs)); + } } } if (wasGroup) startInputsY += 2; @@ -569,7 +579,11 @@ protected void addInventorySlotGroup(@NotNull ParentWidget group, int startSpecX = isOutputs ? startInputsX + itemSlotsToLeft * 18 : startInputsX - 18; for (int i = 0; i < fluidInputsCount; i++) { int y = startInputsY + 18 * i; - addSlot(group, startSpecX, y, i, itemHandler, fluidHandler, !invertFluids, isOutputs); + if (!invertFluids) { + group.child(makeFluidSlot(startSpecX, y, i, fluidHandler, isOutputs)); + } else { + group.child(makeItemSlot(slotGroup, startSpecX, y, i, itemHandler, isOutputs)); + } } } else { int startSpecY = startInputsY + itemSlotsToDown * 18; @@ -577,28 +591,33 @@ protected void addInventorySlotGroup(@NotNull ParentWidget group, int x = isOutputs ? startInputsX + 18 * (i % 3) : startInputsX + itemSlotsToLeft * 18 - 18 - 18 * (i % 3); int y = startSpecY + (i / 3) * 18; - addSlot(group, x, y, i, itemHandler, fluidHandler, !invertFluids, isOutputs); + if (!invertFluids) { + group.child(makeFluidSlot(x, y, i, fluidHandler, isOutputs)); + } else { + group.child(makeItemSlot(slotGroup, x, y, i, itemHandler, isOutputs)); + } } } } } - protected void addSlot(ParentWidget group, int x, int y, int slotIndex, IItemHandlerModifiable itemHandler, - FluidTankList fluidHandler, boolean isFluid, boolean isOutputs) { - if (!isFluid) { - group.child(new ItemSlot() - .slot(SyncHandlers.itemSlot(itemHandler, slotIndex) - .accessibility(!isOutputs, true)) - .pos(x, y) - .background(getOverlaysForSlotNew(isOutputs, false, slotIndex == itemHandler.getSlots() - 1))); - } else { - group.child(new FluidSlot() - .syncHandler(SyncHandlers.fluidSlot(fluidHandler.getTankAt(slotIndex)) - .canFillSlot(!isOutputs)) - .alwaysShowFull(true) - .pos(x, y) - .background(getOverlaysForSlotNew(isOutputs, true, slotIndex == fluidHandler.getTanks() - 1))); - } + protected ItemSlot makeItemSlot(SlotGroup group, int x, int y, int slotIndex, IItemHandlerModifiable itemHandler, + boolean isOutputs) { + return new ItemSlot() + .slot(SyncHandlers.itemSlot(itemHandler, slotIndex) + .slotGroup(group) + .accessibility(!isOutputs, true)) + .pos(x, y) + .background(getOverlaysForSlotNew(isOutputs, false, slotIndex == itemHandler.getSlots() - 1)); + } + + protected FluidSlot makeFluidSlot(int x, int y, int slotIndex, FluidTankList fluidHandler, boolean isOutputs) { + return new FluidSlot() + .syncHandler(SyncHandlers.fluidSlot(fluidHandler.getTankAt(slotIndex)) + .canFillSlot(!isOutputs)) + .alwaysShowFull(true) + .pos(x, y) + .background(getOverlaysForSlotNew(isOutputs, true, slotIndex == fluidHandler.getTanks() - 1)); } @ApiStatus.Experimental From 5acd5fda6a107d665b2cf67814cf86b256f6a291 Mon Sep 17 00:00:00 2001 From: serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Sun, 10 Dec 2023 01:43:56 -0600 Subject: [PATCH 03/55] clean up toggle buttons --- .../SimpleMachineMetaTileEntity.java | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 87a80ab50d0..98011034c81 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -540,18 +540,15 @@ public ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManage BooleanSyncValue outputValue = new BooleanSyncValue(() -> autoOutputItems, val -> autoOutputItems = val); guiSyncManager.syncValue("item_output", outputValue); - ToggleButton outputButton = new ToggleButton(); - outputButton.value( - new BoolValue.Dynamic(outputValue::getBoolValue, val -> { - outputValue.setBoolValue(val); - outputButton.markTooltipDirty(); - })) + panel.child(new ToggleButton() + .pos(leftButtonStartX, 62 + yOffset) + .value(new BoolValue.Dynamic(outputValue::getBoolValue, outputValue::setBoolValue)) .overlay(GTGuiTextures.BUTTON_ITEM_OUTPUT) - .tooltipBuilder(t -> t.addLine(outputValue.getBoolValue() ? - IKey.lang("gregtech.gui.item_auto_output.tooltip.enabled") : - IKey.lang("gregtech.gui.item_auto_output.tooltip.disabled"))); - - panel.child(outputButton.pos(leftButtonStartX, 62 + yOffset)); + .tooltipBuilder(t -> t + .setAutoUpdate(true) + .addLine(outputValue.getBoolValue() ? + IKey.lang("gregtech.gui.item_auto_output.tooltip.enabled") : + IKey.lang("gregtech.gui.item_auto_output.tooltip.disabled")))); leftButtonStartX += 18; } @@ -559,18 +556,15 @@ public ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManage BooleanSyncValue outputValue = new BooleanSyncValue(() -> autoOutputFluids, val -> autoOutputFluids = val); guiSyncManager.syncValue("fluid_output", outputValue); - ToggleButton outputButton = new ToggleButton(); - outputButton.value( - new BoolValue.Dynamic(outputValue::getBoolValue, val -> { - outputValue.setBoolValue(val); - outputButton.markTooltipDirty(); - })) + panel.child(new ToggleButton() + .pos(leftButtonStartX, 62 + yOffset) + .value(new BoolValue.Dynamic(outputValue::getBoolValue, outputValue::setBoolValue)) .overlay(GTGuiTextures.BUTTON_FLUID_OUTPUT) - .tooltipBuilder(t -> t.addLine(outputValue.getBoolValue() ? - IKey.lang("gregtech.gui.fluid_auto_output.tooltip.enabled") : - IKey.lang("gregtech.gui.fluid_auto_output.tooltip.disabled"))); - - panel.child(outputButton.pos(leftButtonStartX, 62 + yOffset)); + .tooltipBuilder(t -> t + .setAutoUpdate(true) + .addLine(outputValue.getBoolValue() ? + IKey.lang("gregtech.gui.fluid_auto_output.tooltip.enabled") : + IKey.lang("gregtech.gui.fluid_auto_output.tooltip.disabled")))); } if (exportItems.getSlots() + exportFluids.getTanks() <= 9) { From 707f89bf912bdbb45c11486502a2e9e29f0b3e2d Mon Sep 17 00:00:00 2001 From: serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Sun, 10 Dec 2023 02:07:47 -0600 Subject: [PATCH 04/55] cleanups --- .../SimpleMachineMetaTileEntity.java | 33 ++++------ .../api/recipes/RecipeMapBuilder.java | 33 +++++----- .../gregtech/api/recipes/ui/RecipeMapUI.java | 60 +++++++++---------- 3 files changed, 60 insertions(+), 66 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 98011034c81..557195e98e4 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -1,22 +1,5 @@ package gregtech.api.metatileentity; -import com.cleanroommc.modularui.api.IThemeApi; -import com.cleanroommc.modularui.api.drawable.IKey; -import com.cleanroommc.modularui.manager.GuiCreationContext; -import com.cleanroommc.modularui.screen.ModularPanel; -import com.cleanroommc.modularui.value.BoolValue; -import com.cleanroommc.modularui.value.sync.BooleanSyncValue; -import com.cleanroommc.modularui.value.sync.GuiSyncManager; - -import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widget.Widget; -import com.cleanroommc.modularui.widgets.ItemSlot; - -import com.cleanroommc.modularui.widgets.SlotGroupWidget; -import com.cleanroommc.modularui.widgets.ToggleButton; - -import com.cleanroommc.modularui.widgets.slot.SlotGroup; - import gregtech.api.GTValues; import gregtech.api.capability.GregtechTileCapabilities; import gregtech.api.capability.IActiveOutputSide; @@ -73,6 +56,16 @@ import codechicken.lib.render.CCRenderState; import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; +import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.manager.GuiCreationContext; +import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.value.BoolValue; +import com.cleanroommc.modularui.value.sync.BooleanSyncValue; +import com.cleanroommc.modularui.value.sync.GuiSyncManager; +import com.cleanroommc.modularui.value.sync.SyncHandlers; +import com.cleanroommc.modularui.widget.Widget; +import com.cleanroommc.modularui.widgets.ItemSlot; +import com.cleanroommc.modularui.widgets.ToggleButton; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -516,7 +509,7 @@ public ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManage ModularPanel panel = GTGuis.createPanel(this, 176, 166 + yOffset); Widget widget = workableRecipeMap.getRecipeMapUI().buildWidget(workable::getProgressPercent, importItems, - exportItems, importFluids, exportFluids, yOffset); + exportItems, importFluids, exportFluids, yOffset); panel.child(widget) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) @@ -538,7 +531,7 @@ public ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManage if (exportItems.getSlots() > 0) { BooleanSyncValue outputValue = new BooleanSyncValue(() -> autoOutputItems, val -> autoOutputItems = val); - guiSyncManager.syncValue("item_output", outputValue); + guiSyncManager.syncValue("item_auto_output", outputValue); panel.child(new ToggleButton() .pos(leftButtonStartX, 62 + yOffset) @@ -554,7 +547,7 @@ public ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManage if (exportFluids.getTanks() > 0) { BooleanSyncValue outputValue = new BooleanSyncValue(() -> autoOutputFluids, val -> autoOutputFluids = val); - guiSyncManager.syncValue("fluid_output", outputValue); + guiSyncManager.syncValue("fluid_auto_output", outputValue); panel.child(new ToggleButton() .pos(leftButtonStartX, 62 + yOffset) diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index 0132059ffba..7b3e701c71c 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -1,15 +1,14 @@ package gregtech.api.recipes; -import com.cleanroommc.modularui.drawable.UITexture; - import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.recipes.ui.RecipeMapUI; import gregtech.api.recipes.ui.RecipeMapUIFunction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; +import com.cleanroommc.modularui.drawable.UITexture; +import com.cleanroommc.modularui.widgets.ProgressWidget; import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap; import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; @@ -52,22 +51,27 @@ public class RecipeMapBuilder> { private boolean sortToBack; - /* MUI 1 */ + /* *********************** MUI 1 *********************** */ + @Deprecated private final Byte2ObjectMap slotOverlays = new Byte2ObjectArrayMap<>(); - + @Deprecated private @Nullable TextureArea progressBar; - private @Nullable ProgressWidget.MoveType moveType; - + @Deprecated + private @Nullable gregtech.api.gui.widgets.ProgressWidget.MoveType moveType; + @Deprecated private @Nullable TextureArea specialTexture; - /* MUI 2 */ + /* *********************** MUI 2 *********************** */ + // todo try to store this better private final Byte2ObjectMap slotOverlayTextures = new Byte2ObjectArrayMap<>(); + @ApiStatus.Experimental private boolean usesMui2 = false; private @Nullable UITexture progressTexture; - private @Nullable com.cleanroommc.modularui.widgets.ProgressWidget.Direction progressDirection; + private @Nullable ProgressWidget.Direction progressDirection; + // todo sus name private @Nullable UITexture specialTextureNew; /** @@ -192,7 +196,7 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull RecipeMapBuilder progressBar(@Nullable TextureArea progressBar, - @Nullable ProgressWidget.MoveType moveType) { + @Nullable gregtech.api.gui.widgets.ProgressWidget.MoveType moveType) { this.progressBar = progressBar; this.moveType = moveType; return this; @@ -204,7 +208,7 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip * @return this */ public @NotNull RecipeMapBuilder progressBar(@Nullable UITexture progressBar, - @Nullable com.cleanroommc.modularui.widgets.ProgressWidget.Direction moveType) { + @Nullable ProgressWidget.Direction moveType) { this.usesMui2 = true; this.progressTexture = progressBar; this.progressDirection = moveType; @@ -340,10 +344,9 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip } /** - * @apiNote Only needed if you do not set textures using MUI2 methods, i.e. the ones that accept - * {@link com.cleanroommc.modularui.drawable.UITexture}. - *
- * Marked experimental since this method will disappear once MUI2 is fully supported by all GTCEu UIs. + * @apiNote Only needed if you do not set textures using MUI2 methods, i.e. the ones that accept{@link UITexture}. + *
+ * Marked experimental since this method will disappear once MUI2 is fully supported by all GTCEu UIs. */ @ApiStatus.Experimental public @NotNull RecipeMapBuilder usesMui2() { diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 9697ab05d05..0a7f22779fa 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -1,35 +1,27 @@ package gregtech.api.recipes.ui; -import com.cleanroommc.modularui.api.drawable.IDrawable; -import com.cleanroommc.modularui.drawable.UITexture; - -import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widget.ParentWidget; - -import com.cleanroommc.modularui.widget.Widget; - -import com.cleanroommc.modularui.widgets.FluidSlot; - -import com.cleanroommc.modularui.widgets.ItemSlot; - -import com.cleanroommc.modularui.widgets.slot.SlotGroup; - import gregtech.api.capability.impl.FluidTankList; import gregtech.api.gui.GuiTextures; import gregtech.api.gui.ModularUI; import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.gui.widgets.RecipeProgressWidget; import gregtech.api.gui.widgets.SlotWidget; import gregtech.api.gui.widgets.TankWidget; import gregtech.api.mui.GTGuiTextures; -import gregtech.api.mui.GTGuis; import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMap; -import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.items.IItemHandlerModifiable; +import com.cleanroommc.modularui.api.drawable.IDrawable; +import com.cleanroommc.modularui.drawable.UITexture; +import com.cleanroommc.modularui.value.sync.SyncHandlers; +import com.cleanroommc.modularui.widget.ParentWidget; +import com.cleanroommc.modularui.widget.Widget; +import com.cleanroommc.modularui.widgets.FluidSlot; +import com.cleanroommc.modularui.widgets.ItemSlot; +import com.cleanroommc.modularui.widgets.ProgressWidget; +import com.cleanroommc.modularui.widgets.slot.SlotGroup; import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; import it.unimi.dsi.fastutil.bytes.Byte2ObjectOpenHashMap; import org.jetbrains.annotations.ApiStatus; @@ -54,22 +46,28 @@ public class RecipeMapUI> { private int @Nullable [] specialTexturePosition; private boolean isJEIVisible = true; - /* MUI 1 */ + /* *********************** MUI 1 *********************** */ + @Deprecated private final Byte2ObjectMap slotOverlays = new Byte2ObjectOpenHashMap<>(); + @Deprecated private TextureArea progressBarTexture = GuiTextures.PROGRESS_BAR_ARROW; - private ProgressWidget.MoveType moveType = ProgressWidget.MoveType.HORIZONTAL; + @Deprecated + private gregtech.api.gui.widgets.ProgressWidget.MoveType moveType = gregtech.api.gui.widgets.ProgressWidget.MoveType.HORIZONTAL; + @Deprecated private @Nullable TextureArea specialTexture; - /* MUI 2 */ + /* *********************** MUI 2 *********************** */ + // todo try to store this better private final Byte2ObjectMap slotTextureOverlays = new Byte2ObjectOpenHashMap<>(); + @ApiStatus.Experimental private boolean usesMui2 = false; private UITexture progressTexture = GTGuiTextures.PROGRESS_BAR_ARROW; - private com.cleanroommc.modularui.widgets.ProgressWidget.Direction progressDirection = - com.cleanroommc.modularui.widgets.ProgressWidget.Direction.RIGHT; + private ProgressWidget.Direction progressDirection = ProgressWidget.Direction.RIGHT; + // todo sus name private @Nullable UITexture specialTextureNew; /** @@ -135,7 +133,7 @@ public static byte computeOverlayKey(boolean isOutput, boolean isFluid, boolean return new int[] { itemSlotsToLeft, itemSlotsToDown }; } - /* MUI 1 */ + /* *********************** MUI 1 *********************** */ /** * Create a JEI UI Template @@ -352,7 +350,7 @@ protected TextureArea[] getOverlaysForSlot(boolean isOutput, boolean isFluid, bo */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "2.9") - public @NotNull ProgressWidget.MoveType progressBarMoveType() { + public @NotNull gregtech.api.gui.widgets.ProgressWidget.MoveType progressBarMoveType() { return moveType; } @@ -361,7 +359,7 @@ protected TextureArea[] getOverlaysForSlot(boolean isOutput, boolean isFluid, bo */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "2.9") - public void setProgressBarMoveType(@NotNull ProgressWidget.MoveType moveType) { + public void setProgressBarMoveType(@NotNull gregtech.api.gui.widgets.ProgressWidget.MoveType moveType) { this.moveType = moveType; } @@ -389,7 +387,8 @@ public void setProgressBarTexture(@NotNull TextureArea progressBarTexture) { */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "2.9") - public void setProgressBar(@NotNull TextureArea progressBarTexture, @NotNull ProgressWidget.MoveType moveType) { + public void setProgressBar(@NotNull TextureArea progressBarTexture, + @NotNull gregtech.api.gui.widgets.ProgressWidget.MoveType moveType) { this.progressBarTexture = progressBarTexture; this.moveType = moveType; } @@ -513,14 +512,13 @@ public void setSlotOverlay(byte key, @NotNull TextureArea texture) { this.slotOverlays.put(key, texture); } - /* MUI 2 */ + /* *********************** MUI 2 *********************** */ public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { ParentWidget group = new ParentWidget<>().size(176, 166 + yOffset); - // todo import - group.child(new com.cleanroommc.modularui.widgets.ProgressWidget() + group.child(new ProgressWidget() .size(20) .alignX(0.5f).top(23 + yOffset) .progress(progressSupplier) @@ -602,7 +600,7 @@ protected void addInventorySlotGroup(@NotNull ParentWidget group, } protected ItemSlot makeItemSlot(SlotGroup group, int x, int y, int slotIndex, IItemHandlerModifiable itemHandler, - boolean isOutputs) { + boolean isOutputs) { return new ItemSlot() .slot(SyncHandlers.itemSlot(itemHandler, slotIndex) .slotGroup(group) @@ -653,7 +651,7 @@ public void setProgressBarTexture(@NotNull UITexture progressTexture) { /** * @param direction the new progress bar move type */ - public void setProgressBarDirection(@NotNull com.cleanroommc.modularui.widgets.ProgressWidget.Direction direction) { + public void setProgressBarDirection(@NotNull ProgressWidget.Direction direction) { this.progressDirection = direction; } From 56f1ecd9e4a3fc9146885ef257b43d58189b28a9 Mon Sep 17 00:00:00 2001 From: serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Sun, 17 Dec 2023 13:55:36 -0600 Subject: [PATCH 05/55] 2.4 fix --- .../api/metatileentity/SimpleMachineMetaTileEntity.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 557195e98e4..99dbc92c0df 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -57,7 +57,7 @@ import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; import com.cleanroommc.modularui.api.drawable.IKey; -import com.cleanroommc.modularui.manager.GuiCreationContext; +import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.value.BoolValue; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; @@ -498,8 +498,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManager guiSyncManager, - boolean isClient) { + public ModularPanel buildUI(PosGuiData guiData, GuiSyncManager guiSyncManager) { RecipeMap workableRecipeMap = workable.getRecipeMap(); int yOffset = 0; if (workableRecipeMap.getMaxInputs() >= 6 || workableRecipeMap.getMaxFluidInputs() >= 6 || From 7c18f9afe3e524d7aec06ce09071791f59aa151e Mon Sep 17 00:00:00 2001 From: serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:01:21 -0600 Subject: [PATCH 06/55] Logo as part of GTGuiTheme --- .../api/metatileentity/SimpleMachineMetaTileEntity.java | 3 ++- src/main/java/gregtech/api/mui/GTGuiTextures.java | 1 + src/main/java/gregtech/api/mui/GTGuiTheme.java | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 99dbc92c0df..4f4dfc163cb 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -563,7 +563,7 @@ public ModularPanel buildUI(PosGuiData guiData, GuiSyncManager guiSyncManager) { panel.child(new Widget<>() .size(17) .pos(152, 63 + yOffset) - .background(GTGuiTextures.getLogo())); + .background(GTGuiTextures.getLogo(getUITheme()))); if (hasGhostCircuitInventory() && circuitInventory != null) { panel.child(new gregtech.api.mui.widget.GhostCircuitSlotWidget() @@ -580,6 +580,7 @@ protected ModularUI createUI(EntityPlayer entityPlayer) { return createGuiTemplate(entityPlayer).build(getHolder(), entityPlayer); } + @Deprecated protected ModularUI.Builder createGuiTemplate(EntityPlayer player) { RecipeMap workableRecipeMap = workable.getRecipeMap(); int yOffset = 0; diff --git a/src/main/java/gregtech/api/mui/GTGuiTextures.java b/src/main/java/gregtech/api/mui/GTGuiTextures.java index f34c08a936a..f20719867c9 100644 --- a/src/main/java/gregtech/api/mui/GTGuiTextures.java +++ b/src/main/java/gregtech/api/mui/GTGuiTextures.java @@ -6,6 +6,7 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.drawable.UITexture; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/gregtech/api/mui/GTGuiTheme.java b/src/main/java/gregtech/api/mui/GTGuiTheme.java index 4a6c2c2d4dd..912377b59ce 100644 --- a/src/main/java/gregtech/api/mui/GTGuiTheme.java +++ b/src/main/java/gregtech/api/mui/GTGuiTheme.java @@ -1,5 +1,6 @@ package gregtech.api.mui; +import gregtech.api.GTValues; import gregtech.api.cover.CoverWithUI; import gregtech.common.ConfigHolder; @@ -32,6 +33,7 @@ public class GTGuiTheme { .simpleToggleButton(GTGuiTextures.IDs.STANDARD_BUTTON, GTGuiTextures.IDs.STANDARD_SLOT, ConfigHolder.client.defaultUIColor) + .logo(() -> GTValues.XMAS.get() ? GTGuiTextures.GREGTECH_LOGO_XMAS : GTGuiTextures.GREGTECH_LOGO) .build(); public static final GTGuiTheme COVER = templateBuilder("gregtech_cover") @@ -391,6 +393,11 @@ public Builder logo(Supplier logo) { return this; } + public Builder logo(Supplier logo) { + theme.logo = logo; + return this; + } + public GTGuiTheme build() { return theme; } From 23e54e52d18122704c68aacf9d1ea1a07ca4b8a2 Mon Sep 17 00:00:00 2001 From: serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:47:04 -0600 Subject: [PATCH 07/55] clickable progress bar (partial) --- .../api/mui/widget/RecipeProgressWidget.java | 70 +++++++++++++++++++ .../gregtech/api/recipes/ui/RecipeMapUI.java | 17 ++--- 2 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 src/main/java/gregtech/api/mui/widget/RecipeProgressWidget.java diff --git a/src/main/java/gregtech/api/mui/widget/RecipeProgressWidget.java b/src/main/java/gregtech/api/mui/widget/RecipeProgressWidget.java new file mode 100644 index 00000000000..810a71c14f9 --- /dev/null +++ b/src/main/java/gregtech/api/mui/widget/RecipeProgressWidget.java @@ -0,0 +1,70 @@ +package gregtech.api.mui.widget; + +import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.api.widget.Interactable; +import com.cleanroommc.modularui.widgets.ProgressWidget; + +import gregtech.api.GregTechAPI; +import gregtech.api.recipes.RecipeMap; + +import gregtech.api.recipes.RecipeMaps; +import gregtech.integration.IntegrationModule; +import gregtech.integration.jei.JustEnoughItemsModule; +import gregtech.integration.jei.recipe.RecipeMapCategory; +import gregtech.modules.GregTechModules; + +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class RecipeProgressWidget extends ProgressWidget implements Interactable { + + private RecipeMap recipeMap; + + public RecipeProgressWidget recipeMap(RecipeMap recipeMap) { + this.recipeMap = recipeMap; + if (GregTechAPI.moduleManager.isModuleEnabled(GregTechModules.MODULE_JEI)) { + tooltip(t -> t.addLine(IKey.lang("gui.widget.recipeProgressWidget.default_tooltip"))); + } + return this; + } + + @Override + public @NotNull Result onMousePressed(int mouseButton) { + return Interactable.super.onMousePressed(mouseButton); + // TODO Waiting for a MUI solution to do this. + // TODO Crashes when exiting the MUI ui after closing the JEI ui + // TODO that was opened by this widget. + /* + if (recipeMap == null) { + return Result.IGNORE; + } + if (mouseButton == 0 || mouseButton == 1) { + if (!GregTechAPI.moduleManager.isModuleEnabled(GregTechModules.MODULE_JEI)) { + return Result.ACCEPT; + } + + Collection categories = RecipeMapCategory.getCategoriesFor(recipeMap); + if (categories != null && !categories.isEmpty()) { + List categoryID = new ArrayList<>(); + if (recipeMap == RecipeMaps.FURNACE_RECIPES) { + categoryID.add("minecraft.smelting"); + } else { + for (RecipeMapCategory category : categories) { + categoryID.add(category.getUid()); + } + } + + if (JustEnoughItemsModule.jeiRuntime == null) { + IntegrationModule.logger.error("GTCEu JEI integration has crashed, this is not a good thing"); + return Result.ACCEPT; + } + JustEnoughItemsModule.jeiRuntime.getRecipesGui().showCategories(categoryID); + return Result.SUCCESS; + } + } + return Result.IGNORE;*/ + } +} diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 0a7f22779fa..8eecf936118 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -4,10 +4,10 @@ import gregtech.api.gui.GuiTextures; import gregtech.api.gui.ModularUI; import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.RecipeProgressWidget; import gregtech.api.gui.widgets.SlotWidget; import gregtech.api.gui.widgets.TankWidget; import gregtech.api.mui.GTGuiTextures; +import gregtech.api.mui.widget.RecipeProgressWidget; import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMap; @@ -150,8 +150,8 @@ public static byte computeOverlayKey(boolean isOutput, boolean isFluid, boolean public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { ModularUI.Builder builder = ModularUI.defaultBuilder(yOffset); - builder.widget(new RecipeProgressWidget(200, 78, 23 + yOffset, 20, 20, progressBarTexture, - moveType, recipeMap)); + builder.widget(new gregtech.api.gui.widgets.RecipeProgressWidget(200, 78, 23 + yOffset, 20, 20, + progressBarTexture, moveType, recipeMap)); addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); addInventorySlotGroup(builder, exportItems, exportFluids, true, yOffset); if (specialTexture != null && specialTexturePosition != null) { @@ -178,8 +178,8 @@ public ModularUI.Builder createUITemplate(DoubleSupplier progressSupplier, IItem FluidTankList exportFluids, int yOffset) { ModularUI.Builder builder = ModularUI.defaultBuilder(yOffset); builder.widget( - new RecipeProgressWidget(progressSupplier, 78, 23 + yOffset, 20, 20, progressBarTexture, - moveType, recipeMap)); + new gregtech.api.gui.widgets.RecipeProgressWidget(progressSupplier, 78, 23 + yOffset, 20, 20, + progressBarTexture, moveType, recipeMap)); addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); addInventorySlotGroup(builder, exportItems, exportFluids, true, yOffset); if (specialTexture != null && specialTexturePosition != null) { @@ -207,8 +207,8 @@ public ModularUI.Builder createUITemplateNoOutputs(DoubleSupplier progressSuppli FluidTankList exportFluids, int yOffset) { ModularUI.Builder builder = ModularUI.defaultBuilder(yOffset); builder.widget( - new RecipeProgressWidget(progressSupplier, 78, 23 + yOffset, 20, 20, progressBarTexture, - moveType, recipeMap)); + new gregtech.api.gui.widgets.RecipeProgressWidget(progressSupplier, 78, 23 + yOffset, 20, 20, + progressBarTexture, moveType, recipeMap)); addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); if (specialTexture != null && specialTexturePosition != null) { addSpecialTexture(builder); @@ -518,7 +518,8 @@ public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandler IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { ParentWidget group = new ParentWidget<>().size(176, 166 + yOffset); - group.child(new ProgressWidget() + group.child(new RecipeProgressWidget() + .recipeMap(recipeMap) .size(20) .alignX(0.5f).top(23 + yOffset) .progress(progressSupplier) From ca3f0235bcf5262056b05beadd173727eacfbf98 Mon Sep 17 00:00:00 2001 From: serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:56:39 -0600 Subject: [PATCH 08/55] finish previous commit --- .../api/mui/widget/RecipeProgressWidget.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/java/gregtech/api/mui/widget/RecipeProgressWidget.java b/src/main/java/gregtech/api/mui/widget/RecipeProgressWidget.java index 810a71c14f9..688fd76a950 100644 --- a/src/main/java/gregtech/api/mui/widget/RecipeProgressWidget.java +++ b/src/main/java/gregtech/api/mui/widget/RecipeProgressWidget.java @@ -1,18 +1,16 @@ package gregtech.api.mui.widget; -import com.cleanroommc.modularui.api.drawable.IKey; -import com.cleanroommc.modularui.api.widget.Interactable; -import com.cleanroommc.modularui.widgets.ProgressWidget; - import gregtech.api.GregTechAPI; import gregtech.api.recipes.RecipeMap; - import gregtech.api.recipes.RecipeMaps; import gregtech.integration.IntegrationModule; import gregtech.integration.jei.JustEnoughItemsModule; import gregtech.integration.jei.recipe.RecipeMapCategory; import gregtech.modules.GregTechModules; +import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.api.widget.Interactable; +import com.cleanroommc.modularui.widgets.ProgressWidget; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -33,11 +31,6 @@ public RecipeProgressWidget recipeMap(RecipeMap recipeMap) { @Override public @NotNull Result onMousePressed(int mouseButton) { - return Interactable.super.onMousePressed(mouseButton); - // TODO Waiting for a MUI solution to do this. - // TODO Crashes when exiting the MUI ui after closing the JEI ui - // TODO that was opened by this widget. - /* if (recipeMap == null) { return Result.IGNORE; } @@ -65,6 +58,6 @@ public RecipeProgressWidget recipeMap(RecipeMap recipeMap) { return Result.SUCCESS; } } - return Result.IGNORE;*/ + return Result.IGNORE; } } From 63599328b2066b3818c2fa26cba519f103444307 Mon Sep 17 00:00:00 2001 From: serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Sun, 17 Dec 2023 15:17:00 -0600 Subject: [PATCH 09/55] fix progress bar sync --- .../api/metatileentity/SimpleMachineMetaTileEntity.java | 2 +- src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 4f4dfc163cb..1a5c023d9f3 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -508,7 +508,7 @@ public ModularPanel buildUI(PosGuiData guiData, GuiSyncManager guiSyncManager) { ModularPanel panel = GTGuis.createPanel(this, 176, 166 + yOffset); Widget widget = workableRecipeMap.getRecipeMapUI().buildWidget(workable::getProgressPercent, importItems, - exportItems, importFluids, exportFluids, yOffset); + exportItems, importFluids, exportFluids, yOffset, guiSyncManager); panel.child(widget) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 8eecf936118..8122b232ce2 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -15,6 +15,8 @@ import com.cleanroommc.modularui.api.drawable.IDrawable; import com.cleanroommc.modularui.drawable.UITexture; +import com.cleanroommc.modularui.value.sync.DoubleSyncValue; +import com.cleanroommc.modularui.value.sync.GuiSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widget.ParentWidget; import com.cleanroommc.modularui.widget.Widget; @@ -516,13 +518,16 @@ public void setSlotOverlay(byte key, @NotNull TextureArea texture) { public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, - FluidTankList exportFluids, int yOffset) { + FluidTankList exportFluids, int yOffset, GuiSyncManager syncManager) { + DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier, null); + syncManager.syncValue("recipe_progress", progressValue); + ParentWidget group = new ParentWidget<>().size(176, 166 + yOffset); group.child(new RecipeProgressWidget() .recipeMap(recipeMap) .size(20) .alignX(0.5f).top(23 + yOffset) - .progress(progressSupplier) + .progress(progressValue::getDoubleValue) .texture(progressTexture, 20) .direction(progressDirection)); addInventorySlotGroup(group, importItems, importFluids, false, yOffset); From 453b0fefcfb2e43a928446f421e41b0231d1f421 Mon Sep 17 00:00:00 2001 From: serenibyss <10861407+serenibyss@users.noreply.github.com> Date: Sun, 17 Dec 2023 15:47:30 -0600 Subject: [PATCH 10/55] fix button/toggle button theme builder calls --- .../java/gregtech/api/mui/GTGuiTheme.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/main/java/gregtech/api/mui/GTGuiTheme.java b/src/main/java/gregtech/api/mui/GTGuiTheme.java index 912377b59ce..2a0a0a9219c 100644 --- a/src/main/java/gregtech/api/mui/GTGuiTheme.java +++ b/src/main/java/gregtech/api/mui/GTGuiTheme.java @@ -393,6 +393,37 @@ public Builder logo(Supplier logo) { return this; } + /** + * Simple toggle button configuration for when you want a button with no texture changes on hover. + * + * @param backgroundId The unselected background texture + * @param selectedBackgroundId The selected background texture + * @param selectedColor The background color when the button is selected + */ + public Builder simpleToggleButton(String backgroundId, String selectedBackgroundId, int selectedColor) { + return simpleToggleButton(backgroundId, selectedBackgroundId, selectedColor, 0xFFBBBBBB, false); + } + + /** + * Simple toggle button configuration for when you want a button with no texture changes on hover. + * + * @param backgroundId The unselected background texture + * @param selectedBackgroundId The selected background texture + * @param selectedColor The background color when the button is selected + * @param textColor The color for text overlaid on this button + * @param textShadow Whether to apply text shadow to text overlaid on this button + */ + public Builder simpleToggleButton(String backgroundId, String selectedBackgroundId, int selectedColor, + int textColor, boolean textShadow) { + return toggleButton( + backgroundId, backgroundId, + selectedBackgroundId, selectedBackgroundId, + selectedColor, textColor, textShadow); + } + + /** + * Set a logo supplier for this theme. + */ public Builder logo(Supplier logo) { theme.logo = logo; return this; From c7cdbf8f9e166f676015f398de000325665d454e Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 27 Feb 2025 17:56:17 -0700 Subject: [PATCH 11/55] fix rebase --- .../SimpleMachineMetaTileEntity.java | 4 +-- .../java/gregtech/api/mui/GTGuiTheme.java | 36 ------------------- .../api/recipes/RecipeMapBuilder.java | 8 ++--- .../gregtech/api/recipes/ui/RecipeMapUI.java | 6 ++-- 4 files changed, 7 insertions(+), 47 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 1a5c023d9f3..5522c600ba8 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -61,7 +61,7 @@ import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.value.BoolValue; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; -import com.cleanroommc.modularui.value.sync.GuiSyncManager; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widgets.ItemSlot; @@ -498,7 +498,7 @@ public boolean usesMui2() { } @Override - public ModularPanel buildUI(PosGuiData guiData, GuiSyncManager guiSyncManager) { + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { RecipeMap workableRecipeMap = workable.getRecipeMap(); int yOffset = 0; if (workableRecipeMap.getMaxInputs() >= 6 || workableRecipeMap.getMaxFluidInputs() >= 6 || diff --git a/src/main/java/gregtech/api/mui/GTGuiTheme.java b/src/main/java/gregtech/api/mui/GTGuiTheme.java index 2a0a0a9219c..92f98225a7c 100644 --- a/src/main/java/gregtech/api/mui/GTGuiTheme.java +++ b/src/main/java/gregtech/api/mui/GTGuiTheme.java @@ -393,42 +393,6 @@ public Builder logo(Supplier logo) { return this; } - /** - * Simple toggle button configuration for when you want a button with no texture changes on hover. - * - * @param backgroundId The unselected background texture - * @param selectedBackgroundId The selected background texture - * @param selectedColor The background color when the button is selected - */ - public Builder simpleToggleButton(String backgroundId, String selectedBackgroundId, int selectedColor) { - return simpleToggleButton(backgroundId, selectedBackgroundId, selectedColor, 0xFFBBBBBB, false); - } - - /** - * Simple toggle button configuration for when you want a button with no texture changes on hover. - * - * @param backgroundId The unselected background texture - * @param selectedBackgroundId The selected background texture - * @param selectedColor The background color when the button is selected - * @param textColor The color for text overlaid on this button - * @param textShadow Whether to apply text shadow to text overlaid on this button - */ - public Builder simpleToggleButton(String backgroundId, String selectedBackgroundId, int selectedColor, - int textColor, boolean textShadow) { - return toggleButton( - backgroundId, backgroundId, - selectedBackgroundId, selectedBackgroundId, - selectedColor, textColor, textShadow); - } - - /** - * Set a logo supplier for this theme. - */ - public Builder logo(Supplier logo) { - theme.logo = logo; - return this; - } - public GTGuiTheme build() { return theme; } diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index 7b3e701c71c..7d9a488ad48 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -36,12 +36,6 @@ public class RecipeMapBuilder> { private boolean isGenerator; - private @Nullable TextureArea progressBar; - private @Nullable ProgressWidget.MoveType moveType; - - private @Nullable TextureArea specialTexture; - private int @Nullable [] specialTextureLocation; - private RecipeMapUIFunction recipeMapUIFunction = this::buildUI; private SoundEvent sound; @@ -61,6 +55,8 @@ public class RecipeMapBuilder> { private @Nullable gregtech.api.gui.widgets.ProgressWidget.MoveType moveType; @Deprecated private @Nullable TextureArea specialTexture; + @Deprecated + private int @Nullable [] specialTextureLocation; /* *********************** MUI 2 *********************** */ diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 8122b232ce2..dc52d3f4b49 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -16,7 +16,7 @@ import com.cleanroommc.modularui.api.drawable.IDrawable; import com.cleanroommc.modularui.drawable.UITexture; import com.cleanroommc.modularui.value.sync.DoubleSyncValue; -import com.cleanroommc.modularui.value.sync.GuiSyncManager; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widget.ParentWidget; import com.cleanroommc.modularui.widget.Widget; @@ -518,8 +518,8 @@ public void setSlotOverlay(byte key, @NotNull TextureArea texture) { public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, - FluidTankList exportFluids, int yOffset, GuiSyncManager syncManager) { - DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier, null); + FluidTankList exportFluids, int yOffset, PanelSyncManager syncManager) { + DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier); syncManager.syncValue("recipe_progress", progressValue); ParentWidget group = new ParentWidget<>().size(176, 166 + yOffset); From 41c6eadf4ddef29629a76d4c06ea62add9be2df3 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:52:01 -0700 Subject: [PATCH 12/55] move mui2 related methods into builder use builder consumer --- .../java/gregtech/api/mui/GTGuiTextures.java | 1 - .../api/recipes/RecipeMapBuilder.java | 115 +++--------------- .../java/gregtech/api/recipes/RecipeMaps.java | 5 +- .../gregtech/api/recipes/ui/RecipeMapUI.java | 37 +++--- .../api/recipes/ui/RecipeMapUIBuilder.java | 110 +++++++++++++++++ 5 files changed, 146 insertions(+), 122 deletions(-) create mode 100644 src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java diff --git a/src/main/java/gregtech/api/mui/GTGuiTextures.java b/src/main/java/gregtech/api/mui/GTGuiTextures.java index f20719867c9..f34c08a936a 100644 --- a/src/main/java/gregtech/api/mui/GTGuiTextures.java +++ b/src/main/java/gregtech/api/mui/GTGuiTextures.java @@ -6,7 +6,6 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.drawable.UITexture; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index 7d9a488ad48..f2f05b3965c 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -2,6 +2,7 @@ import gregtech.api.gui.resources.TextureArea; import gregtech.api.recipes.ui.RecipeMapUI; +import gregtech.api.recipes.ui.RecipeMapUIBuilder; import gregtech.api.recipes.ui.RecipeMapUIFunction; import net.minecraft.util.ResourceLocation; @@ -17,6 +18,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Map; +import java.util.function.Consumer; import static gregtech.api.recipes.ui.RecipeMapUI.computeOverlayKey; @@ -60,15 +62,10 @@ public class RecipeMapBuilder> { /* *********************** MUI 2 *********************** */ - // todo try to store this better - private final Byte2ObjectMap slotOverlayTextures = new Byte2ObjectArrayMap<>(); - @ApiStatus.Experimental private boolean usesMui2 = false; - private @Nullable UITexture progressTexture; - private @Nullable ProgressWidget.Direction progressDirection; - // todo sus name - private @Nullable UITexture specialTextureNew; + + private @Nullable Consumer mapUIBuilder; /** * @param unlocalizedName the name of the recipemap @@ -173,16 +170,6 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } - /** - * @param progressBar the progress bar texture to use - * @return this - */ - public @NotNull RecipeMapBuilder progressBar(@Nullable UITexture progressBar) { - this.usesMui2 = true; - this.progressTexture = progressBar; - return this; - } - /** * @deprecated in favor of the MUI2 method. * @param progressBar the progress bar texture to use @@ -198,19 +185,6 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } - /** - * @param progressBar the progress bar texture to use - * @param moveType the progress bar move type to use - * @return this - */ - public @NotNull RecipeMapBuilder progressBar(@Nullable UITexture progressBar, - @Nullable ProgressWidget.Direction moveType) { - this.usesMui2 = true; - this.progressTexture = progressBar; - this.progressDirection = moveType; - return this; - } - /** * @deprecated in favor of the MUI2 method. * @param texture the texture to use @@ -225,18 +199,6 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } - /** - * @param texture the texture to use - * @param isOutput if the slot is an output slot - * @return this - */ - public @NotNull RecipeMapBuilder itemSlotOverlay(@NotNull UITexture texture, boolean isOutput) { - this.usesMui2 = true; - this.slotOverlayTextures.put(computeOverlayKey(isOutput, false, false), texture); - this.slotOverlayTextures.put(computeOverlayKey(isOutput, false, true), texture); - return this; - } - /** * @deprecated in favor of the MUI2 method. * @param texture the texture to use @@ -252,19 +214,6 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } - /** - * @param texture the texture to use - * @param isOutput if the slot is an output slot - * @param isLastSlot if the slot is the last slot - * @return this - */ - public @NotNull RecipeMapBuilder itemSlotOverlay(@NotNull UITexture texture, boolean isOutput, - boolean isLastSlot) { - this.usesMui2 = true; - this.slotOverlayTextures.put(computeOverlayKey(isOutput, false, isLastSlot), texture); - return this; - } - /** * @deprecated in favor of the MUI2 method. * @param texture the texture to use @@ -279,18 +228,6 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } - /** - * @param texture the texture to use - * @param isOutput if the slot is an output slot - * @return this - */ - public @NotNull RecipeMapBuilder fluidSlotOverlay(@NotNull UITexture texture, boolean isOutput) { - this.usesMui2 = true; - this.slotOverlayTextures.put(computeOverlayKey(isOutput, true, false), texture); - this.slotOverlayTextures.put(computeOverlayKey(isOutput, true, true), texture); - return this; - } - /** * @deprecated in favor of the MUI2 method. * @param texture the texture to use @@ -306,19 +243,6 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } - /** - * @param texture the texture to use - * @param isOutput if the slot is an output slot - * @param isLastSlot if the slot is the last slot - * @return this - */ - public @NotNull RecipeMapBuilder fluidSlotOverlay(@NotNull UITexture texture, boolean isOutput, - boolean isLastSlot) { - this.usesMui2 = true; - this.slotOverlayTextures.put(computeOverlayKey(isOutput, true, isLastSlot), texture); - return this; - } - /** * @deprecated in favor of the MUI2 method. */ @@ -331,14 +255,6 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } - public @NotNull RecipeMapBuilder specialTexture(@NotNull UITexture texture, int x, int y, int width, - int height) { - this.usesMui2 = true; - this.specialTextureNew = texture; - this.specialTextureLocation = new int[] { x, y, width, height }; - return this; - } - /** * @apiNote Only needed if you do not set textures using MUI2 methods, i.e. the ones that accept{@link UITexture}. *
@@ -359,6 +275,12 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } + public @NotNull RecipeMapBuilder uiBuilder(@NotNull Consumer mapUIBuilder) { + this.usesMui2 = true; + this.mapUIBuilder = mapUIBuilder; + return this; + } + /** * @param recipeMap the recipemap associated with the ui * @return the RecipeMap's ui @@ -367,19 +289,10 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip RecipeMapUI ui = new RecipeMapUI<>(recipeMap, modifyItemInputs, modifyItemOutputs, modifyFluidInputs, modifyFluidOutputs, isGenerator); if (usesMui2) { - ui.setUsesMui2(); - if (progressTexture != null) { - ui.setProgressBarTexture(progressTexture); - } - if (progressDirection != null) { - ui.setProgressBarDirection(progressDirection); - } - if (specialTextureNew != null && specialTextureLocation != null) { - ui.setSpecialTexture(specialTextureNew, specialTextureLocation); - } - for (var entry : slotOverlayTextures.byte2ObjectEntrySet()) { - ui.setSlotOverlay(entry.getByteKey(), entry.getValue()); - } + var builder = new RecipeMapUIBuilder(); + // noinspection DataFlowIssue + this.mapUIBuilder.accept(builder); + builder.setMapUi(ui); } else { if (progressBar != null) { ui.setProgressBarTexture(progressBar); diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index 879899b935d..29ad4217f02 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -79,8 +79,9 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(2) .itemOutputs(1) - .itemSlotOverlay(GTGuiTextures.FURNACE_OVERLAY_1, false) - .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW) + .uiBuilder(builder -> builder + .itemSlotOverlay(GTGuiTextures.FURNACE_OVERLAY_1, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW)) .sound(GTSoundEvents.FURNACE) .build(); diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index dc52d3f4b49..4387cad1a00 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -20,6 +20,7 @@ import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widget.ParentWidget; import com.cleanroommc.modularui.widget.Widget; +import com.cleanroommc.modularui.widget.sizer.Area; import com.cleanroommc.modularui.widgets.FluidSlot; import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.ProgressWidget; @@ -30,7 +31,6 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.UnmodifiableView; import java.util.function.DoubleSupplier; @@ -45,7 +45,7 @@ public class RecipeMapUI> { private final boolean isGenerator; - private int @Nullable [] specialTexturePosition; + private @NotNull Area specialTexturePosition = new Area(); private boolean isJEIVisible = true; /* *********************** MUI 1 *********************** */ @@ -156,7 +156,7 @@ public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, progressBarTexture, moveType, recipeMap)); addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); addInventorySlotGroup(builder, exportItems, exportFluids, true, yOffset); - if (specialTexture != null && specialTexturePosition != null) { + if (specialTexture != null) { addSpecialTexture(builder); } return builder; @@ -184,7 +184,7 @@ public ModularUI.Builder createUITemplate(DoubleSupplier progressSupplier, IItem progressBarTexture, moveType, recipeMap)); addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); addInventorySlotGroup(builder, exportItems, exportFluids, true, yOffset); - if (specialTexture != null && specialTexturePosition != null) { + if (specialTexture != null) { addSpecialTexture(builder); } return builder; @@ -212,7 +212,7 @@ public ModularUI.Builder createUITemplateNoOutputs(DoubleSupplier progressSuppli new gregtech.api.gui.widgets.RecipeProgressWidget(progressSupplier, 78, 23 + yOffset, 20, 20, progressBarTexture, moveType, recipeMap)); addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); - if (specialTexture != null && specialTexturePosition != null) { + if (specialTexture != null) { addSpecialTexture(builder); } return builder; @@ -262,7 +262,7 @@ protected void addInventorySlotGroup(@NotNull ModularUI.Builder builder, int startSpecX = isOutputs ? startInputsX + itemSlotsToLeft * 18 : startInputsX - 18; for (int i = 0; i < fluidInputsCount; i++) { int y = startInputsY + 18 * i; - addSlot(builder, startSpecX, y, i, itemHandler, fluidHandler, !invertFluids, isOutputs); + addSlot(builder, startSpecX, y, i, itemHandler, fluidHandler, true, isOutputs); } } else { int startSpecY = startInputsY + itemSlotsToDown * 18; @@ -270,7 +270,7 @@ protected void addInventorySlotGroup(@NotNull ModularUI.Builder builder, int x = isOutputs ? startInputsX + 18 * (i % 3) : startInputsX + itemSlotsToLeft * 18 - 18 - 18 * (i % 3); int y = startSpecY + (i / 3) * 18; - addSlot(builder, x, y, i, itemHandler, fluidHandler, !invertFluids, isOutputs); + addSlot(builder, x, y, i, itemHandler, fluidHandler, true, isOutputs); } } } @@ -416,7 +416,11 @@ public void setSpecialTexture(@NotNull TextureArea specialTexture, int x, int y, @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public void setSpecialTexture(@NotNull TextureArea specialTexture, int @NotNull [] position) { this.specialTexture = specialTexture; - this.specialTexturePosition = position; + this.specialTexturePosition.set( + position[0], + position[1], + position[2], + position[3]); } /** @@ -431,7 +435,7 @@ public void setSpecialTexture(@NotNull TextureArea specialTexture, int @NotNull /** * @return the special texture's position */ - public int @Nullable @UnmodifiableView [] specialTexturePosition() { + public Area specialTexturePosition() { return this.specialTexturePosition; } @@ -444,11 +448,9 @@ public void setSpecialTexture(@NotNull TextureArea specialTexture, int @NotNull @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public @NotNull ModularUI.Builder addSpecialTexture(@NotNull ModularUI.Builder builder) { - if (specialTexturePosition != null) { - builder.image(specialTexturePosition[0], specialTexturePosition[1], - specialTexturePosition[2], - specialTexturePosition[3], specialTexture); - } + builder.image(specialTexturePosition.x(), specialTexturePosition.y(), + specialTexturePosition.w(), + specialTexturePosition.h(), specialTexture); return builder; } @@ -532,10 +534,9 @@ public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandler .direction(progressDirection)); addInventorySlotGroup(group, importItems, importFluids, false, yOffset); addInventorySlotGroup(group, exportItems, exportFluids, true, yOffset); - if (specialTextureNew != null && specialTexturePosition != null) { + if (specialTextureNew != null) { group.child(new Widget<>() - .pos(specialTexturePosition[0], specialTexturePosition[1]) - .size(specialTexturePosition[2], specialTexturePosition[3]) + .flex(flex -> flex.getArea().set(specialTexturePosition)) .background(specialTextureNew)); } return group; @@ -665,7 +666,7 @@ public void setProgressBarDirection(@NotNull ProgressWidget.Direction direction) * @param specialTexture the special texture to set * @param position the position of the texture: [x, y, width, height] */ - public void setSpecialTexture(@NotNull UITexture specialTexture, int @NotNull [] position) { + public void setSpecialTexture(@NotNull UITexture specialTexture, @NotNull Area position) { this.specialTextureNew = specialTexture; this.specialTexturePosition = position; } diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java new file mode 100644 index 00000000000..fbe31eb02e5 --- /dev/null +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java @@ -0,0 +1,110 @@ +package gregtech.api.recipes.ui; + +import com.cleanroommc.modularui.drawable.UITexture; +import com.cleanroommc.modularui.widget.sizer.Area; +import com.cleanroommc.modularui.widgets.ProgressWidget; +import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap; +import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import static gregtech.api.recipes.ui.RecipeMapUI.computeOverlayKey; + +public class RecipeMapUIBuilder { + + // todo try to store this better + private final Byte2ObjectMap slotOverlayTextures = new Byte2ObjectArrayMap<>(); + private @Nullable UITexture progressTexture; + private @Nullable ProgressWidget.Direction progressDirection; + private @Nullable UITexture specialTexture; + private @NotNull Area specialTextureLocation = new Area(); + + /** + * @param progressBar the progress bar texture to use + * @return this + */ + public @NotNull RecipeMapUIBuilder progressBar(@Nullable UITexture progressBar) { + this.progressTexture = progressBar; + return this; + } + + /** + * @param progressBar the progress bar texture to use + * @param moveType the progress bar move type to use + * @return this + */ + public @NotNull RecipeMapUIBuilder progressBar(@Nullable UITexture progressBar, + @Nullable ProgressWidget.Direction moveType) { + this.progressDirection = moveType; + return progressBar(progressBar); + } + + /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @return this + */ + public @NotNull RecipeMapUIBuilder itemSlotOverlay(@NotNull UITexture texture, boolean isOutput) { + itemSlotOverlay(texture, isOutput, false); + itemSlotOverlay(texture, isOutput, true); + return this; + } + + /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @param isLastSlot if the slot is the last slot + * @return this + */ + public @NotNull RecipeMapUIBuilder itemSlotOverlay(@NotNull UITexture texture, boolean isOutput, + boolean isLastSlot) { + this.slotOverlayTextures.put(computeOverlayKey(isOutput, false, isLastSlot), texture); + return this; + } + + /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @return this + */ + public @NotNull RecipeMapUIBuilder fluidSlotOverlay(@NotNull UITexture texture, boolean isOutput) { + fluidSlotOverlay(texture, isOutput, false); + fluidSlotOverlay(texture, isOutput, true); + return this; + } + + /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @param isLastSlot if the slot is the last slot + * @return this + */ + public @NotNull RecipeMapUIBuilder fluidSlotOverlay(@NotNull UITexture texture, boolean isOutput, + boolean isLastSlot) { + this.slotOverlayTextures.put(computeOverlayKey(isOutput, true, isLastSlot), texture); + return this; + } + + public @NotNull RecipeMapUIBuilder specialTexture(@NotNull UITexture texture, int x, int y, int width, + int height) { + this.specialTexture = texture; + this.specialTextureLocation.set(x, y, width, height); + return this; + } + + public void setMapUi(RecipeMapUI mapUi) { + mapUi.setUsesMui2(); + if (progressTexture != null) { + mapUi.setProgressBarTexture(progressTexture); + } + if (progressDirection != null) { + mapUi.setProgressBarDirection(progressDirection); + } + if (specialTexture != null) { + mapUi.setSpecialTexture(specialTexture, specialTextureLocation); + } + for (var entry : slotOverlayTextures.byte2ObjectEntrySet()) { + mapUi.setSlotOverlay(entry.getByteKey(), entry.getValue()); + } + } +} From 70dd55dede244935b9f30b621f3d8b749f35c6c7 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:56:46 -0700 Subject: [PATCH 13/55] use unary operator instead --- src/main/java/gregtech/api/recipes/RecipeMapBuilder.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index f2f05b3965c..4b91e76b86f 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.function.Consumer; +import java.util.function.UnaryOperator; import static gregtech.api.recipes.ui.RecipeMapUI.computeOverlayKey; @@ -65,7 +66,7 @@ public class RecipeMapBuilder> { @ApiStatus.Experimental private boolean usesMui2 = false; - private @Nullable Consumer mapUIBuilder; + private @Nullable UnaryOperator mapUIBuilder; /** * @param unlocalizedName the name of the recipemap @@ -275,7 +276,7 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } - public @NotNull RecipeMapBuilder uiBuilder(@NotNull Consumer mapUIBuilder) { + public @NotNull RecipeMapBuilder uiBuilder(@NotNull UnaryOperator mapUIBuilder) { this.usesMui2 = true; this.mapUIBuilder = mapUIBuilder; return this; @@ -289,10 +290,8 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip RecipeMapUI ui = new RecipeMapUI<>(recipeMap, modifyItemInputs, modifyItemOutputs, modifyFluidInputs, modifyFluidOutputs, isGenerator); if (usesMui2) { - var builder = new RecipeMapUIBuilder(); // noinspection DataFlowIssue - this.mapUIBuilder.accept(builder); - builder.setMapUi(ui); + this.mapUIBuilder.apply(new RecipeMapUIBuilder()).setMapUi(ui); } else { if (progressBar != null) { ui.setProgressBarTexture(progressBar); From bee91a7073cfb047afe0cc89ff226f4437136ed7 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 27 Feb 2025 19:30:37 -0700 Subject: [PATCH 14/55] port arc, assembler, autoclave --- src/main/java/gregtech/api/recipes/RecipeMaps.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index 29ad4217f02..6f49c7a21de 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -121,7 +121,7 @@ public final class RecipeMaps { .itemOutputs(9) .fluidInputs(1) .fluidOutputs(1) - .progressBar(GuiTextures.PROGRESS_BAR_ARC_FURNACE) + .uiBuilder(builder -> builder.progressBar(GTGuiTextures.PROGRESS_BAR_ARC_FURNACE)) .sound(GTSoundEvents.ARC) .onBuild(gregtechId("arc_furnace_oxygen"), recipeBuilder -> { if (recipeBuilder.getFluidInputs().isEmpty()) { @@ -148,8 +148,9 @@ public final class RecipeMaps { .itemInputs(9) .itemOutputs(1) .fluidInputs(1) - .itemSlotOverlay(GuiTextures.CIRCUIT_OVERLAY, false) - .progressBar(GuiTextures.PROGRESS_BAR_CIRCUIT) + .uiBuilder(builder -> builder + .itemSlotOverlay(GTGuiTextures.CIRCUIT_OVERLAY, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_CIRCUIT)) .sound(GTSoundEvents.ASSEMBLER) .onBuild(gregtechId("assembler_solder"), recipeBuilder -> { var fluidInputs = recipeBuilder.getFluidInputs(); @@ -209,9 +210,9 @@ public final class RecipeMaps { .itemOutputs(2) .fluidInputs(1) .fluidOutputs(1) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, false) - .itemSlotOverlay(GuiTextures.CRYSTAL_OVERLAY, true) - .progressBar(GuiTextures.PROGRESS_BAR_CRYSTALLIZATION) + .uiBuilder(builder -> builder.itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, false) + .itemSlotOverlay(GTGuiTextures.CRYSTAL_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_CRYSTALLIZATION)) .sound(GTSoundEvents.FURNACE) .build(); From 8ae5c93a4774629a765cf71e657eb8a16ab64626 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 27 Feb 2025 19:30:52 -0700 Subject: [PATCH 15/55] spotless --- src/main/java/gregtech/api/recipes/RecipeMapBuilder.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index 4b91e76b86f..f439eb30622 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -9,7 +9,6 @@ import net.minecraft.util.SoundEvent; import com.cleanroommc.modularui.drawable.UITexture; -import com.cleanroommc.modularui.widgets.ProgressWidget; import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap; import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; @@ -18,7 +17,6 @@ import org.jetbrains.annotations.Nullable; import java.util.Map; -import java.util.function.Consumer; import java.util.function.UnaryOperator; import static gregtech.api.recipes.ui.RecipeMapUI.computeOverlayKey; From a56538d824c440deb0b4e414029ec19eecafc8d2 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Fri, 28 Feb 2025 12:17:37 -0700 Subject: [PATCH 16/55] simplify builder to modify map ui directly add a few more overloads --- .../api/recipes/RecipeMapBuilder.java | 2 +- .../api/recipes/ui/RecipeMapUIBuilder.java | 78 ++++++++++--------- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index f439eb30622..df53a89cb0e 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -289,7 +289,7 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip modifyFluidOutputs, isGenerator); if (usesMui2) { // noinspection DataFlowIssue - this.mapUIBuilder.apply(new RecipeMapUIBuilder()).setMapUi(ui); + this.mapUIBuilder.apply(new RecipeMapUIBuilder(ui)); } else { if (progressBar != null) { ui.setProgressBarTexture(progressBar); diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java index fbe31eb02e5..f9e234be687 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java @@ -3,28 +3,34 @@ import com.cleanroommc.modularui.drawable.UITexture; import com.cleanroommc.modularui.widget.sizer.Area; import com.cleanroommc.modularui.widgets.ProgressWidget; -import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap; -import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import static gregtech.api.recipes.ui.RecipeMapUI.computeOverlayKey; +@SuppressWarnings({ "unused", "UnusedReturnValue" }) public class RecipeMapUIBuilder { - // todo try to store this better - private final Byte2ObjectMap slotOverlayTextures = new Byte2ObjectArrayMap<>(); - private @Nullable UITexture progressTexture; - private @Nullable ProgressWidget.Direction progressDirection; - private @Nullable UITexture specialTexture; - private @NotNull Area specialTextureLocation = new Area(); + private final RecipeMapUI mapUI; + + public RecipeMapUIBuilder(RecipeMapUI mapUI) { + this.mapUI = mapUI; + } /** * @param progressBar the progress bar texture to use * @return this */ - public @NotNull RecipeMapUIBuilder progressBar(@Nullable UITexture progressBar) { - this.progressTexture = progressBar; + public @NotNull RecipeMapUIBuilder progressBar(@NotNull UITexture progressBar) { + this.mapUI.setProgressBarTexture(progressBar); + return this; + } + + /** + * @param moveType the progress bar move type to use + * @return this + */ + public @NotNull RecipeMapUIBuilder progressDirection(@NotNull ProgressWidget.Direction moveType) { + this.mapUI.setProgressBarDirection(moveType); return this; } @@ -33,10 +39,9 @@ public class RecipeMapUIBuilder { * @param moveType the progress bar move type to use * @return this */ - public @NotNull RecipeMapUIBuilder progressBar(@Nullable UITexture progressBar, - @Nullable ProgressWidget.Direction moveType) { - this.progressDirection = moveType; - return progressBar(progressBar); + public @NotNull RecipeMapUIBuilder progressBar(@NotNull UITexture progressBar, + @NotNull ProgressWidget.Direction moveType) { + return progressBar(progressBar).progressDirection(moveType); } /** @@ -58,8 +63,7 @@ public class RecipeMapUIBuilder { */ public @NotNull RecipeMapUIBuilder itemSlotOverlay(@NotNull UITexture texture, boolean isOutput, boolean isLastSlot) { - this.slotOverlayTextures.put(computeOverlayKey(isOutput, false, isLastSlot), texture); - return this; + return slotOverlay(texture, isOutput, false, isLastSlot); } /** @@ -81,30 +85,30 @@ public class RecipeMapUIBuilder { */ public @NotNull RecipeMapUIBuilder fluidSlotOverlay(@NotNull UITexture texture, boolean isOutput, boolean isLastSlot) { - this.slotOverlayTextures.put(computeOverlayKey(isOutput, true, isLastSlot), texture); - return this; + return slotOverlay(texture, isOutput, true, isLastSlot); } - public @NotNull RecipeMapUIBuilder specialTexture(@NotNull UITexture texture, int x, int y, int width, - int height) { - this.specialTexture = texture; - this.specialTextureLocation.set(x, y, width, height); + /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @param isFluid if the slot is a fluid slot + * @param isLastSlot if the slot is the last slot + * @return this + */ + public @NotNull RecipeMapUIBuilder slotOverlay(@NotNull UITexture texture, boolean isOutput, + boolean isFluid, boolean isLastSlot) { + this.mapUI.setSlotOverlay(computeOverlayKey(isOutput, isFluid, isLastSlot), texture); return this; } - public void setMapUi(RecipeMapUI mapUi) { - mapUi.setUsesMui2(); - if (progressTexture != null) { - mapUi.setProgressBarTexture(progressTexture); - } - if (progressDirection != null) { - mapUi.setProgressBarDirection(progressDirection); - } - if (specialTexture != null) { - mapUi.setSpecialTexture(specialTexture, specialTextureLocation); - } - for (var entry : slotOverlayTextures.byte2ObjectEntrySet()) { - mapUi.setSlotOverlay(entry.getByteKey(), entry.getValue()); - } + public @NotNull RecipeMapUIBuilder specialTexture(@NotNull UITexture texture, + int x, int y, + int width, int height) { + return specialTexture(texture, new Area(x, y, width, height)); + } + + public @NotNull RecipeMapUIBuilder specialTexture(@NotNull UITexture texture, @NotNull Area area) { + this.mapUI.setSpecialTexture(texture, area); + return this; } } From c1576f17a1aefe130015ed7e441a0ab9468e007d Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Fri, 28 Feb 2025 12:19:04 -0700 Subject: [PATCH 17/55] move back to consumer --- src/main/java/gregtech/api/recipes/RecipeMapBuilder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index df53a89cb0e..5b06b95d805 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -17,7 +17,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Map; -import java.util.function.UnaryOperator; +import java.util.function.Consumer; import static gregtech.api.recipes.ui.RecipeMapUI.computeOverlayKey; @@ -64,7 +64,7 @@ public class RecipeMapBuilder> { @ApiStatus.Experimental private boolean usesMui2 = false; - private @Nullable UnaryOperator mapUIBuilder; + private @Nullable Consumer mapUIBuilder; /** * @param unlocalizedName the name of the recipemap @@ -274,7 +274,7 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip return this; } - public @NotNull RecipeMapBuilder uiBuilder(@NotNull UnaryOperator mapUIBuilder) { + public @NotNull RecipeMapBuilder uiBuilder(@NotNull Consumer mapUIBuilder) { this.usesMui2 = true; this.mapUIBuilder = mapUIBuilder; return this; @@ -289,7 +289,7 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip modifyFluidOutputs, isGenerator); if (usesMui2) { // noinspection DataFlowIssue - this.mapUIBuilder.apply(new RecipeMapUIBuilder(ui)); + this.mapUIBuilder.accept(new RecipeMapUIBuilder(ui)); } else { if (progressBar != null) { ui.setProgressBarTexture(progressBar); From ed7c327683b15be1cf33099bcca071269e7c4e07 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Fri, 16 May 2025 17:06:25 -0700 Subject: [PATCH 18/55] add comment clarifying null supression update as many singleblock machines to mui2 --- .../api/recipes/RecipeMapBuilder.java | 1 + .../java/gregtech/api/recipes/RecipeMaps.java | 287 +++++++++++------- 2 files changed, 183 insertions(+), 105 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index 5b06b95d805..af176709d15 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -288,6 +288,7 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip RecipeMapUI ui = new RecipeMapUI<>(recipeMap, modifyItemInputs, modifyItemOutputs, modifyFluidInputs, modifyFluidOutputs, isGenerator); if (usesMui2) { + // if "usesMui2" is true, then "mapUIBuilder" is not null // noinspection DataFlowIssue this.mapUIBuilder.accept(new RecipeMapUIBuilder(ui)); } else { diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index 6f49c7a21de..b62ade32477 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -1,5 +1,7 @@ package gregtech.api.recipes; +import com.cleanroommc.modularui.widgets.ProgressWidget.Direction; + import gregtech.api.GTValues; import gregtech.api.gui.GuiTextures; import gregtech.api.gui.widgets.ProgressWidget; @@ -236,9 +238,10 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(2) .itemOutputs(1) - .itemSlotOverlay(GuiTextures.BENDER_OVERLAY, false, false) - .itemSlotOverlay(GuiTextures.INT_CIRCUIT_OVERLAY, false, true) - .progressBar(GuiTextures.PROGRESS_BAR_BENDING) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.BENDER_OVERLAY, false, false) + .itemSlotOverlay(GTGuiTextures.INT_CIRCUIT_OVERLAY, false, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_BENDING)) .sound(GTSoundEvents.MOTOR) .build(); @@ -296,8 +299,9 @@ public final class RecipeMaps { .itemInputs(1) .fluidInputs(1) .fluidOutputs(1) - .itemSlotOverlay(GuiTextures.BREWER_OVERLAY, false) - .progressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.BREWER_OVERLAY, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE)) .sound(GTSoundEvents.CHEMICAL_REACTOR) .build(); @@ -323,6 +327,7 @@ public final class RecipeMaps { new SimpleRecipeBuilder(), recipeMap -> { RecipeMapUI ui = new RecipeMapUI<>(recipeMap, true, true, true, true, false); + // todo update canner to mui2 ui.setItemSlotOverlay(GuiTextures.CANNER_OVERLAY, false, false); ui.setItemSlotOverlay(GuiTextures.CANISTER_OVERLAY, false, true); ui.setItemSlotOverlay(GuiTextures.CANISTER_OVERLAY, true); @@ -358,10 +363,11 @@ public final class RecipeMaps { .itemOutputs(6) .fluidInputs(1) .fluidOutputs(6) - .itemSlotOverlay(GuiTextures.EXTRACTOR_OVERLAY, false, false) - .itemSlotOverlay(GuiTextures.CANISTER_OVERLAY, false, true) - .fluidSlotOverlay(GuiTextures.CENTRIFUGE_OVERLAY, false, true) - .progressBar(GuiTextures.PROGRESS_BAR_EXTRACT) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.EXTRACTOR_OVERLAY, false, false) + .itemSlotOverlay(GTGuiTextures.CANISTER_OVERLAY, false, true) + .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, false, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRACT)) .sound(GTSoundEvents.CENTRIFUGE) .build(); @@ -384,9 +390,10 @@ public final class RecipeMaps { .itemOutputs(6) .fluidInputs(1) .fluidOutputs(1) - .itemSlotOverlay(GuiTextures.BREWER_OVERLAY, false, true) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true) - .progressBar(GuiTextures.PROGRESS_BAR_MIXER, MoveType.CIRCULAR) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.BREWER_OVERLAY, false, true) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_MIXER, Direction.CIRCULAR_CW)) .sound(GTSoundEvents.BATH) .build(); @@ -420,13 +427,15 @@ public final class RecipeMaps { .itemOutputs(2) .fluidInputs(3) .fluidOutputs(2) - .itemSlotOverlay(GuiTextures.MOLECULAR_OVERLAY_1, false, false) - .itemSlotOverlay(GuiTextures.MOLECULAR_OVERLAY_2, false, true) - .itemSlotOverlay(GuiTextures.VIAL_OVERLAY_1, true) - .fluidSlotOverlay(GuiTextures.MOLECULAR_OVERLAY_3, false, false) - .fluidSlotOverlay(GuiTextures.MOLECULAR_OVERLAY_4, false, true) - .fluidSlotOverlay(GuiTextures.VIAL_OVERLAY_2, true) - .progressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_1, false, false) + .itemSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_2, false, true) + .itemSlotOverlay(GTGuiTextures.VIAL_OVERLAY_1, true) + .fluidSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_3, false, false) + .fluidSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_4, false, true) + .fluidSlotOverlay(GTGuiTextures.VIAL_OVERLAY_2, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) + ) .sound(GTValues.FOOLS.get() ? GTSoundEvents.SCIENCE : GTSoundEvents.CHEMICAL_REACTOR) .onBuild(gregtechId("lcr_copy"), recipeBuilder -> RecipeMaps.LARGE_CHEMICAL_RECIPES.recipeBuilder() .inputs(recipeBuilder.getInputs().toArray(new GTRecipeInput[0])) @@ -474,8 +483,10 @@ public final class RecipeMaps { .itemInputs(6) .itemOutputs(1) .fluidInputs(1) - .itemSlotOverlay(GuiTextures.CIRCUIT_OVERLAY, false) - .progressBar(GuiTextures.PROGRESS_BAR_CIRCUIT_ASSEMBLER) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.CIRCUIT_OVERLAY, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_CIRCUIT_ASSEMBLER) + ) .sound(GTSoundEvents.ASSEMBLER) .onBuild(gregtechId("circuit_assembler_solder"), recipeBuilder -> { if (recipeBuilder.getFluidInputs().isEmpty()) { @@ -537,8 +548,10 @@ public final class RecipeMaps { new SimpleRecipeBuilder().duration(200).EUt(2)) .itemInputs(1) .itemOutputs(1) - .itemSlotOverlay(GuiTextures.COMPRESSOR_OVERLAY, false) - .progressBar(GuiTextures.PROGRESS_BAR_COMPRESS) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.COMPRESSOR_OVERLAY, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_COMPRESS) + ) .sound(GTSoundEvents.COMPRESSOR) .build(); @@ -594,10 +607,12 @@ public final class RecipeMaps { .itemInputs(1) .itemOutputs(2) .fluidInputs(1) - .itemSlotOverlay(GuiTextures.SAWBLADE_OVERLAY, false) - .itemSlotOverlay(GuiTextures.CUTTER_OVERLAY, true, false) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true, true) - .progressBar(GuiTextures.PROGRESS_BAR_SLICE) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.SAWBLADE_OVERLAY, false) + .itemSlotOverlay(GTGuiTextures.CUTTER_OVERLAY, true, false) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_SLICE) + ) .sound(GTSoundEvents.CUT) .onBuild(gregtechId("cutter_fluid"), recipeBuilder -> { if (recipeBuilder.getFluidInputs().isEmpty()) { @@ -686,11 +701,13 @@ public final class RecipeMaps { .itemOutputs(1) .fluidInputs(1) .fluidOutputs(1) - .itemSlotOverlay(GuiTextures.INT_CIRCUIT_OVERLAY, false, true) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true) - .fluidSlotOverlay(GuiTextures.BEAKER_OVERLAY_1, false) - .fluidSlotOverlay(GuiTextures.BEAKER_OVERLAY_4, true) - .progressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.INT_CIRCUIT_OVERLAY, false, true) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) + .fluidSlotOverlay(GTGuiTextures.BEAKER_OVERLAY_1, false) + .fluidSlotOverlay(GTGuiTextures.BEAKER_OVERLAY_4, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) + ) .sound(GTSoundEvents.BOILER) .build(); @@ -715,10 +732,12 @@ public final class RecipeMaps { .itemOutputs(6) .fluidInputs(1) .fluidOutputs(6) - .itemSlotOverlay(GuiTextures.LIGHTNING_OVERLAY_1, false, false) - .itemSlotOverlay(GuiTextures.CANISTER_OVERLAY, false, true) - .fluidSlotOverlay(GuiTextures.LIGHTNING_OVERLAY_2, false) - .progressBar(GuiTextures.PROGRESS_BAR_EXTRACT) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.LIGHTNING_OVERLAY_1, false, false) + .itemSlotOverlay(GTGuiTextures.CANISTER_OVERLAY, false, true) + .fluidSlotOverlay(GTGuiTextures.LIGHTNING_OVERLAY_2, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRACT) + ) .sound(GTSoundEvents.ELECTROLYZER) .build(); @@ -741,9 +760,11 @@ public final class RecipeMaps { "electromagnetic_separator", new SimpleRecipeBuilder()) .itemInputs(1) .itemOutputs(4) - .itemSlotOverlay(GuiTextures.CRUSHED_ORE_OVERLAY, false) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true) - .progressBar(GuiTextures.PROGRESS_BAR_MAGNET) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.CRUSHED_ORE_OVERLAY, false) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_MAGNET) + ) .sound(GTSoundEvents.ARC) .build(); @@ -767,8 +788,10 @@ public final class RecipeMaps { .itemInputs(1) .itemOutputs(1) .fluidOutputs(1) - .itemSlotOverlay(GuiTextures.EXTRACTOR_OVERLAY, false) - .progressBar(GuiTextures.PROGRESS_BAR_EXTRACT) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.EXTRACTOR_OVERLAY, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRACT) + ) .sound(GTSoundEvents.COMPRESSOR) .build(); @@ -790,8 +813,10 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(2) .itemOutputs(1) - .itemSlotOverlay(GuiTextures.MOLD_OVERLAY, false, true) - .progressBar(GuiTextures.PROGRESS_BAR_EXTRUDER) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.MOLD_OVERLAY, false, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRUDER) + ) .sound(GTSoundEvents.ARC) .build(); @@ -815,8 +840,10 @@ public final class RecipeMaps { .itemOutputs(1) .fluidInputs(1) .fluidOutputs(1) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, false, true) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true, true) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, false, true) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true, true) + ) .sound(GTSoundEvents.CHEMICAL_REACTOR) .build(); @@ -839,9 +866,11 @@ public final class RecipeMaps { .itemInputs(1) .fluidInputs(1) .fluidOutputs(1) - .itemSlotOverlay(GuiTextures.INT_CIRCUIT_OVERLAY, false, true) - .fluidSlotOverlay(GuiTextures.HEATING_OVERLAY_1, false) - .fluidSlotOverlay(GuiTextures.HEATING_OVERLAY_2, true) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.INT_CIRCUIT_OVERLAY, false, true) + .fluidSlotOverlay(GTGuiTextures.HEATING_OVERLAY_1, false) + .fluidSlotOverlay(GTGuiTextures.HEATING_OVERLAY_2, true) + ) .sound(GTSoundEvents.BOILER) .build(); @@ -864,7 +893,9 @@ public final class RecipeMaps { .itemInputs(1) .itemOutputs(1) .fluidInputs(1) - .itemSlotOverlay(GuiTextures.SOLIDIFIER_OVERLAY, false) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.SOLIDIFIER_OVERLAY, false) + ) .sound(GTSoundEvents.COOLING) .build(); @@ -885,9 +916,11 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(1) .itemOutputs(1) - .itemSlotOverlay(GuiTextures.HAMMER_OVERLAY, false) - .specialTexture(GuiTextures.PROGRESS_BAR_HAMMER_BASE, 78, 42, 20, 6) - .progressBar(GuiTextures.PROGRESS_BAR_HAMMER, MoveType.VERTICAL_DOWNWARDS) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.HAMMER_OVERLAY, false) + .specialTexture(GTGuiTextures.PROGRESS_BAR_HAMMER_BASE, 78, 42, 20, 6) + .progressBar(GTGuiTextures.PROGRESS_BAR_HAMMER, Direction.DOWN) + ) .sound(GTSoundEvents.FORGE_HAMMER) .build(); @@ -906,6 +939,7 @@ public final class RecipeMaps { @ZenProperty public static final RecipeMap FORMING_PRESS_RECIPES = new RecipeMapFormingPress( "forming_press", new SimpleRecipeBuilder(), FormingPressUI::new); + // todo update forming press to mui2 /** * @@ -935,6 +969,7 @@ public final class RecipeMaps { ui.setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, ProgressWidget.MoveType.HORIZONTAL); return ui; }); + // todo update electric furnace to mui2 /** * Example: @@ -963,6 +998,7 @@ public final class RecipeMaps { new FusionRecipeBuilder()) .fluidInputs(2) .fluidOutputs(1) + // todo figure out what to do here for mui2 .progressBar(GuiTextures.PROGRESS_BAR_FUSION) .sound(GTSoundEvents.ARC) .build(); @@ -972,9 +1008,11 @@ public final class RecipeMaps { "gas_collector", new SimpleRecipeBuilder()) .itemInputs(1) .fluidOutputs(1) - .itemSlotOverlay(GuiTextures.INT_CIRCUIT_OVERLAY, false, true) - .fluidSlotOverlay(GuiTextures.CENTRIFUGE_OVERLAY, true) - .progressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.INT_CIRCUIT_OVERLAY, false, true) + .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR) + ) .sound(GTSoundEvents.COOLING) .build(); @@ -1018,6 +1056,7 @@ public final class RecipeMaps { "implosion_compressor", new ImplosionRecipeBuilder().duration(20).EUt(VA[LV])) .itemInputs(3) .itemOutputs(2) + // todo figure out what to do here for mui2 .itemSlotOverlay(GuiTextures.IMPLOSION_OVERLAY_1, false, true) .itemSlotOverlay(GuiTextures.IMPLOSION_OVERLAY_2, false, false) .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true, true) @@ -1051,6 +1090,7 @@ public final class RecipeMaps { .itemOutputs(3) .fluidInputs(5) .fluidOutputs(4) + // todo figure out what to do here for mui2 .itemSlotOverlay(GuiTextures.MOLECULAR_OVERLAY_1, false, false) .itemSlotOverlay(GuiTextures.MOLECULAR_OVERLAY_2, false, true) .itemSlotOverlay(GuiTextures.VIAL_OVERLAY_1, true) @@ -1080,7 +1120,9 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(2) .itemOutputs(1) - .itemSlotOverlay(GuiTextures.LENS_OVERLAY, false, true) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.LENS_OVERLAY, false, true) + ) .sound(GTSoundEvents.ELECTROLYZER) .build(); @@ -1101,11 +1143,13 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(1) .itemOutputs(2) - .itemSlotOverlay(GuiTextures.PIPE_OVERLAY_1, false) - .itemSlotOverlay(GuiTextures.PIPE_OVERLAY_2, true, false) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true, true) - .specialTexture(GuiTextures.PROGRESS_BAR_LATHE_BASE, 98, 24, 5, 18) - .progressBar(GuiTextures.PROGRESS_BAR_LATHE) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.PIPE_OVERLAY_1, false) + .itemSlotOverlay(GTGuiTextures.PIPE_OVERLAY_2, true, false) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true, true) + .specialTexture(GTGuiTextures.PROGRESS_BAR_LATHE_BASE, 98, 24, 5, 18) + .progressBar(GTGuiTextures.PROGRESS_BAR_LATHE) + ) .sound(GTSoundEvents.CUT) .build(); @@ -1128,9 +1172,11 @@ public final class RecipeMaps { new SimpleRecipeBuilder().duration(150).EUt(2)) .itemInputs(1) .itemOutputs(4) - .itemSlotOverlay(GuiTextures.CRUSHED_ORE_OVERLAY, false) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true) - .progressBar(GuiTextures.PROGRESS_BAR_MACERATE) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.CRUSHED_ORE_OVERLAY, false) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_MACERATE) + ) .sound(GTSoundEvents.MACERATOR) .build(); @@ -1144,11 +1190,13 @@ public final class RecipeMaps { .itemInputs(1) .fluidInputs(1) .fluidOutputs(2) - .itemSlotOverlay(GuiTextures.ATOMIC_OVERLAY_1, false) - .fluidSlotOverlay(GuiTextures.ATOMIC_OVERLAY_2, false) - .fluidSlotOverlay(GuiTextures.POSITIVE_MATTER_OVERLAY, true) - .fluidSlotOverlay(GuiTextures.NEUTRAL_MATTER_OVERLAY, true, true) - .progressBar(GuiTextures.PROGRESS_BAR_MASS_FAB) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.ATOMIC_OVERLAY_1, false) + .fluidSlotOverlay(GTGuiTextures.ATOMIC_OVERLAY_2, false) + .fluidSlotOverlay(GTGuiTextures.POSITIVE_MATTER_OVERLAY, true) + .fluidSlotOverlay(GTGuiTextures.NEUTRAL_MATTER_OVERLAY, true, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_MASS_FAB) + ) .sound(GTSoundEvents.REPLICATOR) .build(); @@ -1172,9 +1220,11 @@ public final class RecipeMaps { .itemOutputs(1) .fluidInputs(2) .fluidOutputs(1) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, false) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true) - .progressBar(GuiTextures.PROGRESS_BAR_MIXER, MoveType.CIRCULAR) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, false) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_MIXER, Direction.CIRCULAR_CW) + ) .sound(GTSoundEvents.MIXER) .build(); @@ -1199,9 +1249,11 @@ public final class RecipeMaps { .itemInputs(2) .itemOutputs(3) .fluidInputs(1) - .itemSlotOverlay(GuiTextures.CRUSHED_ORE_OVERLAY, false) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true) - .progressBar(GuiTextures.PROGRESS_BAR_BATH, MoveType.CIRCULAR) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.CRUSHED_ORE_OVERLAY, false) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_BATH, Direction.CIRCULAR_CW) + ) .sound(GTSoundEvents.BATH) .build(); @@ -1225,9 +1277,11 @@ public final class RecipeMaps { new SimpleRecipeBuilder().EUt(12).duration(10)) .itemInputs(2) .itemOutputs(2) - .itemSlotOverlay(GuiTextures.BOX_OVERLAY, false, true) - .itemSlotOverlay(GuiTextures.BOXED_OVERLAY, true) - .progressBar(GuiTextures.PROGRESS_BAR_UNPACKER) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.BOX_OVERLAY, false, true) + .itemSlotOverlay(GTGuiTextures.BOXED_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_UNPACKER) + ) .sound(GTSoundEvents.ASSEMBLER) .build(); @@ -1248,7 +1302,9 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(1) .itemOutputs(1) - .progressBar(GuiTextures.PROGRESS_BAR_MAGNET) + .uiBuilder(b -> b + .progressBar(GTGuiTextures.PROGRESS_BAR_MAGNET) + ) .sound(GTSoundEvents.ARC) .build(); @@ -1316,12 +1372,14 @@ public final class RecipeMaps { .itemOutputs(1) .fluidInputs(2) .fluidOutputs(1) - .itemSlotOverlay(GuiTextures.DATA_ORB_OVERLAY, false) - .itemSlotOverlay(GuiTextures.ATOMIC_OVERLAY_1, true) - .fluidSlotOverlay(GuiTextures.NEUTRAL_MATTER_OVERLAY, false) - .fluidSlotOverlay(GuiTextures.POSITIVE_MATTER_OVERLAY, false, true) - .fluidSlotOverlay(GuiTextures.ATOMIC_OVERLAY_2, true) - .progressBar(GuiTextures.PROGRESS_BAR_REPLICATOR) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.DATA_ORB_OVERLAY, false) + .itemSlotOverlay(GTGuiTextures.ATOMIC_OVERLAY_1, true) + .fluidSlotOverlay(GTGuiTextures.NEUTRAL_MATTER_OVERLAY, false) + .fluidSlotOverlay(GTGuiTextures.POSITIVE_MATTER_OVERLAY, false, true) + .fluidSlotOverlay(GTGuiTextures.ATOMIC_OVERLAY_2, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_REPLICATOR) + ) .sound(GTSoundEvents.REPLICATOR) .build(); @@ -1334,9 +1392,11 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(1) .itemOutputs(4) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, false) - .itemSlotOverlay(GuiTextures.CRUSHED_ORE_OVERLAY, true) - .progressBar(GuiTextures.PROGRESS_BAR_MACERATE) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, false) + .itemSlotOverlay(GTGuiTextures.CRUSHED_ORE_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_MACERATE) + ) .sound(GTSoundEvents.FIRE) .build(); @@ -1362,6 +1422,7 @@ public final class RecipeMaps { ui.setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, ProgressWidget.MoveType.HORIZONTAL); return ui; }); + // todo update scanner to mui2 /** * Example: @@ -1384,7 +1445,9 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(1) .itemOutputs(6) - .progressBar(GuiTextures.PROGRESS_BAR_SIFT, MoveType.VERTICAL_DOWNWARDS) + .uiBuilder(b -> b + .progressBar(GTGuiTextures.PROGRESS_BAR_SIFT, Direction.DOWN) + ) .sound(SoundEvents.BLOCK_SAND_PLACE) .build(); @@ -1410,9 +1473,11 @@ public final class RecipeMaps { "thermal_centrifuge", new SimpleRecipeBuilder().duration(400).EUt(30)) .itemInputs(1) .itemOutputs(3) - .itemSlotOverlay(GuiTextures.CRUSHED_ORE_OVERLAY, false) - .itemSlotOverlay(GuiTextures.DUST_OVERLAY, true) - .progressBar(GuiTextures.PROGRESS_BAR_MACERATE) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.CRUSHED_ORE_OVERLAY, false) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_MACERATE) + ) .sound(GTSoundEvents.CENTRIFUGE) .build(); @@ -1456,9 +1521,11 @@ public final class RecipeMaps { new SimpleRecipeBuilder()) .itemInputs(2) .itemOutputs(1) - .itemSlotOverlay(GuiTextures.WIREMILL_OVERLAY, false) - .itemSlotOverlay(GuiTextures.INT_CIRCUIT_OVERLAY, false, true) - .progressBar(GuiTextures.PROGRESS_BAR_WIREMILL) + .uiBuilder(b -> b + .itemSlotOverlay(GTGuiTextures.WIREMILL_OVERLAY, false) + .itemSlotOverlay(GTGuiTextures.INT_CIRCUIT_OVERLAY, false, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_WIREMILL) + ) .sound(GTSoundEvents.MOTOR) .build(); @@ -1470,8 +1537,10 @@ public final class RecipeMaps { public static final RecipeMap COMBUSTION_GENERATOR_FUELS = new RecipeMapBuilder<>( "combustion_generator", new FuelRecipeBuilder()) .fluidInputs(1) - .fluidSlotOverlay(GuiTextures.FURNACE_OVERLAY_2, false) - .progressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) + .uiBuilder(b -> b + .fluidSlotOverlay(GTGuiTextures.FURNACE_OVERLAY_2, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) + ) .sound(GTSoundEvents.COMBUSTION) .allowEmptyOutputs() .generator() @@ -1481,8 +1550,10 @@ public final class RecipeMaps { public static final RecipeMap GAS_TURBINE_FUELS = new RecipeMapBuilder<>("gas_turbine", new FuelRecipeBuilder()) .fluidInputs(1) - .fluidSlotOverlay(GuiTextures.DARK_CANISTER_OVERLAY, false) - .progressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR) + .uiBuilder(b -> b + .fluidSlotOverlay(GTGuiTextures.DARK_CANISTER_OVERLAY, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR) + ) .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() .generator() @@ -1493,8 +1564,10 @@ public final class RecipeMaps { new FuelRecipeBuilder()) .fluidInputs(1) .fluidOutputs(1) - .fluidSlotOverlay(GuiTextures.CENTRIFUGE_OVERLAY, false) - .progressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR) + .uiBuilder(b -> b + .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR) + ) .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() .generator() @@ -1504,8 +1577,10 @@ public final class RecipeMaps { public static final RecipeMap SEMI_FLUID_GENERATOR_FUELS = new RecipeMapBuilder<>( "semi_fluid_generator", new FuelRecipeBuilder()) .fluidInputs(1) - .fluidSlotOverlay(GuiTextures.FURNACE_OVERLAY_2, false) - .progressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) + .uiBuilder(b -> b + .fluidSlotOverlay(GTGuiTextures.FURNACE_OVERLAY_2, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) + ) .sound(GTSoundEvents.COMBUSTION) .allowEmptyOutputs() .generator() @@ -1516,8 +1591,10 @@ public final class RecipeMaps { new FuelRecipeBuilder()) .fluidInputs(1) .fluidOutputs(1) - .fluidSlotOverlay(GuiTextures.CENTRIFUGE_OVERLAY, false) - .progressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR) + .uiBuilder(b -> b + .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR) + ) .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() .generator() From d39b1ff0e8be0dc24629bb2eda4f17da2a506af1 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Fri, 16 May 2025 17:21:39 -0700 Subject: [PATCH 19/55] set mui2 for map ui spotless --- .../java/gregtech/api/recipes/RecipeMaps.java | 108 ++++++------------ .../api/recipes/ui/RecipeMapUIBuilder.java | 1 + 2 files changed, 38 insertions(+), 71 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index b62ade32477..a493922f5d7 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -1,11 +1,8 @@ package gregtech.api.recipes; -import com.cleanroommc.modularui.widgets.ProgressWidget.Direction; - import gregtech.api.GTValues; import gregtech.api.gui.GuiTextures; import gregtech.api.gui.widgets.ProgressWidget; -import gregtech.api.gui.widgets.ProgressWidget.MoveType; import gregtech.api.mui.GTGuiTextures; import gregtech.api.recipes.builders.AssemblerRecipeBuilder; import gregtech.api.recipes.builders.AssemblyLineRecipeBuilder; @@ -39,6 +36,7 @@ import net.minecraft.init.SoundEvents; +import com.cleanroommc.modularui.widgets.ProgressWidget.Direction; import crafttweaker.annotations.ZenRegister; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenProperty; @@ -364,10 +362,10 @@ public final class RecipeMaps { .fluidInputs(1) .fluidOutputs(6) .uiBuilder(b -> b - .itemSlotOverlay(GTGuiTextures.EXTRACTOR_OVERLAY, false, false) - .itemSlotOverlay(GTGuiTextures.CANISTER_OVERLAY, false, true) - .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, false, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRACT)) + .itemSlotOverlay(GTGuiTextures.EXTRACTOR_OVERLAY, false, false) + .itemSlotOverlay(GTGuiTextures.CANISTER_OVERLAY, false, true) + .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, false, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRACT)) .sound(GTSoundEvents.CENTRIFUGE) .build(); @@ -434,8 +432,7 @@ public final class RecipeMaps { .fluidSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_3, false, false) .fluidSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_4, false, true) .fluidSlotOverlay(GTGuiTextures.VIAL_OVERLAY_2, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE)) .sound(GTValues.FOOLS.get() ? GTSoundEvents.SCIENCE : GTSoundEvents.CHEMICAL_REACTOR) .onBuild(gregtechId("lcr_copy"), recipeBuilder -> RecipeMaps.LARGE_CHEMICAL_RECIPES.recipeBuilder() .inputs(recipeBuilder.getInputs().toArray(new GTRecipeInput[0])) @@ -485,8 +482,7 @@ public final class RecipeMaps { .fluidInputs(1) .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.CIRCUIT_OVERLAY, false) - .progressBar(GTGuiTextures.PROGRESS_BAR_CIRCUIT_ASSEMBLER) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_CIRCUIT_ASSEMBLER)) .sound(GTSoundEvents.ASSEMBLER) .onBuild(gregtechId("circuit_assembler_solder"), recipeBuilder -> { if (recipeBuilder.getFluidInputs().isEmpty()) { @@ -550,8 +546,7 @@ public final class RecipeMaps { .itemOutputs(1) .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.COMPRESSOR_OVERLAY, false) - .progressBar(GTGuiTextures.PROGRESS_BAR_COMPRESS) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_COMPRESS)) .sound(GTSoundEvents.COMPRESSOR) .build(); @@ -611,8 +606,7 @@ public final class RecipeMaps { .itemSlotOverlay(GTGuiTextures.SAWBLADE_OVERLAY, false) .itemSlotOverlay(GTGuiTextures.CUTTER_OVERLAY, true, false) .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_SLICE) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_SLICE)) .sound(GTSoundEvents.CUT) .onBuild(gregtechId("cutter_fluid"), recipeBuilder -> { if (recipeBuilder.getFluidInputs().isEmpty()) { @@ -706,8 +700,7 @@ public final class RecipeMaps { .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) .fluidSlotOverlay(GTGuiTextures.BEAKER_OVERLAY_1, false) .fluidSlotOverlay(GTGuiTextures.BEAKER_OVERLAY_4, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE)) .sound(GTSoundEvents.BOILER) .build(); @@ -736,8 +729,7 @@ public final class RecipeMaps { .itemSlotOverlay(GTGuiTextures.LIGHTNING_OVERLAY_1, false, false) .itemSlotOverlay(GTGuiTextures.CANISTER_OVERLAY, false, true) .fluidSlotOverlay(GTGuiTextures.LIGHTNING_OVERLAY_2, false) - .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRACT) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRACT)) .sound(GTSoundEvents.ELECTROLYZER) .build(); @@ -763,8 +755,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.CRUSHED_ORE_OVERLAY, false) .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_MAGNET) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_MAGNET)) .sound(GTSoundEvents.ARC) .build(); @@ -790,8 +781,7 @@ public final class RecipeMaps { .fluidOutputs(1) .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.EXTRACTOR_OVERLAY, false) - .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRACT) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRACT)) .sound(GTSoundEvents.COMPRESSOR) .build(); @@ -815,8 +805,7 @@ public final class RecipeMaps { .itemOutputs(1) .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.MOLD_OVERLAY, false, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRUDER) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRUDER)) .sound(GTSoundEvents.ARC) .build(); @@ -842,8 +831,7 @@ public final class RecipeMaps { .fluidOutputs(1) .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, false, true) - .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true, true) - ) + .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true, true)) .sound(GTSoundEvents.CHEMICAL_REACTOR) .build(); @@ -869,8 +857,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.INT_CIRCUIT_OVERLAY, false, true) .fluidSlotOverlay(GTGuiTextures.HEATING_OVERLAY_1, false) - .fluidSlotOverlay(GTGuiTextures.HEATING_OVERLAY_2, true) - ) + .fluidSlotOverlay(GTGuiTextures.HEATING_OVERLAY_2, true)) .sound(GTSoundEvents.BOILER) .build(); @@ -894,8 +881,7 @@ public final class RecipeMaps { .itemOutputs(1) .fluidInputs(1) .uiBuilder(b -> b - .itemSlotOverlay(GTGuiTextures.SOLIDIFIER_OVERLAY, false) - ) + .itemSlotOverlay(GTGuiTextures.SOLIDIFIER_OVERLAY, false)) .sound(GTSoundEvents.COOLING) .build(); @@ -919,8 +905,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.HAMMER_OVERLAY, false) .specialTexture(GTGuiTextures.PROGRESS_BAR_HAMMER_BASE, 78, 42, 20, 6) - .progressBar(GTGuiTextures.PROGRESS_BAR_HAMMER, Direction.DOWN) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_HAMMER, Direction.DOWN)) .sound(GTSoundEvents.FORGE_HAMMER) .build(); @@ -1011,8 +996,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.INT_CIRCUIT_OVERLAY, false, true) .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR)) .sound(GTSoundEvents.COOLING) .build(); @@ -1121,8 +1105,7 @@ public final class RecipeMaps { .itemInputs(2) .itemOutputs(1) .uiBuilder(b -> b - .itemSlotOverlay(GTGuiTextures.LENS_OVERLAY, false, true) - ) + .itemSlotOverlay(GTGuiTextures.LENS_OVERLAY, false, true)) .sound(GTSoundEvents.ELECTROLYZER) .build(); @@ -1148,8 +1131,7 @@ public final class RecipeMaps { .itemSlotOverlay(GTGuiTextures.PIPE_OVERLAY_2, true, false) .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true, true) .specialTexture(GTGuiTextures.PROGRESS_BAR_LATHE_BASE, 98, 24, 5, 18) - .progressBar(GTGuiTextures.PROGRESS_BAR_LATHE) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_LATHE)) .sound(GTSoundEvents.CUT) .build(); @@ -1175,8 +1157,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.CRUSHED_ORE_OVERLAY, false) .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_MACERATE) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_MACERATE)) .sound(GTSoundEvents.MACERATOR) .build(); @@ -1195,8 +1176,7 @@ public final class RecipeMaps { .fluidSlotOverlay(GTGuiTextures.ATOMIC_OVERLAY_2, false) .fluidSlotOverlay(GTGuiTextures.POSITIVE_MATTER_OVERLAY, true) .fluidSlotOverlay(GTGuiTextures.NEUTRAL_MATTER_OVERLAY, true, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_MASS_FAB) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_MASS_FAB)) .sound(GTSoundEvents.REPLICATOR) .build(); @@ -1223,8 +1203,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, false) .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_MIXER, Direction.CIRCULAR_CW) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_MIXER, Direction.CIRCULAR_CW)) .sound(GTSoundEvents.MIXER) .build(); @@ -1252,8 +1231,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.CRUSHED_ORE_OVERLAY, false) .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_BATH, Direction.CIRCULAR_CW) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_BATH, Direction.CIRCULAR_CW)) .sound(GTSoundEvents.BATH) .build(); @@ -1280,8 +1258,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.BOX_OVERLAY, false, true) .itemSlotOverlay(GTGuiTextures.BOXED_OVERLAY, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_UNPACKER) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_UNPACKER)) .sound(GTSoundEvents.ASSEMBLER) .build(); @@ -1303,8 +1280,7 @@ public final class RecipeMaps { .itemInputs(1) .itemOutputs(1) .uiBuilder(b -> b - .progressBar(GTGuiTextures.PROGRESS_BAR_MAGNET) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_MAGNET)) .sound(GTSoundEvents.ARC) .build(); @@ -1378,8 +1354,7 @@ public final class RecipeMaps { .fluidSlotOverlay(GTGuiTextures.NEUTRAL_MATTER_OVERLAY, false) .fluidSlotOverlay(GTGuiTextures.POSITIVE_MATTER_OVERLAY, false, true) .fluidSlotOverlay(GTGuiTextures.ATOMIC_OVERLAY_2, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_REPLICATOR) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_REPLICATOR)) .sound(GTSoundEvents.REPLICATOR) .build(); @@ -1395,8 +1370,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, false) .itemSlotOverlay(GTGuiTextures.CRUSHED_ORE_OVERLAY, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_MACERATE) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_MACERATE)) .sound(GTSoundEvents.FIRE) .build(); @@ -1446,8 +1420,7 @@ public final class RecipeMaps { .itemInputs(1) .itemOutputs(6) .uiBuilder(b -> b - .progressBar(GTGuiTextures.PROGRESS_BAR_SIFT, Direction.DOWN) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_SIFT, Direction.DOWN)) .sound(SoundEvents.BLOCK_SAND_PLACE) .build(); @@ -1476,8 +1449,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.CRUSHED_ORE_OVERLAY, false) .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_MACERATE) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_MACERATE)) .sound(GTSoundEvents.CENTRIFUGE) .build(); @@ -1524,8 +1496,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.WIREMILL_OVERLAY, false) .itemSlotOverlay(GTGuiTextures.INT_CIRCUIT_OVERLAY, false, true) - .progressBar(GTGuiTextures.PROGRESS_BAR_WIREMILL) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_WIREMILL)) .sound(GTSoundEvents.MOTOR) .build(); @@ -1539,8 +1510,7 @@ public final class RecipeMaps { .fluidInputs(1) .uiBuilder(b -> b .fluidSlotOverlay(GTGuiTextures.FURNACE_OVERLAY_2, false) - .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE)) .sound(GTSoundEvents.COMBUSTION) .allowEmptyOutputs() .generator() @@ -1552,8 +1522,7 @@ public final class RecipeMaps { .fluidInputs(1) .uiBuilder(b -> b .fluidSlotOverlay(GTGuiTextures.DARK_CANISTER_OVERLAY, false) - .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR)) .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() .generator() @@ -1566,8 +1535,7 @@ public final class RecipeMaps { .fluidOutputs(1) .uiBuilder(b -> b .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, false) - .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR)) .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() .generator() @@ -1579,8 +1547,7 @@ public final class RecipeMaps { .fluidInputs(1) .uiBuilder(b -> b .fluidSlotOverlay(GTGuiTextures.FURNACE_OVERLAY_2, false) - .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE)) .sound(GTSoundEvents.COMBUSTION) .allowEmptyOutputs() .generator() @@ -1593,8 +1560,7 @@ public final class RecipeMaps { .fluidOutputs(1) .uiBuilder(b -> b .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, false) - .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR) - ) + .progressBar(GTGuiTextures.PROGRESS_BAR_GAS_COLLECTOR)) .sound(GTSoundEvents.TURBINE) .allowEmptyOutputs() .generator() diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java index f9e234be687..6ba48add167 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java @@ -14,6 +14,7 @@ public class RecipeMapUIBuilder { public RecipeMapUIBuilder(RecipeMapUI mapUI) { this.mapUI = mapUI; + this.mapUI.setUsesMui2(); } /** From 9fe269cc9d753a6b681728dbe152580cfc741cab Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Fri, 16 May 2025 17:39:41 -0700 Subject: [PATCH 20/55] use progress value directly in widget fix special texture use GTFluidSlot instead of FluidSlot use IDrawable.of() for slot overlays --- .../SimpleGeneratorMetaTileEntity.java | 2 ++ .../gregtech/api/recipes/ui/RecipeMapUI.java | 29 +++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java index e4443e15cd5..9dab73c95dd 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java @@ -128,6 +128,8 @@ protected void renderOverlays(CCRenderState renderState, Matrix4 translation, IV workable.isWorkingEnabled()); } + // todo mui2 check + @Override protected ModularUI createUI(EntityPlayer entityPlayer) { return createGuiTemplate(entityPlayer).build(getHolder(), entityPlayer); diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 4387cad1a00..c2edaae31ea 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -10,6 +10,7 @@ import gregtech.api.mui.widget.RecipeProgressWidget; import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMap; +import gregtech.common.mui.widget.GTFluidSlot; import net.minecraftforge.items.IItemHandlerModifiable; @@ -19,9 +20,7 @@ import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widget.ParentWidget; -import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widget.sizer.Area; -import com.cleanroommc.modularui.widgets.FluidSlot; import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.ProgressWidget; import com.cleanroommc.modularui.widgets.slot.SlotGroup; @@ -522,22 +521,22 @@ public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandler IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset, PanelSyncManager syncManager) { DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier); - syncManager.syncValue("recipe_progress", progressValue); ParentWidget group = new ParentWidget<>().size(176, 166 + yOffset); group.child(new RecipeProgressWidget() .recipeMap(recipeMap) .size(20) .alignX(0.5f).top(23 + yOffset) - .progress(progressValue::getDoubleValue) + .value(progressValue) .texture(progressTexture, 20) .direction(progressDirection)); addInventorySlotGroup(group, importItems, importFluids, false, yOffset); addInventorySlotGroup(group, exportItems, exportFluids, true, yOffset); if (specialTextureNew != null) { - group.child(new Widget<>() - .flex(flex -> flex.getArea().set(specialTexturePosition)) - .background(specialTextureNew)); + group.child(specialTextureNew.asWidget() + .debugName("special_texture") + .pos(specialTexturePosition.x(), specialTexturePosition.y()) + .size(specialTexturePosition.w(), specialTexturePosition.h())); } return group; } @@ -616,23 +615,23 @@ protected ItemSlot makeItemSlot(SlotGroup group, int x, int y, int slotIndex, II .background(getOverlaysForSlotNew(isOutputs, false, slotIndex == itemHandler.getSlots() - 1)); } - protected FluidSlot makeFluidSlot(int x, int y, int slotIndex, FluidTankList fluidHandler, boolean isOutputs) { - return new FluidSlot() - .syncHandler(SyncHandlers.fluidSlot(fluidHandler.getTankAt(slotIndex)) - .canFillSlot(!isOutputs)) - .alwaysShowFull(true) + protected GTFluidSlot makeFluidSlot(int x, int y, int slotIndex, FluidTankList fluidHandler, boolean isOutputs) { + return new GTFluidSlot() + .syncHandler(GTFluidSlot.sync(fluidHandler.getTankAt(slotIndex)) + .accessibility(true, !isOutputs)) + // todo show always full, should be implemented with mui2 multis .pos(x, y) .background(getOverlaysForSlotNew(isOutputs, true, slotIndex == fluidHandler.getTanks() - 1)); } @ApiStatus.Experimental - protected IDrawable[] getOverlaysForSlotNew(boolean isOutput, boolean isFluid, boolean isLast) { + protected IDrawable getOverlaysForSlotNew(boolean isOutput, boolean isFluid, boolean isLast) { UITexture base = isFluid ? GTGuiTextures.FLUID_SLOT : GTGuiTextures.SLOT; byte overlayKey = computeOverlayKey(isOutput, isFluid, isLast); if (slotTextureOverlays.containsKey(overlayKey)) { - return new UITexture[] { base, slotTextureOverlays.get(overlayKey) }; + return IDrawable.of(base, slotTextureOverlays.get(overlayKey)); } - return new UITexture[] { base }; + return IDrawable.of(base); } /** Marked experimental as this method will be removed when all GTCEu UIs are ported to MUI2. */ From 80a721c9bda947cf8a636b46a01d26cc1297be3d Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 18 May 2025 18:45:52 -0700 Subject: [PATCH 21/55] rework slot overlay methods set max inputs before ui build split overlay maps into Int2Obj maps pull pos out of make slot methods --- .../java/gregtech/api/recipes/RecipeMap.java | 3 +- .../java/gregtech/api/recipes/RecipeMaps.java | 57 ++++++------ .../gregtech/api/recipes/ui/RecipeMapUI.java | 71 ++++++++++----- .../api/recipes/ui/RecipeMapUIBuilder.java | 89 ++++++++++++++----- 4 files changed, 148 insertions(+), 72 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMap.java b/src/main/java/gregtech/api/recipes/RecipeMap.java index 9b920a7239f..94018f05506 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMap.java +++ b/src/main/java/gregtech/api/recipes/RecipeMap.java @@ -145,7 +145,6 @@ public RecipeMap(@NotNull String unlocalizedName, @NotNull R defaultRecipeBuilde @NotNull RecipeMapUIFunction recipeMapUI, int maxInputs, int maxOutputs, int maxFluidInputs, int maxFluidOutputs) { this.unlocalizedName = unlocalizedName; - this.recipeMapUI = recipeMapUI.apply(this); this.maxInputs = maxInputs; this.maxFluidInputs = maxFluidInputs; @@ -154,6 +153,8 @@ public RecipeMap(@NotNull String unlocalizedName, @NotNull R defaultRecipeBuilde this.primaryRecipeCategory = GTRecipeCategory.create(GTValues.MODID, unlocalizedName, getTranslationKey(), this); + this.recipeMapUI = recipeMapUI.apply(this); + defaultRecipeBuilder.setRecipeMap(this); defaultRecipeBuilder.category(primaryRecipeCategory); this.recipeBuilderSample = defaultRecipeBuilder; diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index a493922f5d7..a26a0e9f905 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -2,7 +2,6 @@ import gregtech.api.GTValues; import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.mui.GTGuiTextures; import gregtech.api.recipes.builders.AssemblerRecipeBuilder; import gregtech.api.recipes.builders.AssemblyLineRecipeBuilder; @@ -36,6 +35,7 @@ import net.minecraft.init.SoundEvents; +import com.cleanroommc.modularui.api.drawable.IDrawable; import com.cleanroommc.modularui.widgets.ProgressWidget.Direction; import crafttweaker.annotations.ZenRegister; import stanhebben.zenscript.annotations.ZenClass; @@ -323,16 +323,14 @@ public final class RecipeMaps { @ZenProperty public static final RecipeMap CANNER_RECIPES = new RecipeMapFluidCanner("canner", new SimpleRecipeBuilder(), recipeMap -> { - RecipeMapUI ui = new RecipeMapUI<>(recipeMap, true, true, true, true, false); - // todo update canner to mui2 - ui.setItemSlotOverlay(GuiTextures.CANNER_OVERLAY, false, false); - ui.setItemSlotOverlay(GuiTextures.CANISTER_OVERLAY, false, true); - ui.setItemSlotOverlay(GuiTextures.CANISTER_OVERLAY, true); - ui.setFluidSlotOverlay(GuiTextures.DARK_CANISTER_OVERLAY, false); - ui.setFluidSlotOverlay(GuiTextures.DARK_CANISTER_OVERLAY, true); - ui.setProgressBar(GuiTextures.PROGRESS_BAR_CANNER, ProgressWidget.MoveType.HORIZONTAL); - return ui; + return ui.buildMui2(b -> b + .itemSlotOverlay(GTGuiTextures.CANNER_OVERLAY, false, false) + .itemSlotOverlay(GTGuiTextures.CANISTER_OVERLAY, false, true) + .itemSlotOverlay(GTGuiTextures.CANISTER_OVERLAY, true) + .fluidSlotOverlay(GTGuiTextures.DARK_CANISTER_OVERLAY, false) + .fluidSlotOverlay(GTGuiTextures.DARK_CANISTER_OVERLAY, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_CANNER, Direction.RIGHT)); }); /** @@ -364,7 +362,7 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.EXTRACTOR_OVERLAY, false, false) .itemSlotOverlay(GTGuiTextures.CANISTER_OVERLAY, false, true) - .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, false, true) + .fluidSlotOverlay(GTGuiTextures.CENTRIFUGE_OVERLAY, false) .progressBar(GTGuiTextures.PROGRESS_BAR_EXTRACT)) .sound(GTSoundEvents.CENTRIFUGE) .build(); @@ -429,8 +427,8 @@ public final class RecipeMaps { .itemSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_1, false, false) .itemSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_2, false, true) .itemSlotOverlay(GTGuiTextures.VIAL_OVERLAY_1, true) - .fluidSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_3, false, false) - .fluidSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_4, false, true) + .fluidSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_3, false) + .fluidSlotOverlay(GTGuiTextures.MOLECULAR_OVERLAY_4, false) .fluidSlotOverlay(GTGuiTextures.VIAL_OVERLAY_2, true) .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW_MULTIPLE)) .sound(GTValues.FOOLS.get() ? GTSoundEvents.SCIENCE : GTSoundEvents.CHEMICAL_REACTOR) @@ -923,8 +921,17 @@ public final class RecipeMaps { */ @ZenProperty public static final RecipeMap FORMING_PRESS_RECIPES = new RecipeMapFormingPress( - "forming_press", new SimpleRecipeBuilder(), FormingPressUI::new); - // todo update forming press to mui2 + "forming_press", new SimpleRecipeBuilder(), recipeMap -> new FormingPressUI<>(recipeMap) + .buildMui2(b -> { + IDrawable[] overlays = { GTGuiTextures.PRESS_OVERLAY_2, GTGuiTextures.PRESS_OVERLAY_4, + GTGuiTextures.PRESS_OVERLAY_1 }; + for (int i = 0; i < 3; i++) { + b.itemSlotOverlay(overlays[i], i, false); + b.itemSlotOverlay(overlays[i], i + 3, false); + } + b.itemSlotOverlay(GTGuiTextures.PRESS_OVERLAY_3, true); + b.progressBar(GTGuiTextures.PROGRESS_BAR_COMPRESS, Direction.RIGHT); + })); /** * @@ -950,11 +957,10 @@ public final class RecipeMaps { public static final RecipeMap FURNACE_RECIPES = new RecipeMapFurnace("electric_furnace", new SimpleRecipeBuilder(), recipeMap -> { RecipeMapUI ui = new RecipeMapUI<>(recipeMap, true, true, true, true, false); - ui.setItemSlotOverlay(GuiTextures.FURNACE_OVERLAY_1, false); - ui.setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, ProgressWidget.MoveType.HORIZONTAL); - return ui; + return ui.buildMui2(b -> b + .itemSlotOverlay(GTGuiTextures.FURNACE_OVERLAY_1, false) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW, Direction.RIGHT)); }); - // todo update electric furnace to mui2 /** * Example: @@ -1175,7 +1181,7 @@ public final class RecipeMaps { .itemSlotOverlay(GTGuiTextures.ATOMIC_OVERLAY_1, false) .fluidSlotOverlay(GTGuiTextures.ATOMIC_OVERLAY_2, false) .fluidSlotOverlay(GTGuiTextures.POSITIVE_MATTER_OVERLAY, true) - .fluidSlotOverlay(GTGuiTextures.NEUTRAL_MATTER_OVERLAY, true, true) + .fluidSlotOverlay(GTGuiTextures.NEUTRAL_MATTER_OVERLAY, true) .progressBar(GTGuiTextures.PROGRESS_BAR_MASS_FAB)) .sound(GTSoundEvents.REPLICATOR) .build(); @@ -1352,7 +1358,7 @@ public final class RecipeMaps { .itemSlotOverlay(GTGuiTextures.DATA_ORB_OVERLAY, false) .itemSlotOverlay(GTGuiTextures.ATOMIC_OVERLAY_1, true) .fluidSlotOverlay(GTGuiTextures.NEUTRAL_MATTER_OVERLAY, false) - .fluidSlotOverlay(GTGuiTextures.POSITIVE_MATTER_OVERLAY, false, true) + .fluidSlotOverlay(GTGuiTextures.POSITIVE_MATTER_OVERLAY, false) .fluidSlotOverlay(GTGuiTextures.ATOMIC_OVERLAY_2, true) .progressBar(GTGuiTextures.PROGRESS_BAR_REPLICATOR)) .sound(GTSoundEvents.REPLICATOR) @@ -1391,12 +1397,11 @@ public final class RecipeMaps { public static final RecipeMap SCANNER_RECIPES = new RecipeMapScanner("scanner", new SimpleRecipeBuilder(), recipeMap -> { RecipeMapUI ui = new RecipeMapUI<>(recipeMap, true, true, true, true, false); - ui.setItemSlotOverlay(GuiTextures.DATA_ORB_OVERLAY, false, false); - ui.setItemSlotOverlay(GuiTextures.SCANNER_OVERLAY, false, true); - ui.setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, ProgressWidget.MoveType.HORIZONTAL); - return ui; + return ui.buildMui2(b -> b + .itemSlotOverlay(GTGuiTextures.DATA_ORB_OVERLAY, false, false) + .itemSlotOverlay(GTGuiTextures.SCANNER_OVERLAY, false, true) + .progressBar(GTGuiTextures.PROGRESS_BAR_ARROW, Direction.RIGHT)); }); - // todo update scanner to mui2 /** * Example: diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index c2edaae31ea..91ecb30c8ce 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -26,11 +26,14 @@ import com.cleanroommc.modularui.widgets.slot.SlotGroup; import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; import it.unimi.dsi.fastutil.bytes.Byte2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.function.Consumer; import java.util.function.DoubleSupplier; @ApiStatus.Experimental @@ -62,14 +65,17 @@ public class RecipeMapUI> { /* *********************** MUI 2 *********************** */ // todo try to store this better - private final Byte2ObjectMap slotTextureOverlays = new Byte2ObjectOpenHashMap<>(); + private final Int2ObjectMap itemInputOverlays = new Int2ObjectOpenHashMap<>(); + private final Int2ObjectMap itemOutputOverlays = new Int2ObjectOpenHashMap<>(); + private final Int2ObjectMap fluidInputOverlays = new Int2ObjectOpenHashMap<>(); + private final Int2ObjectMap fluidOutputOverlays = new Int2ObjectOpenHashMap<>(); @ApiStatus.Experimental private boolean usesMui2 = false; private UITexture progressTexture = GTGuiTextures.PROGRESS_BAR_ARROW; private ProgressWidget.Direction progressDirection = ProgressWidget.Direction.RIGHT; // todo sus name - private @Nullable UITexture specialTextureNew; + private @Nullable IDrawable specialTextureNew; /** * @param recipeMap the recipemap corresponding to this ui @@ -571,9 +577,11 @@ protected void addInventorySlotGroup(@NotNull ParentWidget group, int x = startInputsX + 18 * j; int y = startInputsY + 18 * i; if (invertFluids) { - group.child(makeFluidSlot(x, y, slotIndex, fluidHandler, isOutputs)); + group.child(makeFluidSlot(slotIndex, fluidHandler, isOutputs) + .pos(x, y)); } else { - group.child(makeItemSlot(slotGroup, x, y, slotIndex, itemHandler, isOutputs)); + group.child(makeItemSlot(slotGroup, slotIndex, itemHandler, isOutputs) + .pos(x, y)); } } } @@ -584,9 +592,11 @@ protected void addInventorySlotGroup(@NotNull ParentWidget group, for (int i = 0; i < fluidInputsCount; i++) { int y = startInputsY + 18 * i; if (!invertFluids) { - group.child(makeFluidSlot(startSpecX, y, i, fluidHandler, isOutputs)); + group.child(makeFluidSlot(i, fluidHandler, isOutputs) + .pos(startSpecX, y)); } else { - group.child(makeItemSlot(slotGroup, startSpecX, y, i, itemHandler, isOutputs)); + group.child(makeItemSlot(slotGroup, i, itemHandler, isOutputs) + .pos(startSpecX, y)); } } } else { @@ -596,44 +606,49 @@ protected void addInventorySlotGroup(@NotNull ParentWidget group, startInputsX + itemSlotsToLeft * 18 - 18 - 18 * (i % 3); int y = startSpecY + (i / 3) * 18; if (!invertFluids) { - group.child(makeFluidSlot(x, y, i, fluidHandler, isOutputs)); + group.child(makeFluidSlot(i, fluidHandler, isOutputs) + .pos(x, y)); } else { - group.child(makeItemSlot(slotGroup, x, y, i, itemHandler, isOutputs)); + group.child(makeItemSlot(slotGroup, i, itemHandler, isOutputs) + .pos(x, y)); } } } } } - protected ItemSlot makeItemSlot(SlotGroup group, int x, int y, int slotIndex, IItemHandlerModifiable itemHandler, + protected ItemSlot makeItemSlot(SlotGroup group, int slotIndex, IItemHandlerModifiable itemHandler, boolean isOutputs) { return new ItemSlot() .slot(SyncHandlers.itemSlot(itemHandler, slotIndex) .slotGroup(group) .accessibility(!isOutputs, true)) - .pos(x, y) - .background(getOverlaysForSlotNew(isOutputs, false, slotIndex == itemHandler.getSlots() - 1)); + .background(getOverlaysForSlotNew(isOutputs, false, slotIndex)); } - protected GTFluidSlot makeFluidSlot(int x, int y, int slotIndex, FluidTankList fluidHandler, boolean isOutputs) { + protected GTFluidSlot makeFluidSlot(int slotIndex, FluidTankList fluidHandler, boolean isOutputs) { return new GTFluidSlot() .syncHandler(GTFluidSlot.sync(fluidHandler.getTankAt(slotIndex)) .accessibility(true, !isOutputs)) // todo show always full, should be implemented with mui2 multis - .pos(x, y) - .background(getOverlaysForSlotNew(isOutputs, true, slotIndex == fluidHandler.getTanks() - 1)); + .background(getOverlaysForSlotNew(isOutputs, true, slotIndex)); } @ApiStatus.Experimental - protected IDrawable getOverlaysForSlotNew(boolean isOutput, boolean isFluid, boolean isLast) { + protected IDrawable getOverlaysForSlotNew(boolean isOutput, boolean isFluid, int index) { UITexture base = isFluid ? GTGuiTextures.FLUID_SLOT : GTGuiTextures.SLOT; - byte overlayKey = computeOverlayKey(isOutput, isFluid, isLast); - if (slotTextureOverlays.containsKey(overlayKey)) { - return IDrawable.of(base, slotTextureOverlays.get(overlayKey)); + var overlays = getOverlayMap(isOutput, isFluid); + if (overlays.containsKey(index)) { + return IDrawable.of(base, overlays.get(index)); } return IDrawable.of(base); } + protected Int2ObjectMap getOverlayMap(boolean isOutput, boolean isFluid) { + if (isOutput) return isFluid ? fluidOutputOverlays : itemOutputOverlays; + else return isFluid ? fluidInputOverlays : itemInputOverlays; + } + /** Marked experimental as this method will be removed when all GTCEu UIs are ported to MUI2. */ @ApiStatus.Experimental @ApiStatus.Internal @@ -647,6 +662,14 @@ public boolean usesMui2() { return usesMui2; } + // todo this is a quick and dirty method, find a better way + /** Marked experimental as this method will be removed when all GTCEu UIs are ported to MUI2. */ + @ApiStatus.Experimental + public RecipeMapUI buildMui2(Consumer builderConsumer) { + builderConsumer.accept(new RecipeMapUIBuilder(this)); + return this; + } + /** * @param progressTexture the new progress bar texture */ @@ -665,18 +688,20 @@ public void setProgressBarDirection(@NotNull ProgressWidget.Direction direction) * @param specialTexture the special texture to set * @param position the position of the texture: [x, y, width, height] */ - public void setSpecialTexture(@NotNull UITexture specialTexture, @NotNull Area position) { + public void setSpecialTexture(@NotNull IDrawable specialTexture, @NotNull Area position) { this.specialTextureNew = specialTexture; this.specialTexturePosition = position; } /** - * @param key the key to store the slot's texture with - * @param texture the texture to store + * @param texture the texture to store + * @param index the key to store the slot's texture with + * @param isFluid if the slot is fluid + * @param isOutput if the slot is an output */ @ApiStatus.Internal - public void setSlotOverlay(byte key, @NotNull UITexture texture) { - this.slotTextureOverlays.put(key, texture); + public void setSlotOverlay(@NotNull IDrawable texture, int index, boolean isFluid, boolean isOutput) { + getOverlayMap(isOutput, isFluid).put(index, texture); } /** diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java index 6ba48add167..3ab671137ec 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java @@ -1,12 +1,13 @@ package gregtech.api.recipes.ui; +import com.cleanroommc.modularui.api.drawable.IDrawable; import com.cleanroommc.modularui.drawable.UITexture; import com.cleanroommc.modularui.widget.sizer.Area; import com.cleanroommc.modularui.widgets.ProgressWidget; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import static gregtech.api.recipes.ui.RecipeMapUI.computeOverlayKey; - +@ApiStatus.Experimental @SuppressWarnings({ "unused", "UnusedReturnValue" }) public class RecipeMapUIBuilder { @@ -50,21 +51,39 @@ public RecipeMapUIBuilder(RecipeMapUI mapUI) { * @param isOutput if the slot is an output slot * @return this */ - public @NotNull RecipeMapUIBuilder itemSlotOverlay(@NotNull UITexture texture, boolean isOutput) { - itemSlotOverlay(texture, isOutput, false); - itemSlotOverlay(texture, isOutput, true); + public @NotNull RecipeMapUIBuilder itemSlotOverlay(@NotNull IDrawable texture, boolean isOutput) { + int max = getMax(false, isOutput); + for (int i = 0; i < max; i++) { + itemSlotOverlay(texture, i, isOutput); + } return this; } + /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @return this + */ + public @NotNull RecipeMapUIBuilder itemSlotOverlay(@NotNull IDrawable texture, int index, boolean isOutput) { + return slotOverlay(texture, index, false, isOutput); + } + /** * @param texture the texture to use * @param isOutput if the slot is an output slot * @param isLastSlot if the slot is the last slot * @return this */ - public @NotNull RecipeMapUIBuilder itemSlotOverlay(@NotNull UITexture texture, boolean isOutput, + public @NotNull RecipeMapUIBuilder itemSlotOverlay(@NotNull IDrawable texture, + boolean isOutput, boolean isLastSlot) { - return slotOverlay(texture, isOutput, false, isLastSlot); + int max = getMax(false, isOutput); + if (isLastSlot) { + return slotOverlay(texture, max - 1, false, isOutput); + } else for (int i = 0; i < max - 1; i++) { + slotOverlay(texture, i, false, isOutput); + } + return this; } /** @@ -72,33 +91,53 @@ public RecipeMapUIBuilder(RecipeMapUI mapUI) { * @param isOutput if the slot is an output slot * @return this */ - public @NotNull RecipeMapUIBuilder fluidSlotOverlay(@NotNull UITexture texture, boolean isOutput) { - fluidSlotOverlay(texture, isOutput, false); - fluidSlotOverlay(texture, isOutput, true); + public @NotNull RecipeMapUIBuilder fluidSlotOverlay(@NotNull IDrawable texture, + boolean isOutput) { + int max = getMax(true, isOutput); + for (int i = 0; i < max; i++) { + fluidSlotOverlay(texture, i, isOutput); + } return this; } /** - * @param texture the texture to use - * @param isOutput if the slot is an output slot - * @param isLastSlot if the slot is the last slot + * @param texture the texture to use + * @param isOutput if the slot is an output slot * @return this */ - public @NotNull RecipeMapUIBuilder fluidSlotOverlay(@NotNull UITexture texture, boolean isOutput, + public @NotNull RecipeMapUIBuilder fluidSlotOverlay(@NotNull IDrawable texture, + int index, + boolean isOutput) { + return slotOverlay(texture, index, true, isOutput); + } + + /** + * @param texture the texture to use + * @param isOutput if the slot is an output slot + * @return this + */ + public @NotNull RecipeMapUIBuilder fluidSlotOverlay(@NotNull IDrawable texture, + boolean isOutput, boolean isLastSlot) { - return slotOverlay(texture, isOutput, true, isLastSlot); + int max = getMax(true, isOutput); + if (isLastSlot) { + return slotOverlay(texture, max - 1, true, isOutput); + } else for (int i = 0; i < max - 1; i++) { + slotOverlay(texture, i, true, isOutput); + } + return this; } /** - * @param texture the texture to use - * @param isOutput if the slot is an output slot - * @param isFluid if the slot is a fluid slot - * @param isLastSlot if the slot is the last slot + * @param texture the texture to use + * @param index the slot index + * @param isFluid if this slot is fluid + * @param isOutput if this slot is an output * @return this */ - public @NotNull RecipeMapUIBuilder slotOverlay(@NotNull UITexture texture, boolean isOutput, - boolean isFluid, boolean isLastSlot) { - this.mapUI.setSlotOverlay(computeOverlayKey(isOutput, isFluid, isLastSlot), texture); + public @NotNull RecipeMapUIBuilder slotOverlay(@NotNull IDrawable texture, int index, boolean isFluid, + boolean isOutput) { + this.mapUI.setSlotOverlay(texture, index, isFluid, isOutput); return this; } @@ -112,4 +151,10 @@ public RecipeMapUIBuilder(RecipeMapUI mapUI) { this.mapUI.setSpecialTexture(texture, area); return this; } + + private int getMax(boolean isFluid, boolean isOutput) { + var map = mapUI.recipeMap(); + if (isOutput) return isFluid ? map.getMaxFluidOutputs() : map.getMaxOutputs(); + else return isFluid ? map.getMaxFluidInputs() : map.getMaxInputs(); + } } From da09ea832f9b236e930d737e37fa93fa19b1047d Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 18 May 2025 19:14:17 -0700 Subject: [PATCH 22/55] port steam machines to mui2 simplify usesMui2 checks --- .../SimpleMachineMetaTileEntity.java | 5 ++- .../metatileentity/SteamMetaTileEntity.java | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 5522c600ba8..066e2757108 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -492,9 +492,8 @@ public void clearMachineInventory(@NotNull List<@NotNull ItemStack> itemBuffer) @Override public boolean usesMui2() { - RecipeMap recipeMap = getRecipeMap(); - if (recipeMap == null) return false; - return recipeMap.getRecipeMapUI().usesMui2(); + RecipeMap map = getRecipeMap(); + return map != null && map.getRecipeMapUI().usesMui2(); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java index ed904815d2d..a0ef028230a 100644 --- a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java @@ -8,6 +8,8 @@ import gregtech.api.gui.GuiTextures; import gregtech.api.gui.ModularUI; import gregtech.api.gui.widgets.ImageWidget; +import gregtech.api.mui.GTGuiTheme; +import gregtech.api.mui.GTGuis; import gregtech.api.recipes.RecipeMap; import gregtech.api.util.GTUtility; import gregtech.client.particle.VanillaParticleEffects; @@ -34,6 +36,11 @@ import codechicken.lib.render.pipeline.ColourMultiplier; import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; +import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.factory.PosGuiData; +import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; +import com.cleanroommc.modularui.widget.Widget; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; @@ -43,6 +50,8 @@ public abstract class SteamMetaTileEntity extends MetaTileEntity { + // todo quick and dirty fix to not show input tank in ui, find better solution + protected static final FluidTankList EMPTY = new FluidTankList(false); protected static final int STEAM_CAPACITY = 16000; protected final boolean isHighPressure; @@ -127,6 +136,33 @@ public FluidTankList createImportFluidHandler() { return new FluidTankList(false, steamFluidTank); } + @Override + public boolean usesMui2() { + RecipeMap map = getRecipeMap(); + return map != null && map.getRecipeMapUI().usesMui2(); + } + + @Override + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + RecipeMap map = Objects.requireNonNull(getRecipeMap()); + + ModularPanel modularPanel = GTGuis.defaultPanel(this); + + Widget widget = map.getRecipeMapUI().buildWidget(workableHandler::getProgressPercent, importItems, + exportItems, EMPTY, exportFluids, 0, guiSyncManager); + + modularPanel.child(widget) + .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) + .bindPlayerInventory(); + + return modularPanel; + } + + @Override + public GTGuiTheme getUITheme() { + return isHighPressure ? GTGuiTheme.STEEL : GTGuiTheme.BRONZE; + } + public ModularUI.Builder createUITemplate(EntityPlayer player) { return ModularUI.builder(GuiTextures.BACKGROUND_STEAM.get(isHighPressure), 176, 166) .label(6, 6, getMetaFullName()).shouldColor(false) From 4f6cfac9f02b0b2984519ff4181cc0c2ce0d36c7 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 18 May 2025 20:27:09 -0700 Subject: [PATCH 23/55] actually port steam machines to mui2 add todos for fluid slot --- .../api/mui/sync/GTFluidSyncHandler.java | 2 + .../steam/boiler/SteamBoiler.java | 100 ++++++++++++++++-- .../steam/boiler/SteamCoalBoiler.java | 28 +++++ .../steam/boiler/SteamLavaBoiler.java | 18 ++++ .../steam/boiler/SteamSolarBoiler.java | 19 ++++ .../common/mui/widget/GTFluidSlot.java | 2 + 6 files changed, 160 insertions(+), 9 deletions(-) diff --git a/src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java b/src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java index 4571c26e93d..ee98add3314 100644 --- a/src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java +++ b/src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java @@ -142,6 +142,8 @@ public boolean isPhantom() { return phantom; } + // todo decouple show amount from drawn amount and tooltip amount + // probably already done in the mui2 multis pr public GTFluidSyncHandler showAmount(boolean showAmount) { this.showAmount = () -> showAmount; return this; diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java index f322cfbc4b8..3a94c56c493 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java @@ -7,13 +7,12 @@ import gregtech.api.gui.GuiTextures; import gregtech.api.gui.ModularUI; import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.FluidContainerSlotWidget; -import gregtech.api.gui.widgets.ProgressWidget; -import gregtech.api.gui.widgets.ProgressWidget.MoveType; -import gregtech.api.gui.widgets.TankWidget; import gregtech.api.items.itemhandlers.GTItemStackHandler; import gregtech.api.metatileentity.IDataInfoProvider; import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.mui.GTGuiTextures; +import gregtech.api.mui.GTGuiTheme; +import gregtech.api.mui.GTGuis; import gregtech.api.unification.material.Materials; import gregtech.api.util.GTTransferUtils; import gregtech.api.util.GTUtility; @@ -23,6 +22,7 @@ import gregtech.client.renderer.texture.Textures; import gregtech.client.renderer.texture.cube.SimpleSidedCubeRenderer; import gregtech.common.ConfigHolder; +import gregtech.common.mui.widget.GTFluidSlot; import gregtech.core.sound.GTSoundEvents; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -47,6 +47,17 @@ import codechicken.lib.render.pipeline.ColourMultiplier; import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; +import com.cleanroommc.modularui.api.drawable.IDrawable; +import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.drawable.UITexture; +import com.cleanroommc.modularui.factory.PosGuiData; +import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.value.sync.DoubleSyncValue; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; +import com.cleanroommc.modularui.widget.Widget; +import com.cleanroommc.modularui.widgets.ItemSlot; +import com.cleanroommc.modularui.widgets.ProgressWidget; +import com.cleanroommc.modularui.widgets.slot.ModularSlot; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; @@ -331,20 +342,91 @@ protected TextureArea getGuiTexture(String pathTemplate) { type, STRING_SUBSTITUTION_PATTERN.matcher(pathTemplate).replaceAll(Matcher.quoteReplacement(type)))); } + @Override + public boolean usesMui2() { + return true; + } + + @Override + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + return GTGuis.defaultPanel(this) + .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) + .child(new ProgressWidget() + .texture(getEmptyBarDrawable(), GTGuiTextures.PROGRESS_BAR_BOILER_HEAT, -1) + .direction(ProgressWidget.Direction.UP) + .debugName("temp") + .value(new DoubleSyncValue(this::getTemperaturePercent)) + .pos(96, 26) + .size(10, 54)) + .child(new GTFluidSlot() + .debugName("water") + .background(getEmptyBarDrawable()) + .syncHandler(GTFluidSlot.sync(waterFluidTank) + .showAmount(false) + .accessibility(false, false)) + .pos(83, 26) + .size(10, 54)) + .child(new GTFluidSlot() + .debugName("steam") + .background(getEmptyBarDrawable()) + .syncHandler(GTFluidSlot.sync(steamFluidTank) + .showAmount(false) + .accessibility(false, false)) + .pos(70, 26) + .size(10, 54)) + .child(new ItemSlot() + .debugName("fluid in") + .background(getSlotBackground(false)) + .slot(new ModularSlot(containerInventory, 0) + .singletonSlotGroup()) + .pos(43, 26)) + .child(new ItemSlot() + .debugName("fluid out") + .background(getSlotBackground(true)) + .slot(new ModularSlot(containerInventory, 1) + .accessibility(false, true)) + .pos(43, 62)) + .child(new Widget<>() + .pos(43, 44) + .size(18) + .background(isHighPressure ? GTGuiTextures.CANISTER_OVERLAY_STEEL : + GTGuiTextures.CANISTER_OVERLAY_BRONZE)) + .bindPlayerInventory(); + } + + @Override + public GTGuiTheme getUITheme() { + return isHighPressure ? GTGuiTheme.STEEL : GTGuiTheme.BRONZE; + } + + protected UITexture getEmptyBarDrawable() { + return isHighPressure ? GTGuiTextures.PROGRESS_BAR_BOILER_EMPTY_STEEL : + GTGuiTextures.PROGRESS_BAR_BOILER_EMPTY_BRONZE; + } + + protected IDrawable getSlotBackground(boolean output) { + UITexture base = isHighPressure ? GTGuiTextures.SLOT_STEEL : GTGuiTextures.SLOT_BRONZE; + UITexture overlay; + if (isHighPressure) + overlay = output ? GTGuiTextures.OUT_SLOT_OVERLAY_STEEL : GTGuiTextures.IN_SLOT_OVERLAY_STEEL; + else overlay = output ? GTGuiTextures.OUT_SLOT_OVERLAY_BRONZE : GTGuiTextures.IN_SLOT_OVERLAY_BRONZE; + return IDrawable.of(base, overlay); + } + public ModularUI.Builder createUITemplate(EntityPlayer player) { return ModularUI.builder(GuiTextures.BACKGROUND_STEAM.get(isHighPressure), 176, 166) .label(6, 6, getMetaFullName()).shouldColor(false) - .widget(new ProgressWidget(this::getTemperaturePercent, 96, 26, 10, 54) + .widget(new gregtech.api.gui.widgets.ProgressWidget(this::getTemperaturePercent, 96, 26, 10, 54) .setProgressBar(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure), GuiTextures.PROGRESS_BAR_BOILER_HEAT, - MoveType.VERTICAL)) + gregtech.api.gui.widgets.ProgressWidget.MoveType.VERTICAL)) - .widget(new TankWidget(waterFluidTank, 83, 26, 10, 54) + .widget(new gregtech.api.gui.widgets.TankWidget(waterFluidTank, 83, 26, 10, 54) .setBackgroundTexture(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure))) - .widget(new TankWidget(steamFluidTank, 70, 26, 10, 54) + .widget(new gregtech.api.gui.widgets.TankWidget(steamFluidTank, 70, 26, 10, 54) .setBackgroundTexture(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure))) - .widget(new FluidContainerSlotWidget(containerInventory, 0, 43, 26, true) + .widget(new gregtech.api.gui.widgets.FluidContainerSlotWidget(containerInventory, 0, 43, 26, true) .setBackgroundTexture(GuiTextures.SLOT_STEAM.get(isHighPressure), GuiTextures.IN_SLOT_OVERLAY_STEAM.get(isHighPressure))) .slot(containerInventory, 1, 43, 62, true, false, diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java index 555595b007f..efd971237dd 100755 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java @@ -6,6 +6,7 @@ import gregtech.api.items.itemhandlers.GTItemStackHandler; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.mui.GTGuiTextures; import gregtech.api.recipes.ModHandler; import gregtech.api.recipes.category.ICategoryOverride; import gregtech.client.renderer.texture.Textures; @@ -17,6 +18,13 @@ import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.items.IItemHandlerModifiable; +import com.cleanroommc.modularui.factory.PosGuiData; +import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.value.sync.DoubleSyncValue; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; +import com.cleanroommc.modularui.widgets.ItemSlot; +import com.cleanroommc.modularui.widgets.ProgressWidget; +import com.cleanroommc.modularui.widgets.slot.ModularSlot; import org.jetbrains.annotations.NotNull; public class SteamCoalBoiler extends SteamBoiler implements ICategoryOverride { @@ -82,6 +90,26 @@ public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate }; } + @Override + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + return super.buildUI(guiData, guiSyncManager) + .child(new ItemSlot() + .slot(this.importItems, 0) + .pos(115, 62)) + .child(new ItemSlot() + .slot(new ModularSlot(this.exportItems, 0) + .accessibility(false, true)) + .pos(115, 26)) + .child(new ProgressWidget() + .value(new DoubleSyncValue(this::getFuelLeftPercent)) + .pos(115, 44) + .size(18) + .texture(isHighPressure ? + GTGuiTextures.PROGRESS_BAR_BOILER_FUEL_STEEL : + GTGuiTextures.PROGRESS_BAR_BOILER_FUEL_BRONZE, 18) + .direction(ProgressWidget.Direction.UP)); + } + @Override public ModularUI createUI(EntityPlayer player) { return createUITemplate(player) diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java index 1269bf30450..ac564c021a9 100755 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java @@ -10,10 +10,12 @@ import gregtech.api.gui.widgets.TankWidget; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.mui.GTGuiTextures; import gregtech.api.unification.material.Materials; import gregtech.client.particle.VanillaParticleEffects; import gregtech.client.renderer.texture.Textures; import gregtech.common.ConfigHolder; +import gregtech.common.mui.widget.GTFluidSlot; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; @@ -26,6 +28,9 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import com.cleanroommc.modularui.factory.PosGuiData; +import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMaps; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; @@ -120,6 +125,19 @@ protected int getCoolDownRate() { return 1; } + @Override + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + return super.buildUI(guiData, guiSyncManager) + .child(new GTFluidSlot() + .syncHandler(GTFluidSlot.sync(fuelFluidTank) + .showAmount(true)) + .pos(119, 26) + .size(10, 54) + .overlay(isHighPressure ? + GTGuiTextures.PROGRESS_BAR_BOILER_EMPTY_STEEL : + GTGuiTextures.PROGRESS_BAR_BOILER_EMPTY_BRONZE)); + } + @Override protected ModularUI createUI(EntityPlayer entityPlayer) { return createUITemplate(entityPlayer) diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java index 970afae65d3..687ad2b9fd6 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java @@ -5,6 +5,7 @@ import gregtech.api.gui.widgets.ProgressWidget.MoveType; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.mui.GTGuiTextures; import gregtech.api.util.GTUtility; import gregtech.client.renderer.texture.Textures; @@ -13,6 +14,12 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import com.cleanroommc.modularui.factory.PosGuiData; +import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.value.sync.DoubleSyncValue; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; +import com.cleanroommc.modularui.widgets.ProgressWidget; + public class SteamSolarBoiler extends SteamBoiler { public SteamSolarBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure) { @@ -46,6 +53,18 @@ protected int getCoolDownRate() { return 3; } + @Override + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + return super.buildUI(guiData, guiSyncManager) + .child(new ProgressWidget() + .value(new DoubleSyncValue(() -> GTUtility.canSeeSunClearly(getWorld(), getPos()) ? 1.0 : 0.0)) + .pos(114, 44) + .size(20) + .texture(isHighPressure ? + GTGuiTextures.PROGRESS_BAR_SOLAR_STEEL : + GTGuiTextures.PROGRESS_BAR_SOLAR_BRONZE, -1)); + } + @Override protected ModularUI createUI(EntityPlayer entityPlayer) { return createUITemplate(entityPlayer) diff --git a/src/main/java/gregtech/common/mui/widget/GTFluidSlot.java b/src/main/java/gregtech/common/mui/widget/GTFluidSlot.java index 2530e38a587..2c4fc79fcab 100644 --- a/src/main/java/gregtech/common/mui/widget/GTFluidSlot.java +++ b/src/main/java/gregtech/common/mui/widget/GTFluidSlot.java @@ -123,6 +123,8 @@ public void draw(ModularGuiContext context, WidgetSlotTheme widgetTheme) { if (content == null) content = this.syncHandler.getLockedFluid(); + // todo add option for drawing partial fluid instead of always full + // probably already done in the mui2 multis pr GuiDraw.drawFluidTexture(content, 1, 1, getArea().w() - 2, getArea().h() - 2, 0); if (content != null && this.syncHandler.showAmount()) { From 4db04a43183348c281e0f64b506f5bcf8ca5f9df Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 18 May 2025 20:40:19 -0700 Subject: [PATCH 24/55] port singleblock generators to mui2 --- .../SimpleGeneratorMetaTileEntity.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java index 9dab73c95dd..84481ba9adf 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java @@ -10,6 +10,8 @@ import gregtech.api.gui.ModularUI; import gregtech.api.gui.widgets.LabelWidget; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.mui.GTGuiTextures; +import gregtech.api.mui.GTGuis; import gregtech.api.recipes.RecipeMap; import gregtech.client.renderer.ICubeRenderer; import gregtech.client.renderer.texture.Textures; @@ -28,6 +30,11 @@ import codechicken.lib.render.CCRenderState; import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; +import com.cleanroommc.modularui.api.drawable.IKey; +import com.cleanroommc.modularui.factory.PosGuiData; +import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.value.sync.PanelSyncManager; +import com.cleanroommc.modularui.widget.Widget; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -130,6 +137,44 @@ protected void renderOverlays(CCRenderState renderState, Matrix4 translation, IV // todo mui2 check + @Override + public boolean usesMui2() { + RecipeMap map = getRecipeMap(); + return map != null && map.getRecipeMapUI().usesMui2(); + } + + @Override + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + RecipeMap workableRecipeMap = workable.getRecipeMap(); + int yOffset = 0; + if (workableRecipeMap.getMaxInputs() >= 6 || workableRecipeMap.getMaxFluidInputs() >= 6 || + workableRecipeMap.getMaxOutputs() >= 6 || workableRecipeMap.getMaxFluidOutputs() >= 6) { + yOffset = FONT_HEIGHT; + } + + ModularPanel panel = GTGuis.createPanel(this, 176, 166 + yOffset); + Widget widget = workableRecipeMap.getRecipeMapUI().buildWidget(workable::getProgressPercent, importItems, + exportItems, importFluids, exportFluids, yOffset, guiSyncManager); + + panel.child(widget) + .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) + // .child(new ItemSlot() + // .slot(SyncHandlers.itemSlot(chargerInventory, 0)) + // .pos(79, 62 + yOffset) + // .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY) + // .tooltip(t -> t.addLine(IKey.lang("gregtech.gui.charger_slot.tooltip", GTValues.VNF[getTier()], + // GTValues.VNF[getTier()])))) + .bindPlayerInventory(); + + if (exportItems.getSlots() + exportFluids.getTanks() <= 9) { + panel.child(new Widget<>() + .size(17) + .pos(152, 63 + yOffset) + .background(GTGuiTextures.getLogo(getUITheme()))); + } + return panel; + } + @Override protected ModularUI createUI(EntityPlayer entityPlayer) { return createGuiTemplate(entityPlayer).build(getHolder(), entityPlayer); From e9b07ecece569a6e60a27cb562de14267c6c3540 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 18 May 2025 20:56:53 -0700 Subject: [PATCH 25/55] spotless --- src/main/java/gregtech/api/recipes/RecipeMaps.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index a26a0e9f905..bc47899d6b4 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -3,7 +3,6 @@ import gregtech.api.GTValues; import gregtech.api.gui.GuiTextures; import gregtech.api.mui.GTGuiTextures; -import gregtech.api.recipes.builders.AssemblerRecipeBuilder; import gregtech.api.recipes.builders.AssemblyLineRecipeBuilder; import gregtech.api.recipes.builders.BlastRecipeBuilder; import gregtech.api.recipes.builders.CircuitAssemblerRecipeBuilder; From a3e50d0068597ddadbb4d2e731d830854d6ae3f3 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 18 May 2025 21:06:08 -0700 Subject: [PATCH 26/55] improve/cleanup existing mui2 code add todo --- .../SimpleGeneratorMetaTileEntity.java | 5 +-- .../SimpleMachineMetaTileEntity.java | 37 ++++++++----------- .../metatileentity/SteamMetaTileEntity.java | 2 + 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java index 84481ba9adf..2db342d6582 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java @@ -39,6 +39,7 @@ import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Objects; import java.util.function.Function; public class SimpleGeneratorMetaTileEntity extends WorkableTieredMetaTileEntity implements IActiveOutputSide { @@ -135,8 +136,6 @@ protected void renderOverlays(CCRenderState renderState, Matrix4 translation, IV workable.isWorkingEnabled()); } - // todo mui2 check - @Override public boolean usesMui2() { RecipeMap map = getRecipeMap(); @@ -145,7 +144,7 @@ public boolean usesMui2() { @Override public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { - RecipeMap workableRecipeMap = workable.getRecipeMap(); + RecipeMap workableRecipeMap = Objects.requireNonNull(workable.getRecipeMap(), "recipe map is null"); int yOffset = 0; if (workableRecipeMap.getMaxInputs() >= 6 || workableRecipeMap.getMaxFluidInputs() >= 6 || workableRecipeMap.getMaxOutputs() >= 6 || workableRecipeMap.getMaxFluidOutputs() >= 6) { diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 066e2757108..385cdff5f2b 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -71,6 +71,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.function.Function; import static gregtech.api.capability.GregtechDataCodes.*; @@ -498,7 +499,7 @@ public boolean usesMui2() { @Override public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { - RecipeMap workableRecipeMap = workable.getRecipeMap(); + RecipeMap workableRecipeMap = Objects.requireNonNull(workable.getRecipeMap(), "recipe map is null"); int yOffset = 0; if (workableRecipeMap.getMaxInputs() >= 6 || workableRecipeMap.getMaxFluidInputs() >= 6 || workableRecipeMap.getMaxOutputs() >= 6 || workableRecipeMap.getMaxFluidOutputs() >= 6) { @@ -509,53 +510,47 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) Widget widget = workableRecipeMap.getRecipeMapUI().buildWidget(workable::getProgressPercent, importItems, exportItems, importFluids, exportFluids, yOffset, guiSyncManager); + BooleanSyncValue hasEnergy = new BooleanSyncValue(workable::isHasNotEnoughEnergy); + panel.child(widget) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) .child(new ItemSlot() .slot(SyncHandlers.itemSlot(chargerInventory, 0)) .pos(79, 62 + yOffset) .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY) - .tooltip(t -> t.addLine(IKey.lang("gregtech.gui.charger_slot.tooltip", GTValues.VNF[getTier()], - GTValues.VNF[getTier()])))) + .addTooltipLine(IKey.lang("gregtech.gui.charger_slot.tooltip", + GTValues.VNF[getTier()], GTValues.VNF[getTier()]))) .child(new Widget<>() .size(18, 18) .pos(79, 42 + yOffset) .background(GTGuiTextures.INDICATOR_NO_ENERGY) - // todo this isnt synced, and flicker appears on ui open even when it has enough energy - .setEnabledIf($ -> workable.isHasNotEnoughEnergy())) + // todo flicker appears on ui open even when it has enough energy + // will need to test this + .setEnabledIf($ -> hasEnergy.getBoolValue())) .bindPlayerInventory(); int leftButtonStartX = 7; if (exportItems.getSlots() > 0) { - BooleanSyncValue outputValue = new BooleanSyncValue(() -> autoOutputItems, val -> autoOutputItems = val); - guiSyncManager.syncValue("item_auto_output", outputValue); panel.child(new ToggleButton() .pos(leftButtonStartX, 62 + yOffset) - .value(new BoolValue.Dynamic(outputValue::getBoolValue, outputValue::setBoolValue)) .overlay(GTGuiTextures.BUTTON_ITEM_OUTPUT) - .tooltipBuilder(t -> t - .setAutoUpdate(true) - .addLine(outputValue.getBoolValue() ? - IKey.lang("gregtech.gui.item_auto_output.tooltip.enabled") : - IKey.lang("gregtech.gui.item_auto_output.tooltip.disabled")))); + .value(new BooleanSyncValue(() -> autoOutputItems, val -> autoOutputItems = val)) + .addTooltip(true, IKey.lang("gregtech.gui.item_auto_output.tooltip.enabled")) + .addTooltip(false, IKey.lang("gregtech.gui.item_auto_output.tooltip.disabled"))); + leftButtonStartX += 18; } if (exportFluids.getTanks() > 0) { - BooleanSyncValue outputValue = new BooleanSyncValue(() -> autoOutputFluids, val -> autoOutputFluids = val); - guiSyncManager.syncValue("fluid_auto_output", outputValue); panel.child(new ToggleButton() .pos(leftButtonStartX, 62 + yOffset) - .value(new BoolValue.Dynamic(outputValue::getBoolValue, outputValue::setBoolValue)) .overlay(GTGuiTextures.BUTTON_FLUID_OUTPUT) - .tooltipBuilder(t -> t - .setAutoUpdate(true) - .addLine(outputValue.getBoolValue() ? - IKey.lang("gregtech.gui.fluid_auto_output.tooltip.enabled") : - IKey.lang("gregtech.gui.fluid_auto_output.tooltip.disabled")))); + .value(new BooleanSyncValue(() -> autoOutputFluids, val -> autoOutputFluids = val)) + .addTooltip(true, IKey.lang("gregtech.gui.fluid_auto_output.tooltip.enabled")) + .addTooltip(false, IKey.lang("gregtech.gui.fluid_auto_output.tooltip.disabled"))); } if (exportItems.getSlots() + exportFluids.getTanks() <= 9) { diff --git a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java index a0ef028230a..6fb14bffe18 100644 --- a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java @@ -148,6 +148,8 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) ModularPanel modularPanel = GTGuis.defaultPanel(this); + // todo this method needs options to ignore certain handlers + // actually, steam machines manually construct their ui instead of using the recipe map ui Widget widget = map.getRecipeMapUI().buildWidget(workableHandler::getProgressPercent, importItems, exportItems, EMPTY, exportFluids, 0, guiSyncManager); From 1cc2681d6fc091b9aaca547440cf4e0a7c2b09f8 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Mon, 19 May 2025 13:09:33 -0700 Subject: [PATCH 27/55] spotless --- .../gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 385cdff5f2b..86f7c9f3cdb 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -59,7 +59,6 @@ import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; -import com.cleanroommc.modularui.value.BoolValue; import com.cleanroommc.modularui.value.sync.BooleanSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; From 14a022115a576d5f7383470f7a06421d1f2a3e6e Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Mon, 19 May 2025 13:19:20 -0700 Subject: [PATCH 28/55] null check ui builder and simplify --- src/main/java/gregtech/api/recipes/RecipeMapBuilder.java | 9 ++++----- src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java index af176709d15..dcd0e62ee24 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java +++ b/src/main/java/gregtech/api/recipes/RecipeMapBuilder.java @@ -17,6 +17,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Map; +import java.util.Objects; import java.util.function.Consumer; import static gregtech.api.recipes.ui.RecipeMapUI.computeOverlayKey; @@ -276,7 +277,7 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip public @NotNull RecipeMapBuilder uiBuilder(@NotNull Consumer mapUIBuilder) { this.usesMui2 = true; - this.mapUIBuilder = mapUIBuilder; + this.mapUIBuilder = Objects.requireNonNull(mapUIBuilder, "ui builder is null"); return this; } @@ -287,10 +288,8 @@ public RecipeMapBuilder(@NotNull String unlocalizedName, @NotNull B defaultRecip private @NotNull RecipeMapUI buildUI(@NotNull RecipeMap recipeMap) { RecipeMapUI ui = new RecipeMapUI<>(recipeMap, modifyItemInputs, modifyItemOutputs, modifyFluidInputs, modifyFluidOutputs, isGenerator); - if (usesMui2) { - // if "usesMui2" is true, then "mapUIBuilder" is not null - // noinspection DataFlowIssue - this.mapUIBuilder.accept(new RecipeMapUIBuilder(ui)); + if (usesMui2 && this.mapUIBuilder != null) { + ui.buildMui2(this.mapUIBuilder); } else { if (progressBar != null) { ui.setProgressBarTexture(progressBar); diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 91ecb30c8ce..c750a6a76a6 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -665,7 +665,7 @@ public boolean usesMui2() { // todo this is a quick and dirty method, find a better way /** Marked experimental as this method will be removed when all GTCEu UIs are ported to MUI2. */ @ApiStatus.Experimental - public RecipeMapUI buildMui2(Consumer builderConsumer) { + public RecipeMapUI buildMui2(@NotNull Consumer builderConsumer) { builderConsumer.accept(new RecipeMapUIBuilder(this)); return this; } From 2ca12cb0748cca3a337b1ba17aca121afeba456c Mon Sep 17 00:00:00 2001 From: Zorbatron <46525467+Zorbatron@users.noreply.github.com> Date: Wed, 2 Jul 2025 01:39:56 -0400 Subject: [PATCH 29/55] Actually merge master in properly :facepalm: --- .../common/metatileentities/steam/boiler/SteamBoiler.java | 4 ++-- .../common/metatileentities/steam/boiler/SteamLavaBoiler.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java index 3a94c56c493..b364c3f3fc3 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java @@ -362,7 +362,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) .debugName("water") .background(getEmptyBarDrawable()) .syncHandler(GTFluidSlot.sync(waterFluidTank) - .showAmount(false) + .showAmountOnSlot(false) .accessibility(false, false)) .pos(83, 26) .size(10, 54)) @@ -370,7 +370,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) .debugName("steam") .background(getEmptyBarDrawable()) .syncHandler(GTFluidSlot.sync(steamFluidTank) - .showAmount(false) + .showAmountOnSlot(false) .accessibility(false, false)) .pos(70, 26) .size(10, 54)) diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java index ac564c021a9..53ee4177a59 100755 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java @@ -130,7 +130,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) return super.buildUI(guiData, guiSyncManager) .child(new GTFluidSlot() .syncHandler(GTFluidSlot.sync(fuelFluidTank) - .showAmount(true)) + .showAmountOnSlot(true)) .pos(119, 26) .size(10, 54) .overlay(isHighPressure ? From a3b023b26e54c876c1df727598bdc86213838290 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 14 Aug 2025 21:49:36 -0700 Subject: [PATCH 30/55] remove old ui code from SteamBoiler and extending classes --- .../steam/boiler/SteamBoiler.java | 24 ------------------- .../steam/boiler/SteamCoalBoiler.java | 12 ---------- .../steam/boiler/SteamLavaBoiler.java | 8 ------- .../steam/boiler/SteamSolarBoiler.java | 8 ------- 4 files changed, 52 deletions(-) diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java index b364c3f3fc3..b9d26868079 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java @@ -413,30 +413,6 @@ protected IDrawable getSlotBackground(boolean output) { return IDrawable.of(base, overlay); } - public ModularUI.Builder createUITemplate(EntityPlayer player) { - return ModularUI.builder(GuiTextures.BACKGROUND_STEAM.get(isHighPressure), 176, 166) - .label(6, 6, getMetaFullName()).shouldColor(false) - .widget(new gregtech.api.gui.widgets.ProgressWidget(this::getTemperaturePercent, 96, 26, 10, 54) - .setProgressBar(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure), - GuiTextures.PROGRESS_BAR_BOILER_HEAT, - gregtech.api.gui.widgets.ProgressWidget.MoveType.VERTICAL)) - - .widget(new gregtech.api.gui.widgets.TankWidget(waterFluidTank, 83, 26, 10, 54) - .setBackgroundTexture(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure))) - .widget(new gregtech.api.gui.widgets.TankWidget(steamFluidTank, 70, 26, 10, 54) - .setBackgroundTexture(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure))) - - .widget(new gregtech.api.gui.widgets.FluidContainerSlotWidget(containerInventory, 0, 43, 26, true) - .setBackgroundTexture(GuiTextures.SLOT_STEAM.get(isHighPressure), - GuiTextures.IN_SLOT_OVERLAY_STEAM.get(isHighPressure))) - .slot(containerInventory, 1, 43, 62, true, false, - GuiTextures.SLOT_STEAM.get(isHighPressure), - GuiTextures.OUT_SLOT_OVERLAY_STEAM.get(isHighPressure)) - .image(43, 44, 18, 18, GuiTextures.CANISTER_OVERLAY_STEAM.get(isHighPressure)) - - .bindPlayerInventory(player.inventory, GuiTextures.SLOT_STEAM.get(isHighPressure), 0); - } - @Override public void addInformation(ItemStack stack, @Nullable World player, List tooltip, boolean advanced) { tooltip.add(String.format("%s %s", diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java index efd971237dd..3e3c3f2f5d4 100755 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java @@ -110,18 +110,6 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) .direction(ProgressWidget.Direction.UP)); } - @Override - public ModularUI createUI(EntityPlayer player) { - return createUITemplate(player) - .slot(this.importItems, 0, 115, 62, - GuiTextures.SLOT_STEAM.get(isHighPressure), GuiTextures.COAL_OVERLAY_STEAM.get(isHighPressure)) - .slot(this.exportItems, 0, 115, 26, true, false, - GuiTextures.SLOT_STEAM.get(isHighPressure), GuiTextures.DUST_OVERLAY_STEAM.get(isHighPressure)) - .progressBar(this::getFuelLeftPercent, 115, 44, 18, 18, - GuiTextures.PROGRESS_BAR_BOILER_FUEL.get(isHighPressure), MoveType.VERTICAL) - .build(getHolder(), player); - } - @Override public @NotNull String @NotNull [] getJEICategoryOverrides() { return new String[] { "minecraft.fuel" }; diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java index 53ee4177a59..0cfff72c499 100755 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java @@ -138,14 +138,6 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) GTGuiTextures.PROGRESS_BAR_BOILER_EMPTY_BRONZE)); } - @Override - protected ModularUI createUI(EntityPlayer entityPlayer) { - return createUITemplate(entityPlayer) - .widget(new TankWidget(fuelFluidTank, 119, 26, 10, 54) - .setBackgroundTexture(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure))) - .build(getHolder(), entityPlayer); - } - @SideOnly(Side.CLIENT) @Override public void randomDisplayTick() { diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java index 687ad2b9fd6..dc1e15dd4f2 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java @@ -65,14 +65,6 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) GTGuiTextures.PROGRESS_BAR_SOLAR_BRONZE, -1)); } - @Override - protected ModularUI createUI(EntityPlayer entityPlayer) { - return createUITemplate(entityPlayer) - .progressBar(() -> GTUtility.canSeeSunClearly(getWorld(), getPos()) ? 1.0 : 0.0, 114, 44, 20, 20, - GuiTextures.PROGRESS_BAR_SOLAR_STEAM.get(isHighPressure), MoveType.HORIZONTAL) - .build(getHolder(), entityPlayer); - } - @SideOnly(Side.CLIENT) @Override public void randomDisplayTick() { From 8a9491669bba74b870650ee14d17294ec5ebf216 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 14 Aug 2025 22:00:17 -0700 Subject: [PATCH 31/55] fix SteamLavaBoiler lava fluid slot --- .../common/metatileentities/steam/boiler/SteamLavaBoiler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java index 0cfff72c499..cdce2288d9c 100755 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java @@ -130,10 +130,10 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) return super.buildUI(guiData, guiSyncManager) .child(new GTFluidSlot() .syncHandler(GTFluidSlot.sync(fuelFluidTank) - .showAmountOnSlot(true)) + .showAmountOnSlot(false)) .pos(119, 26) .size(10, 54) - .overlay(isHighPressure ? + .background(isHighPressure ? GTGuiTextures.PROGRESS_BAR_BOILER_EMPTY_STEEL : GTGuiTextures.PROGRESS_BAR_BOILER_EMPTY_BRONZE)); } From 8473cb253bc4cf15a160681a33624b2723616092 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 14 Aug 2025 22:08:36 -0700 Subject: [PATCH 32/55] use `slotOverlay()` directly --- src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java index 3ab671137ec..4622e869232 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java @@ -54,7 +54,7 @@ public RecipeMapUIBuilder(RecipeMapUI mapUI) { public @NotNull RecipeMapUIBuilder itemSlotOverlay(@NotNull IDrawable texture, boolean isOutput) { int max = getMax(false, isOutput); for (int i = 0; i < max; i++) { - itemSlotOverlay(texture, i, isOutput); + slotOverlay(texture, i, false, isOutput); } return this; } @@ -95,7 +95,7 @@ public RecipeMapUIBuilder(RecipeMapUI mapUI) { boolean isOutput) { int max = getMax(true, isOutput); for (int i = 0; i < max; i++) { - fluidSlotOverlay(texture, i, isOutput); + slotOverlay(texture, i, true, isOutput); } return this; } From bbb2991825b7a039b312c24a9366bf119d01f16e Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 14 Aug 2025 22:09:58 -0700 Subject: [PATCH 33/55] rename mui2 special drawable --- src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index c750a6a76a6..c67ed8abbb2 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -74,8 +74,7 @@ public class RecipeMapUI> { private boolean usesMui2 = false; private UITexture progressTexture = GTGuiTextures.PROGRESS_BAR_ARROW; private ProgressWidget.Direction progressDirection = ProgressWidget.Direction.RIGHT; - // todo sus name - private @Nullable IDrawable specialTextureNew; + private @Nullable IDrawable specialDrawableTexture; /** * @param recipeMap the recipemap corresponding to this ui @@ -538,8 +537,8 @@ public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandler .direction(progressDirection)); addInventorySlotGroup(group, importItems, importFluids, false, yOffset); addInventorySlotGroup(group, exportItems, exportFluids, true, yOffset); - if (specialTextureNew != null) { - group.child(specialTextureNew.asWidget() + if (specialDrawableTexture != null) { + group.child(specialDrawableTexture.asWidget() .debugName("special_texture") .pos(specialTexturePosition.x(), specialTexturePosition.y()) .size(specialTexturePosition.w(), specialTexturePosition.h())); @@ -689,7 +688,7 @@ public void setProgressBarDirection(@NotNull ProgressWidget.Direction direction) * @param position the position of the texture: [x, y, width, height] */ public void setSpecialTexture(@NotNull IDrawable specialTexture, @NotNull Area position) { - this.specialTextureNew = specialTexture; + this.specialDrawableTexture = specialTexture; this.specialTexturePosition = position; } From 9c9b9a5c6c1ac97f9157b8c5f51ad88e63f9f515 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 14 Aug 2025 22:12:00 -0700 Subject: [PATCH 34/55] rename mui2 special drawable and method address todo --- src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index c67ed8abbb2..831628ce172 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -622,19 +622,19 @@ protected ItemSlot makeItemSlot(SlotGroup group, int slotIndex, IItemHandlerModi .slot(SyncHandlers.itemSlot(itemHandler, slotIndex) .slotGroup(group) .accessibility(!isOutputs, true)) - .background(getOverlaysForSlotNew(isOutputs, false, slotIndex)); + .background(getDrawableOverlaysForSlot(isOutputs, false, slotIndex)); } protected GTFluidSlot makeFluidSlot(int slotIndex, FluidTankList fluidHandler, boolean isOutputs) { return new GTFluidSlot() .syncHandler(GTFluidSlot.sync(fluidHandler.getTankAt(slotIndex)) - .accessibility(true, !isOutputs)) - // todo show always full, should be implemented with mui2 multis - .background(getOverlaysForSlotNew(isOutputs, true, slotIndex)); + .accessibility(true, !isOutputs) + .drawAlwaysFull(true)) + .background(getDrawableOverlaysForSlot(isOutputs, true, slotIndex)); } @ApiStatus.Experimental - protected IDrawable getOverlaysForSlotNew(boolean isOutput, boolean isFluid, int index) { + protected IDrawable getDrawableOverlaysForSlot(boolean isOutput, boolean isFluid, int index) { UITexture base = isFluid ? GTGuiTextures.FLUID_SLOT : GTGuiTextures.SLOT; var overlays = getOverlayMap(isOutput, isFluid); if (overlays.containsKey(index)) { From 88bfa5a57053c435985aded6617e7ff9504a6fae Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 14 Aug 2025 22:32:48 -0700 Subject: [PATCH 35/55] remove irrelevant todo --- .../java/gregtech/api/metatileentity/SteamMetaTileEntity.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java index 6fb14bffe18..a0ef028230a 100644 --- a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java @@ -148,8 +148,6 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) ModularPanel modularPanel = GTGuis.defaultPanel(this); - // todo this method needs options to ignore certain handlers - // actually, steam machines manually construct their ui instead of using the recipe map ui Widget widget = map.getRecipeMapUI().buildWidget(workableHandler::getProgressPercent, importItems, exportItems, EMPTY, exportFluids, 0, guiSyncManager); From e7d7b823fc11e6a31b3da8e9c80c341286bf97d8 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 14 Aug 2025 22:39:18 -0700 Subject: [PATCH 36/55] remove commented code --- .../api/metatileentity/SimpleGeneratorMetaTileEntity.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java index 2db342d6582..5d91c8feb4a 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java @@ -157,12 +157,6 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) panel.child(widget) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - // .child(new ItemSlot() - // .slot(SyncHandlers.itemSlot(chargerInventory, 0)) - // .pos(79, 62 + yOffset) - // .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY) - // .tooltip(t -> t.addLine(IKey.lang("gregtech.gui.charger_slot.tooltip", GTValues.VNF[getTier()], - // GTValues.VNF[getTier()])))) .bindPlayerInventory(); if (exportItems.getSlots() + exportFluids.getTanks() <= 9) { From 83dc7659fb7062c22003415aacc0b910f1b7946c Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 14 Aug 2025 22:45:03 -0700 Subject: [PATCH 37/55] actually sync the sync value and remove todo --- .../api/metatileentity/SimpleMachineMetaTileEntity.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 86f7c9f3cdb..eed434e1ea2 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -510,6 +510,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) exportItems, importFluids, exportFluids, yOffset, guiSyncManager); BooleanSyncValue hasEnergy = new BooleanSyncValue(workable::isHasNotEnoughEnergy); + guiSyncManager.syncValue("has_energy", hasEnergy); panel.child(widget) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) @@ -523,8 +524,6 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) .size(18, 18) .pos(79, 42 + yOffset) .background(GTGuiTextures.INDICATOR_NO_ENERGY) - // todo flicker appears on ui open even when it has enough energy - // will need to test this .setEnabledIf($ -> hasEnergy.getBoolValue())) .bindPlayerInventory(); From 8d1cc64aedc249745311c11a865092de3380689f Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 14 Aug 2025 22:45:27 -0700 Subject: [PATCH 38/55] spotless --- .../common/metatileentities/steam/boiler/SteamBoiler.java | 3 --- .../common/metatileentities/steam/boiler/SteamCoalBoiler.java | 4 ---- .../common/metatileentities/steam/boiler/SteamLavaBoiler.java | 4 ---- .../metatileentities/steam/boiler/SteamSolarBoiler.java | 4 ---- 4 files changed, 15 deletions(-) diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java index b9d26868079..c49f4d68d8a 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java @@ -4,8 +4,6 @@ import gregtech.api.capability.impl.CommonFluidFilters; import gregtech.api.capability.impl.FilteredFluidHandler; import gregtech.api.capability.impl.FluidTankList; -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.ModularUI; import gregtech.api.gui.resources.TextureArea; import gregtech.api.items.itemhandlers.GTItemStackHandler; import gregtech.api.metatileentity.IDataInfoProvider; @@ -27,7 +25,6 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java index 3e3c3f2f5d4..44d9915c4cf 100755 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java @@ -1,8 +1,5 @@ package gregtech.common.metatileentities.steam.boiler; -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.ModularUI; -import gregtech.api.gui.widgets.ProgressWidget.MoveType; import gregtech.api.items.itemhandlers.GTItemStackHandler; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; @@ -11,7 +8,6 @@ import gregtech.api.recipes.category.ICategoryOverride; import gregtech.client.renderer.texture.Textures; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java index cdce2288d9c..ce9acbe74af 100755 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java @@ -5,9 +5,6 @@ import gregtech.api.capability.impl.CommonFluidFilters; import gregtech.api.capability.impl.FilteredFluidHandler; import gregtech.api.capability.impl.FluidTankList; -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.ModularUI; -import gregtech.api.gui.widgets.TankWidget; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.mui.GTGuiTextures; @@ -17,7 +14,6 @@ import gregtech.common.ConfigHolder; import gregtech.common.mui.widget.GTFluidSlot; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java index dc1e15dd4f2..ecbc3d8b1e6 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java @@ -1,15 +1,11 @@ package gregtech.common.metatileentities.steam.boiler; -import gregtech.api.gui.GuiTextures; -import gregtech.api.gui.ModularUI; -import gregtech.api.gui.widgets.ProgressWidget.MoveType; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.mui.GTGuiTextures; import gregtech.api.util.GTUtility; import gregtech.client.renderer.texture.Textures; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; From 79891d82b5ea62f56840570927cfd64f088d7f3e Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sat, 16 Aug 2025 22:05:10 -0700 Subject: [PATCH 39/55] initial rework of `addInventorySlotGroup()` for mui2 --- .../gregtech/api/recipes/ui/RecipeMapUI.java | 125 +++++++++--------- 1 file changed, 64 insertions(+), 61 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 831628ce172..1e379c05f83 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -23,6 +23,7 @@ import com.cleanroommc.modularui.widget.sizer.Area; import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.ProgressWidget; +import com.cleanroommc.modularui.widgets.layout.Grid; import com.cleanroommc.modularui.widgets.slot.SlotGroup; import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; import it.unimi.dsi.fastutil.bytes.Byte2ObjectOpenHashMap; @@ -549,70 +550,72 @@ public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandler protected void addInventorySlotGroup(@NotNull ParentWidget group, @NotNull IItemHandlerModifiable itemHandler, @NotNull FluidTankList fluidHandler, boolean isOutputs, int yOffset) { - int itemInputsCount = itemHandler.getSlots(); - int fluidInputsCount = fluidHandler.getTanks(); - boolean invertFluids = false; - if (itemInputsCount == 0) { - int tmp = itemInputsCount; - itemInputsCount = fluidInputsCount; - fluidInputsCount = tmp; - invertFluids = true; + final int itemInputsCount = itemHandler.getSlots(); + boolean onlyFluids = itemInputsCount == 0; + final int fluidInputsCount = fluidHandler.getTanks(); + if (fluidInputsCount == 0 && onlyFluids) + return; // nothing to do here + + int[] inputSlotGrid = determineSlotsGrid(onlyFluids ? fluidInputsCount : itemInputsCount); + int slotsToLeft = inputSlotGrid[0]; + int slotsToDown = inputSlotGrid[1]; + + int startX = isOutputs ? 106 : 70 - slotsToLeft * 18; + int startY = 33 - (int) (slotsToDown / 2.0 * 18) + yOffset; + + // note: is 'wasGroup' for the electrolyzer/centrifuge? + // it's the only thing I can think of that has 12 of item and fluid slots + boolean wasGroup = itemInputsCount + fluidInputsCount == 12; + if (wasGroup || itemInputsCount >= 6 && fluidInputsCount >= 2 && !isOutputs) { + startY -= 9; } - int[] inputSlotGrid = determineSlotsGrid(itemInputsCount); - int itemSlotsToLeft = inputSlotGrid[0]; - int itemSlotsToDown = inputSlotGrid[1]; - int startInputsX = isOutputs ? 106 : 70 - itemSlotsToLeft * 18; - int startInputsY = 33 - (int) (itemSlotsToDown / 2.0 * 18) + yOffset; - boolean wasGroup = itemHandler.getSlots() + fluidHandler.getTanks() == 12; - if (wasGroup) startInputsY -= 9; - else if (itemHandler.getSlots() >= 6 && fluidHandler.getTanks() >= 2 && !isOutputs) startInputsY -= 9; - SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", itemSlotsToLeft, 1, !isOutputs); - - for (int i = 0; i < itemSlotsToDown; i++) { - for (int j = 0; j < itemSlotsToLeft; j++) { - int slotIndex = i * itemSlotsToLeft + j; - if (slotIndex >= itemInputsCount) break; - int x = startInputsX + 18 * j; - int y = startInputsY + 18 * i; - if (invertFluids) { - group.child(makeFluidSlot(slotIndex, fluidHandler, isOutputs) - .pos(x, y)); - } else { - group.child(makeItemSlot(slotGroup, slotIndex, itemHandler, isOutputs) - .pos(x, y)); - } - } - } - if (wasGroup) startInputsY += 2; - if (fluidInputsCount > 0 || invertFluids) { - if (itemSlotsToDown >= fluidInputsCount && itemSlotsToLeft < 3) { - int startSpecX = isOutputs ? startInputsX + itemSlotsToLeft * 18 : startInputsX - 18; - for (int i = 0; i < fluidInputsCount; i++) { - int y = startInputsY + 18 * i; - if (!invertFluids) { - group.child(makeFluidSlot(i, fluidHandler, isOutputs) - .pos(startSpecX, y)); - } else { - group.child(makeItemSlot(slotGroup, i, itemHandler, isOutputs) - .pos(startSpecX, y)); - } - } - } else { - int startSpecY = startInputsY + itemSlotsToDown * 18; - for (int i = 0; i < fluidInputsCount; i++) { - int x = isOutputs ? startInputsX + 18 * (i % 3) : - startInputsX + itemSlotsToLeft * 18 - 18 - 18 * (i % 3); - int y = startSpecY + (i / 3) * 18; - if (!invertFluids) { - group.child(makeFluidSlot(i, fluidHandler, isOutputs) - .pos(x, y)); - } else { - group.child(makeItemSlot(slotGroup, i, itemHandler, isOutputs) - .pos(x, y)); - } - } + SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", slotsToLeft, 1, !isOutputs); + group.child(new Grid() + .mapTo(slotsToLeft, onlyFluids ? fluidInputsCount : itemInputsCount, + i -> onlyFluids ? makeFluidSlot(i, fluidHandler, isOutputs) : + makeItemSlot(slotGroup, i, itemHandler, isOutputs)) + .pos(startX, startY) + .coverChildren()); + + // we only have fluid slots, so we're done here + if (onlyFluids) return; + + int oldDown = slotsToDown; + int oldLeft = slotsToLeft; + inputSlotGrid = determineSlotsGrid(fluidInputsCount); + slotsToLeft = inputSlotGrid[0]; + slotsToDown = inputSlotGrid[1]; + + // otherwise, now we add the fluid slots + if (wasGroup) startY += 2; // this is responsible for the spacing between the slots on the electrolyzer + + if (oldDown >= fluidInputsCount && oldLeft < 3) { + // we have enough room to place fluid slots to the left of the item slots + // import has fluid slots left of item slots + // export has fluid slots right of item slots + int startSpecX = isOutputs ? startX + oldLeft * 18 : startX - 18; + group.child(new Grid() + .mapTo(slotsToLeft, fluidInputsCount, i -> makeFluidSlot(i, fluidHandler, isOutputs)) + .pos(startSpecX, startY) + .coverChildren()); + } else { + // otherwise place them below the item slots + int startSpecY = startY + oldDown * 18; + int x = startX; + if (!isOutputs) { + if (oldLeft == 3) + // for assembler machine input fluid slot + x += (18 * oldLeft) - 18; + + if (fluidInputsCount > oldLeft) + // to move chem reactor fluid input to the left + x -= 18; } + group.child(new Grid() // hardcode 3 for now + .mapTo(slotsToLeft, fluidInputsCount, i -> makeFluidSlot(i, fluidHandler, isOutputs)) + .pos(x, startSpecY) + .coverChildren()); } } From ef0a7b85d860af005a9cf3a75248581acb323b19 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 17 Aug 2025 23:42:39 -0700 Subject: [PATCH 40/55] more work on the rewrite add debug names clarify some variable names calculate the grid size for both items and fluids --- .../gregtech/api/recipes/ui/RecipeMapUI.java | 97 ++++++++++++------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 1e379c05f83..4e01b617979 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -140,6 +140,23 @@ public static byte computeOverlayKey(boolean isOutput, boolean isFluid, boolean return new int[] { itemSlotsToLeft, itemSlotsToDown }; } + /** + * Determines the slot grid sizes for the item and fluid counts + * + * @param itemInputsCount the amount of item slots + * @param fluidInputsCount the amount of fluid tanks + * @return [item grid width, item grid height, fluid grid width, fluid grid height] + */ + @Contract("_, _ -> new") + public static int @NotNull [] determineSlotsGrid(int itemInputsCount, int fluidInputsCount) { + int[] arr = determineSlotsGrid(itemInputsCount); + int[] sizes = { arr[0], arr[1], 0, 0 }; + arr = determineSlotsGrid(fluidInputsCount); + sizes[2] = arr[0]; + sizes[3] = arr[1]; + return sizes; + } + /* *********************** MUI 1 *********************** */ /** @@ -528,11 +545,16 @@ public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandler FluidTankList exportFluids, int yOffset, PanelSyncManager syncManager) { DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier); - ParentWidget group = new ParentWidget<>().size(176, 166 + yOffset); + ParentWidget group = new ParentWidget<>() + .debugName("recipemapui.parent") + .size(176, 166 + yOffset); + group.child(new RecipeProgressWidget() .recipeMap(recipeMap) + .debugName("recipe.progress") .size(20) - .alignX(0.5f).top(23 + yOffset) + .alignX(0.5f) + .top(23 + yOffset) .value(progressValue) .texture(progressTexture, 20) .direction(progressDirection)); @@ -556,12 +578,15 @@ protected void addInventorySlotGroup(@NotNull ParentWidget group, if (fluidInputsCount == 0 && onlyFluids) return; // nothing to do here - int[] inputSlotGrid = determineSlotsGrid(onlyFluids ? fluidInputsCount : itemInputsCount); - int slotsToLeft = inputSlotGrid[0]; - int slotsToDown = inputSlotGrid[1]; + int[] slotGridSizes = determineSlotsGrid(itemInputsCount, fluidInputsCount); + int itemGridWidth = slotGridSizes[onlyFluids ? 2 : 0]; + int itemGridHeight = slotGridSizes[onlyFluids ? 3 : 1]; + + int fluidGridWidth = slotGridSizes[2]; + int fluidGridHeight = slotGridSizes[3]; - int startX = isOutputs ? 106 : 70 - slotsToLeft * 18; - int startY = 33 - (int) (slotsToDown / 2.0 * 18) + yOffset; + int startX = isOutputs ? 106 : 70 - itemGridWidth * 18; + int startY = 33 - (int) (itemGridHeight / 2.0 * 18) + yOffset; // note: is 'wasGroup' for the electrolyzer/centrifuge? // it's the only thing I can think of that has 12 of item and fluid slots @@ -570,52 +595,58 @@ protected void addInventorySlotGroup(@NotNull ParentWidget group, startY -= 9; } - SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", slotsToLeft, 1, !isOutputs); - group.child(new Grid() - .mapTo(slotsToLeft, onlyFluids ? fluidInputsCount : itemInputsCount, - i -> onlyFluids ? makeFluidSlot(i, fluidHandler, isOutputs) : - makeItemSlot(slotGroup, i, itemHandler, isOutputs)) + var itemGrid = new Grid() + .debugName(String.format("%s.%s.grid", + onlyFluids ? "fluid" : "item", + isOutputs ? "output" : "input")) .pos(startX, startY) - .coverChildren()); + .width(itemGridWidth * 18) + .height(itemGridHeight * 18); + + if (onlyFluids) { + itemGrid.mapTo(fluidGridWidth, fluidInputsCount, i -> makeFluidSlot(i, fluidHandler, isOutputs)); + } else { + SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", itemGridWidth, 1, + !isOutputs); + itemGrid.mapTo(itemGridWidth, itemInputsCount, i -> makeItemSlot(slotGroup, i, itemHandler, isOutputs)); + } + + group.child(itemGrid); // we only have fluid slots, so we're done here if (onlyFluids) return; - int oldDown = slotsToDown; - int oldLeft = slotsToLeft; - inputSlotGrid = determineSlotsGrid(fluidInputsCount); - slotsToLeft = inputSlotGrid[0]; - slotsToDown = inputSlotGrid[1]; - // otherwise, now we add the fluid slots if (wasGroup) startY += 2; // this is responsible for the spacing between the slots on the electrolyzer - if (oldDown >= fluidInputsCount && oldLeft < 3) { + Grid fluidGrid = new Grid() + .debugName(String.format("fluid.%s.grid", isOutputs ? "output" : "inputs")) + .size(fluidGridWidth * 18, fluidGridHeight * 18); + + if (itemGridHeight >= fluidInputsCount && itemGridWidth < 3) { // we have enough room to place fluid slots to the left of the item slots // import has fluid slots left of item slots // export has fluid slots right of item slots - int startSpecX = isOutputs ? startX + oldLeft * 18 : startX - 18; - group.child(new Grid() - .mapTo(slotsToLeft, fluidInputsCount, i -> makeFluidSlot(i, fluidHandler, isOutputs)) - .pos(startSpecX, startY) - .coverChildren()); + int startSpecX = isOutputs ? startX + itemGridWidth * 18 : startX - 18; + group.child(fluidGrid + .mapTo(fluidGridWidth, fluidInputsCount, i -> makeFluidSlot(i, fluidHandler, isOutputs)) + .pos(startSpecX, startY)); } else { // otherwise place them below the item slots - int startSpecY = startY + oldDown * 18; + int startSpecY = startY + itemGridHeight * 18; int x = startX; if (!isOutputs) { - if (oldLeft == 3) + if (itemGridWidth == 3) // for assembler machine input fluid slot - x += (18 * oldLeft) - 18; + x += (18 * itemGridWidth) - 18; - if (fluidInputsCount > oldLeft) + if (fluidInputsCount > itemGridWidth) // to move chem reactor fluid input to the left x -= 18; } - group.child(new Grid() // hardcode 3 for now - .mapTo(slotsToLeft, fluidInputsCount, i -> makeFluidSlot(i, fluidHandler, isOutputs)) - .pos(x, startSpecY) - .coverChildren()); + group.child(fluidGrid + .mapTo(fluidGridWidth, fluidInputsCount, i -> makeFluidSlot(i, fluidHandler, isOutputs)) + .pos(x, startSpecY)); } } From 7595eb399f758cdf1f7db81b61dce1e9d4093eb1 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sat, 20 Sep 2025 15:26:16 -0700 Subject: [PATCH 41/55] use modular panel instead of redundant parent widget use qualified references for old gui class references --- .../SimpleGeneratorMetaTileEntity.java | 6 +-- .../SimpleMachineMetaTileEntity.java | 43 +++++++++---------- .../metatileentity/SteamMetaTileEntity.java | 7 +-- .../gregtech/api/recipes/ui/RecipeMapUI.java | 18 ++++---- 4 files changed, 34 insertions(+), 40 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java index 5d91c8feb4a..12954f569bd 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java @@ -152,10 +152,8 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) } ModularPanel panel = GTGuis.createPanel(this, 176, 166 + yOffset); - Widget widget = workableRecipeMap.getRecipeMapUI().buildWidget(workable::getProgressPercent, importItems, - exportItems, importFluids, exportFluids, yOffset, guiSyncManager); - - panel.child(widget) + workableRecipeMap.getRecipeMapUI().constructPanel(panel, workable::getProgressPercent, + importItems, exportItems, importFluids, exportFluids, yOffset, guiSyncManager) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) .bindPlayerInventory(); diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index eed434e1ea2..05d0e069ba9 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -14,15 +14,11 @@ import gregtech.api.gui.GuiTextures; import gregtech.api.gui.ModularUI; import gregtech.api.gui.resources.TextureArea; -import gregtech.api.gui.widgets.GhostCircuitSlotWidget; -import gregtech.api.gui.widgets.ImageWidget; -import gregtech.api.gui.widgets.LabelWidget; -import gregtech.api.gui.widgets.SlotWidget; -import gregtech.api.gui.widgets.ToggleButtonWidget; import gregtech.api.items.itemhandlers.GTItemStackHandler; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.mui.GTGuiTextures; import gregtech.api.mui.GTGuis; +import gregtech.api.mui.widget.GhostCircuitSlotWidget; import gregtech.api.recipes.RecipeMap; import gregtech.api.util.GTTransferUtils; import gregtech.api.util.GTUtility; @@ -506,13 +502,12 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) } ModularPanel panel = GTGuis.createPanel(this, 176, 166 + yOffset); - Widget widget = workableRecipeMap.getRecipeMapUI().buildWidget(workable::getProgressPercent, importItems, - exportItems, importFluids, exportFluids, yOffset, guiSyncManager); BooleanSyncValue hasEnergy = new BooleanSyncValue(workable::isHasNotEnoughEnergy); guiSyncManager.syncValue("has_energy", hasEnergy); - panel.child(widget) + workableRecipeMap.getRecipeMapUI().constructPanel(panel, workable::getProgressPercent, + importItems, exportItems, importFluids, exportFluids, yOffset, guiSyncManager) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) .child(new ItemSlot() .slot(SyncHandlers.itemSlot(chargerInventory, 0)) @@ -558,7 +553,7 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) .background(GTGuiTextures.getLogo(getUITheme()))); if (hasGhostCircuitInventory() && circuitInventory != null) { - panel.child(new gregtech.api.mui.widget.GhostCircuitSlotWidget() + panel.child(new GhostCircuitSlotWidget() .pos(124, 62 + yOffset) .slot(SyncHandlers.itemSlot(circuitInventory, 0)) .background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY)); @@ -584,38 +579,42 @@ protected ModularUI.Builder createGuiTemplate(EntityPlayer player) { ModularUI.Builder builder = workableRecipeMap.getRecipeMapUI() .createUITemplate(workable::getProgressPercent, importItems, exportItems, importFluids, exportFluids, yOffset) - .widget(new LabelWidget(5, 5, getMetaFullName())) - .widget(new SlotWidget(chargerInventory, 0, 79, 62 + yOffset, true, true, false) - .setBackgroundTexture(GuiTextures.SLOT, GuiTextures.CHARGER_OVERLAY) - .setTooltipText("gregtech.gui.charger_slot.tooltip", GTValues.VNF[getTier()], - GTValues.VNF[getTier()])) - .widget(new ImageWidget(79, 42 + yOffset, 18, 18, GuiTextures.INDICATOR_NO_ENERGY).setIgnoreColor(true) - .setPredicate(workable::isHasNotEnoughEnergy)) + .widget(new gregtech.api.gui.widgets.LabelWidget(5, 5, getMetaFullName())) + .widget(new gregtech.api.gui.widgets.SlotWidget(chargerInventory, 0, 79, 62 + yOffset, true, true, + false) + .setBackgroundTexture(GuiTextures.SLOT, GuiTextures.CHARGER_OVERLAY) + .setTooltipText("gregtech.gui.charger_slot.tooltip", GTValues.VNF[getTier()], + GTValues.VNF[getTier()])) + .widget(new gregtech.api.gui.widgets.ImageWidget(79, 42 + yOffset, 18, 18, + GuiTextures.INDICATOR_NO_ENERGY).setIgnoreColor(true) + .setPredicate(workable::isHasNotEnoughEnergy)) .bindPlayerInventory(player.inventory, GuiTextures.SLOT, yOffset); int leftButtonStartX = 7; if (exportItems.getSlots() > 0) { - builder.widget(new ToggleButtonWidget(leftButtonStartX, 62 + yOffset, 18, 18, + builder.widget(new gregtech.api.gui.widgets.ToggleButtonWidget(leftButtonStartX, 62 + yOffset, 18, 18, GuiTextures.BUTTON_ITEM_OUTPUT, this::isAutoOutputItems, this::setAutoOutputItems) .setTooltipText("gregtech.gui.item_auto_output.tooltip") .shouldUseBaseBackground()); leftButtonStartX += 18; } if (exportFluids.getTanks() > 0) { - builder.widget(new ToggleButtonWidget(leftButtonStartX, 62 + yOffset, 18, 18, + builder.widget(new gregtech.api.gui.widgets.ToggleButtonWidget(leftButtonStartX, 62 + yOffset, 18, 18, GuiTextures.BUTTON_FLUID_OUTPUT, this::isAutoOutputFluids, this::setAutoOutputFluids) .setTooltipText("gregtech.gui.fluid_auto_output.tooltip") .shouldUseBaseBackground()); } if (exportItems.getSlots() + exportFluids.getTanks() <= 9) { - ImageWidget logo = new ImageWidget(152, 63 + yOffset, 17, 17, + gregtech.api.gui.widgets.ImageWidget logo = new gregtech.api.gui.widgets.ImageWidget(152, 63 + yOffset, 17, + 17, GTValues.XMAS.get() ? getXmasLogo() : getLogo()).setIgnoreColor(true); if (this.circuitInventory != null) { - SlotWidget circuitSlot = new GhostCircuitSlotWidget(circuitInventory, 0, 124, 62 + yOffset) - .setBackgroundTexture(GuiTextures.SLOT, getCircuitSlotOverlay()); + gregtech.api.gui.widgets.SlotWidget circuitSlot = new gregtech.api.gui.widgets.GhostCircuitSlotWidget( + circuitInventory, 0, 124, 62 + yOffset) + .setBackgroundTexture(GuiTextures.SLOT, getCircuitSlotOverlay()); builder.widget(circuitSlot.setConsumer(this::getCircuitSlotTooltip)).widget(logo); } } @@ -641,7 +640,7 @@ protected TextureArea getCircuitSlotOverlay() { } // Method provided to override - protected void getCircuitSlotTooltip(SlotWidget widget) { + protected void getCircuitSlotTooltip(gregtech.api.gui.widgets.SlotWidget widget) { String configString; if (circuitInventory == null || circuitInventory.getCircuitValue() == GhostCircuitItemStackHandler.NO_CONFIG) { configString = new TextComponentTranslation("gregtech.gui.configurator_slot.no_value").getFormattedText(); diff --git a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java index a0ef028230a..33a9935d49d 100644 --- a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java @@ -40,7 +40,6 @@ import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.value.sync.PanelSyncManager; -import com.cleanroommc.modularui.widget.Widget; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; @@ -148,10 +147,8 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) ModularPanel modularPanel = GTGuis.defaultPanel(this); - Widget widget = map.getRecipeMapUI().buildWidget(workableHandler::getProgressPercent, importItems, - exportItems, EMPTY, exportFluids, 0, guiSyncManager); - - modularPanel.child(widget) + map.getRecipeMapUI().constructPanel(modularPanel, workableHandler::getProgressPercent, + importItems, exportItems, EMPTY, exportFluids, 0, guiSyncManager) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) .bindPlayerInventory(); diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 4e01b617979..faa2ada6357 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -16,6 +16,7 @@ import com.cleanroommc.modularui.api.drawable.IDrawable; import com.cleanroommc.modularui.drawable.UITexture; +import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.value.sync.DoubleSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; @@ -540,16 +541,15 @@ public void setSlotOverlay(byte key, @NotNull TextureArea texture) { /* *********************** MUI 2 *********************** */ - public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandlerModifiable importItems, + public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSupplier, + IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset, PanelSyncManager syncManager) { DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier); - ParentWidget group = new ParentWidget<>() - .debugName("recipemapui.parent") - .size(176, 166 + yOffset); + panel.debugName("recipemapui.parent"); - group.child(new RecipeProgressWidget() + panel.child(new RecipeProgressWidget() .recipeMap(recipeMap) .debugName("recipe.progress") .size(20) @@ -558,15 +558,15 @@ public ParentWidget buildWidget(DoubleSupplier progressSupplier, IItemHandler .value(progressValue) .texture(progressTexture, 20) .direction(progressDirection)); - addInventorySlotGroup(group, importItems, importFluids, false, yOffset); - addInventorySlotGroup(group, exportItems, exportFluids, true, yOffset); + addInventorySlotGroup(panel, importItems, importFluids, false, yOffset); + addInventorySlotGroup(panel, exportItems, exportFluids, true, yOffset); if (specialDrawableTexture != null) { - group.child(specialDrawableTexture.asWidget() + panel.child(specialDrawableTexture.asWidget() .debugName("special_texture") .pos(specialTexturePosition.x(), specialTexturePosition.y()) .size(specialTexturePosition.w(), specialTexturePosition.h())); } - return group; + return panel; } protected void addInventorySlotGroup(@NotNull ParentWidget group, From e8bc2c963472b7c6c19665606776008abd5a556e Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Fri, 26 Sep 2025 18:47:05 -0700 Subject: [PATCH 42/55] rework mostly done --- .../SimpleMachineMetaTileEntity.java | 48 +++-- .../gregtech/api/recipes/ui/RecipeMapUI.java | 179 +++++++++++++++++- 2 files changed, 204 insertions(+), 23 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 05d0e069ba9..af24409f1af 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -1,5 +1,9 @@ package gregtech.api.metatileentity; +import com.cleanroommc.modularui.widgets.SlotGroupWidget; + +import com.cleanroommc.modularui.widgets.layout.Flow; + import gregtech.api.GTValues; import gregtech.api.capability.GregtechTileCapabilities; import gregtech.api.capability.IActiveOutputSide; @@ -501,7 +505,12 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) yOffset = FONT_HEIGHT; } - ModularPanel panel = GTGuis.createPanel(this, 176, 166 + yOffset); + ModularPanel panel = GTGuis.createPanel(this, 176 + 20, 166 + yOffset); + Flow col = Flow.column() + .debugName("special.buttons") + .right(7).bottom(7) + .height(18 * 4 + 4) + .width(18); BooleanSyncValue hasEnergy = new BooleanSyncValue(workable::isHasNotEnoughEnergy); guiSyncManager.syncValue("has_energy", hasEnergy); @@ -509,25 +518,28 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) workableRecipeMap.getRecipeMapUI().constructPanel(panel, workable::getProgressPercent, importItems, exportItems, importFluids, exportFluids, yOffset, guiSyncManager) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(new ItemSlot() - .slot(SyncHandlers.itemSlot(chargerInventory, 0)) - .pos(79, 62 + yOffset) - .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY) - .addTooltipLine(IKey.lang("gregtech.gui.charger_slot.tooltip", - GTValues.VNF[getTier()], GTValues.VNF[getTier()]))) .child(new Widget<>() + .debugName("energy.indicator") .size(18, 18) .pos(79, 42 + yOffset) .background(GTGuiTextures.INDICATOR_NO_ENERGY) .setEnabledIf($ -> hasEnergy.getBoolValue())) - .bindPlayerInventory(); + .child(col) + .child(SlotGroupWidget.playerInventory().left(7)); + + col.child(new ItemSlot() + .debugName("charger.slot") + .slot(SyncHandlers.itemSlot(chargerInventory, 0)) +// .pos(79, 62 + yOffset) + .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY) + .addTooltipLine(IKey.lang("gregtech.gui.charger_slot.tooltip", + GTValues.VNF[getTier()], GTValues.VNF[getTier()]))); int leftButtonStartX = 7; if (exportItems.getSlots() > 0) { - - panel.child(new ToggleButton() - .pos(leftButtonStartX, 62 + yOffset) + col.child(new ToggleButton() +// .pos(leftButtonStartX, 62 + yOffset) .overlay(GTGuiTextures.BUTTON_ITEM_OUTPUT) .value(new BooleanSyncValue(() -> autoOutputItems, val -> autoOutputItems = val)) .addTooltip(true, IKey.lang("gregtech.gui.item_auto_output.tooltip.enabled")) @@ -538,8 +550,8 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) if (exportFluids.getTanks() > 0) { - panel.child(new ToggleButton() - .pos(leftButtonStartX, 62 + yOffset) + col.child(new ToggleButton() +// .pos(leftButtonStartX, 62 + yOffset) .overlay(GTGuiTextures.BUTTON_FLUID_OUTPUT) .value(new BooleanSyncValue(() -> autoOutputFluids, val -> autoOutputFluids = val)) .addTooltip(true, IKey.lang("gregtech.gui.fluid_auto_output.tooltip.enabled")) @@ -547,14 +559,16 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) } if (exportItems.getSlots() + exportFluids.getTanks() <= 9) { - panel.child(new Widget<>() + col.child(new Widget<>() .size(17) - .pos(152, 63 + yOffset) + .marginTop(1).marginRight(1) + .bottom(0) +// .pos(152, 63 + yOffset) .background(GTGuiTextures.getLogo(getUITheme()))); if (hasGhostCircuitInventory() && circuitInventory != null) { - panel.child(new GhostCircuitSlotWidget() - .pos(124, 62 + yOffset) + col.child(new GhostCircuitSlotWidget() +// .pos(124, 62 + yOffset) .slot(SyncHandlers.itemSlot(circuitInventory, 0)) .background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY)); } diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index faa2ada6357..06550442e94 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -15,15 +15,19 @@ import net.minecraftforge.items.IItemHandlerModifiable; import com.cleanroommc.modularui.api.drawable.IDrawable; +import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.drawable.UITexture; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.value.sync.DoubleSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widget.ParentWidget; +import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widget.sizer.Area; import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.ProgressWidget; +import com.cleanroommc.modularui.widgets.layout.Flow; import com.cleanroommc.modularui.widgets.layout.Grid; import com.cleanroommc.modularui.widgets.slot.SlotGroup; import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; @@ -35,6 +39,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.List; import java.util.function.Consumer; import java.util.function.DoubleSupplier; @@ -547,19 +553,30 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu FluidTankList exportFluids, int yOffset, PanelSyncManager syncManager) { DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier); - panel.debugName("recipemapui.parent"); + Flow row = Flow.row() + .height(3 * 18 + 9) + .debugName("recipemapui.parent") + .crossAxisAlignment(Alignment.CrossAxis.CENTER) + .top(23 - 7); - panel.child(new RecipeProgressWidget() + int m = calculateCenter(importItems.getSlots(), importFluids.getTanks(), 176 + 20); + + row.child(makeInventorySlotGroup(importItems, importFluids, false) + .marginLeft(m - 4)); + row.child(new RecipeProgressWidget() .recipeMap(recipeMap) .debugName("recipe.progress") .size(20) - .alignX(0.5f) - .top(23 + yOffset) + .margin(4, 0) + // .alignX(0.5f) + // .top(23 + yOffset) .value(progressValue) .texture(progressTexture, 20) .direction(progressDirection)); - addInventorySlotGroup(panel, importItems, importFluids, false, yOffset); - addInventorySlotGroup(panel, exportItems, exportFluids, true, yOffset); + row.child(makeInventorySlotGroup(exportItems, exportFluids, true)); + // addInventorySlotGroup(panel, importItems, importFluids, false, yOffset); + // addInventorySlotGroup(panel, exportItems, exportFluids, true, yOffset); + panel.child(row); if (specialDrawableTexture != null) { panel.child(specialDrawableTexture.asWidget() .debugName("special_texture") @@ -569,6 +586,154 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu return panel; } + private int calculateCenter(int inputItems, int inputFluids, int panelSize) { + int[] ints = determineSlotsGrid(inputItems, inputFluids); + int leftSize = ints[1] >= inputFluids && ints[0] < 3 ? + (ints[0] + ints[2]) * 18 : + Math.max(ints[0] * 18, ints[2] * 18); + int p = panelSize / 2; + p -= 10; + p -= leftSize; + return p; + } + + private Widget makeItemGroup(int width, IItemHandlerModifiable handler, boolean isOutputs) { + Flow col = Flow.column().mainAxisAlignment(Alignment.MainAxis.END) + .coverChildren().debugName("item.col"); + int c = handler.getSlots(); + int h = (int) Math.ceil((double) c / width); + SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", + width, 1, !isOutputs); + for (int i = 0; i < h; i++) { + Flow row = Flow.row().mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END) + .coverChildren().debugName("item.row." + i); + for (int j = 0; j < width; j++) { + row.child(makeItemSlot(slotGroup, (i * h) + j, handler, isOutputs)); + } + col.child(row); + } + return col; + } + + private Widget makeFluidGroup(int width, FluidTankList handler, boolean isOutputs) { + Flow col = Flow.column().mainAxisAlignment(Alignment.MainAxis.START) + .coverChildren().debugName("fluid.col"); + int c = handler.getTanks(); + int h = (int) Math.ceil((double) c / width); + for (int i = 0; i < h; i++) { + Flow row = Flow.row().mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END) + .coverChildren().debugName("fluid.row"); + for (int j = 0; j < width; j++) { + row.child(makeFluidSlot((i * h) + j, handler, isOutputs)); + } + col.child(row); + } + return col; + } + + protected Widget makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemHandler, + @NotNull FluidTankList fluidHandler, boolean isOutputs) { + final int itemInputsCount = itemHandler.getSlots(); + boolean onlyFluids = itemInputsCount == 0; + final int fluidInputsCount = fluidHandler.getTanks(); + if (fluidInputsCount == 0 && onlyFluids) + return null; // nothing to do here + + int[] slotGridSizes = determineSlotsGrid(itemInputsCount, fluidInputsCount); + int itemGridWidth = slotGridSizes[onlyFluids ? 2 : 0]; + int itemGridHeight = slotGridSizes[onlyFluids ? 3 : 1]; + + int fluidGridWidth = slotGridSizes[2]; + int fluidGridHeight = slotGridSizes[3]; + boolean singleRow = itemGridHeight >= fluidInputsCount && itemGridWidth < 3; + + Flow flow = (singleRow ? Flow.row() : Flow.column()).coverChildren() + .debugName(singleRow ? "parent.row" : "parent.col"); + flow.crossAxisAlignment(isOutputs ? Alignment.CrossAxis.START : Alignment.CrossAxis.END); + + if (!onlyFluids && fluidGridHeight > 1) { + // 1 should be 18, 2 should be 0, 3 should be -18, 4 should be -36 + // this is to make the first item row align with progress widget + flow.top((2 - itemGridHeight) * 18); + } + + if (itemInputsCount > 6) { + flow.top(0); + } + + if (onlyFluids) { + flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(fluidGridWidth, fluidHandler, isOutputs)); + } else { + flow.childIf(!singleRow || isOutputs, () -> makeItemGroup(itemGridWidth, itemHandler, isOutputs)); + flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(fluidGridWidth, fluidHandler, isOutputs)); + flow.childIf(singleRow && !isOutputs, () -> makeItemGroup(itemGridWidth, itemHandler, isOutputs)); + } + + if (true) { + return flow; + } + + Grid grid = new Grid() + .debugName(isOutputs ? "output.grid" : "input.grid"); + + SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", itemGridWidth, 1, + !isOutputs); + int tHeight = singleRow ? itemGridHeight : itemGridHeight + fluidGridHeight; + int tWidth = itemGridWidth + fluidGridWidth; + int total = tWidth * tHeight; + grid.size(tWidth * 18, tHeight * 18); + + List list = new ArrayList<>(); + int diff = (itemGridHeight * itemGridWidth) - itemInputsCount; + int fluidDiff = Math.max(tWidth - fluidInputsCount, 0); + int fluidIndex = 0, itemIndex = 0, emptyIndex = 0; + + for (int i = 0; i < total; i++) { + IWidget widget = IDrawable.EMPTY.asWidget().size(18) + .debugName("empty.slot." + emptyIndex++); + if (!isOutputs) { + if (singleRow) { + // fluid slot, then item slots + if (i == 0 && fluidIndex < fluidInputsCount) { + widget = makeFluidSlot(fluidIndex++, fluidHandler, false); + } else if (itemIndex < itemInputsCount) { + widget = makeItemSlot(slotGroup, itemIndex++, itemHandler, false); + } + } else { + if (i > diff && i < itemGridWidth * itemGridHeight) { + // top left should be empty + widget = makeItemSlot(slotGroup, itemIndex++, itemHandler, false); + } else if (i >= itemGridWidth * itemGridHeight && i < total - fluidDiff) { + // bottom left should be empty + widget = makeFluidSlot(fluidIndex++, fluidHandler, false); + } + } + } else { + if (singleRow) { + // item slots, then fluid slots + if (i == total - 1 && fluidIndex < fluidInputsCount) { + widget = makeFluidSlot(fluidIndex++, fluidHandler, false); + } else if (itemIndex < itemInputsCount) { + widget = makeItemSlot(slotGroup, itemIndex++, itemHandler, false); + } + } else { + if (i < (tWidth - diff) || i >= tWidth) { + // top right should be empty + widget = makeItemSlot(slotGroup, itemIndex++, itemHandler, false); + } else if (i >= itemGridWidth * itemGridHeight && i < total - fluidDiff) { + // bottom right should be empty + widget = makeFluidSlot(fluidIndex++, fluidHandler, false); + } + } + } + list.add(widget); + } + + grid.mapTo(Math.max(itemGridWidth, fluidGridWidth), list); + + return grid; + } + protected void addInventorySlotGroup(@NotNull ParentWidget group, @NotNull IItemHandlerModifiable itemHandler, @NotNull FluidTankList fluidHandler, boolean isOutputs, int yOffset) { @@ -653,6 +818,7 @@ protected void addInventorySlotGroup(@NotNull ParentWidget group, protected ItemSlot makeItemSlot(SlotGroup group, int slotIndex, IItemHandlerModifiable itemHandler, boolean isOutputs) { return new ItemSlot() + .debugName("item.slot." + slotIndex + ":" + group.getName()) .slot(SyncHandlers.itemSlot(itemHandler, slotIndex) .slotGroup(group) .accessibility(!isOutputs, true)) @@ -661,6 +827,7 @@ protected ItemSlot makeItemSlot(SlotGroup group, int slotIndex, IItemHandlerModi protected GTFluidSlot makeFluidSlot(int slotIndex, FluidTankList fluidHandler, boolean isOutputs) { return new GTFluidSlot() + .debugName("fluid.slot." + slotIndex) .syncHandler(GTFluidSlot.sync(fluidHandler.getTankAt(slotIndex)) .accessibility(true, !isOutputs) .drawAlwaysFull(true)) From 7a53dd923ac89c462390d4e315fe9184297653d4 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Fri, 26 Sep 2025 18:48:58 -0700 Subject: [PATCH 43/55] clean + spotless --- .../SimpleMachineMetaTileEntity.java | 19 ++++--------------- .../gregtech/api/recipes/ui/RecipeMapUI.java | 6 ++---- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index af24409f1af..543c2a7d609 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -1,9 +1,5 @@ package gregtech.api.metatileentity; -import com.cleanroommc.modularui.widgets.SlotGroupWidget; - -import com.cleanroommc.modularui.widgets.layout.Flow; - import gregtech.api.GTValues; import gregtech.api.capability.GregtechTileCapabilities; import gregtech.api.capability.IActiveOutputSide; @@ -64,7 +60,9 @@ import com.cleanroommc.modularui.value.sync.SyncHandlers; import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widgets.ItemSlot; +import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.ToggleButton; +import com.cleanroommc.modularui.widgets.layout.Flow; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -530,28 +528,20 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) col.child(new ItemSlot() .debugName("charger.slot") .slot(SyncHandlers.itemSlot(chargerInventory, 0)) -// .pos(79, 62 + yOffset) .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY) .addTooltipLine(IKey.lang("gregtech.gui.charger_slot.tooltip", GTValues.VNF[getTier()], GTValues.VNF[getTier()]))); - int leftButtonStartX = 7; - if (exportItems.getSlots() > 0) { col.child(new ToggleButton() -// .pos(leftButtonStartX, 62 + yOffset) .overlay(GTGuiTextures.BUTTON_ITEM_OUTPUT) .value(new BooleanSyncValue(() -> autoOutputItems, val -> autoOutputItems = val)) .addTooltip(true, IKey.lang("gregtech.gui.item_auto_output.tooltip.enabled")) .addTooltip(false, IKey.lang("gregtech.gui.item_auto_output.tooltip.disabled"))); - - leftButtonStartX += 18; } if (exportFluids.getTanks() > 0) { - col.child(new ToggleButton() -// .pos(leftButtonStartX, 62 + yOffset) .overlay(GTGuiTextures.BUTTON_FLUID_OUTPUT) .value(new BooleanSyncValue(() -> autoOutputFluids, val -> autoOutputFluids = val)) .addTooltip(true, IKey.lang("gregtech.gui.fluid_auto_output.tooltip.enabled")) @@ -561,14 +551,13 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) if (exportItems.getSlots() + exportFluids.getTanks() <= 9) { col.child(new Widget<>() .size(17) - .marginTop(1).marginRight(1) + .marginTop(1) + .marginRight(1) .bottom(0) -// .pos(152, 63 + yOffset) .background(GTGuiTextures.getLogo(getUITheme()))); if (hasGhostCircuitInventory() && circuitInventory != null) { col.child(new GhostCircuitSlotWidget() -// .pos(124, 62 + yOffset) .slot(SyncHandlers.itemSlot(circuitInventory, 0)) .background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY)); } diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 06550442e94..3de6070f755 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -559,6 +559,8 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu .crossAxisAlignment(Alignment.CrossAxis.CENTER) .top(23 - 7); + // this isn't great but it works for now + // panel size is hardcoded because you can't get the panel size from the panel int m = calculateCenter(importItems.getSlots(), importFluids.getTanks(), 176 + 20); row.child(makeInventorySlotGroup(importItems, importFluids, false) @@ -568,14 +570,10 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu .debugName("recipe.progress") .size(20) .margin(4, 0) - // .alignX(0.5f) - // .top(23 + yOffset) .value(progressValue) .texture(progressTexture, 20) .direction(progressDirection)); row.child(makeInventorySlotGroup(exportItems, exportFluids, true)); - // addInventorySlotGroup(panel, importItems, importFluids, false, yOffset); - // addInventorySlotGroup(panel, exportItems, exportFluids, true, yOffset); panel.child(row); if (specialDrawableTexture != null) { panel.child(specialDrawableTexture.asWidget() From 7651ce10b7a592e18c384144cc1d3968ae6b0a0b Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sat, 27 Sep 2025 17:40:43 -0700 Subject: [PATCH 44/55] cleanup pt 2 improve overlay map --- .../gregtech/api/recipes/ui/RecipeMapUI.java | 172 ++---------------- 1 file changed, 14 insertions(+), 158 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 3de6070f755..57a1cacfc58 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -12,35 +12,32 @@ import gregtech.api.recipes.RecipeMap; import gregtech.common.mui.widget.GTFluidSlot; +import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; + import net.minecraftforge.items.IItemHandlerModifiable; import com.cleanroommc.modularui.api.drawable.IDrawable; -import com.cleanroommc.modularui.api.widget.IWidget; import com.cleanroommc.modularui.drawable.UITexture; import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.value.sync.DoubleSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.value.sync.SyncHandlers; -import com.cleanroommc.modularui.widget.ParentWidget; import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widget.sizer.Area; import com.cleanroommc.modularui.widgets.ItemSlot; import com.cleanroommc.modularui.widgets.ProgressWidget; import com.cleanroommc.modularui.widgets.layout.Flow; -import com.cleanroommc.modularui.widgets.layout.Grid; import com.cleanroommc.modularui.widgets.slot.SlotGroup; import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; import it.unimi.dsi.fastutil.bytes.Byte2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; import java.util.function.Consumer; import java.util.function.DoubleSupplier; @@ -72,11 +69,7 @@ public class RecipeMapUI> { /* *********************** MUI 2 *********************** */ - // todo try to store this better - private final Int2ObjectMap itemInputOverlays = new Int2ObjectOpenHashMap<>(); - private final Int2ObjectMap itemOutputOverlays = new Int2ObjectOpenHashMap<>(); - private final Int2ObjectMap fluidInputOverlays = new Int2ObjectOpenHashMap<>(); - private final Int2ObjectMap fluidOutputOverlays = new Int2ObjectOpenHashMap<>(); + private final Byte2ObjectMap> overlays = new Byte2ObjectArrayMap<>(4); @ApiStatus.Experimental private boolean usesMui2 = false; @@ -667,150 +660,7 @@ protected Widget makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemH flow.childIf(singleRow && !isOutputs, () -> makeItemGroup(itemGridWidth, itemHandler, isOutputs)); } - if (true) { - return flow; - } - - Grid grid = new Grid() - .debugName(isOutputs ? "output.grid" : "input.grid"); - - SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", itemGridWidth, 1, - !isOutputs); - int tHeight = singleRow ? itemGridHeight : itemGridHeight + fluidGridHeight; - int tWidth = itemGridWidth + fluidGridWidth; - int total = tWidth * tHeight; - grid.size(tWidth * 18, tHeight * 18); - - List list = new ArrayList<>(); - int diff = (itemGridHeight * itemGridWidth) - itemInputsCount; - int fluidDiff = Math.max(tWidth - fluidInputsCount, 0); - int fluidIndex = 0, itemIndex = 0, emptyIndex = 0; - - for (int i = 0; i < total; i++) { - IWidget widget = IDrawable.EMPTY.asWidget().size(18) - .debugName("empty.slot." + emptyIndex++); - if (!isOutputs) { - if (singleRow) { - // fluid slot, then item slots - if (i == 0 && fluidIndex < fluidInputsCount) { - widget = makeFluidSlot(fluidIndex++, fluidHandler, false); - } else if (itemIndex < itemInputsCount) { - widget = makeItemSlot(slotGroup, itemIndex++, itemHandler, false); - } - } else { - if (i > diff && i < itemGridWidth * itemGridHeight) { - // top left should be empty - widget = makeItemSlot(slotGroup, itemIndex++, itemHandler, false); - } else if (i >= itemGridWidth * itemGridHeight && i < total - fluidDiff) { - // bottom left should be empty - widget = makeFluidSlot(fluidIndex++, fluidHandler, false); - } - } - } else { - if (singleRow) { - // item slots, then fluid slots - if (i == total - 1 && fluidIndex < fluidInputsCount) { - widget = makeFluidSlot(fluidIndex++, fluidHandler, false); - } else if (itemIndex < itemInputsCount) { - widget = makeItemSlot(slotGroup, itemIndex++, itemHandler, false); - } - } else { - if (i < (tWidth - diff) || i >= tWidth) { - // top right should be empty - widget = makeItemSlot(slotGroup, itemIndex++, itemHandler, false); - } else if (i >= itemGridWidth * itemGridHeight && i < total - fluidDiff) { - // bottom right should be empty - widget = makeFluidSlot(fluidIndex++, fluidHandler, false); - } - } - } - list.add(widget); - } - - grid.mapTo(Math.max(itemGridWidth, fluidGridWidth), list); - - return grid; - } - - protected void addInventorySlotGroup(@NotNull ParentWidget group, - @NotNull IItemHandlerModifiable itemHandler, - @NotNull FluidTankList fluidHandler, boolean isOutputs, int yOffset) { - final int itemInputsCount = itemHandler.getSlots(); - boolean onlyFluids = itemInputsCount == 0; - final int fluidInputsCount = fluidHandler.getTanks(); - if (fluidInputsCount == 0 && onlyFluids) - return; // nothing to do here - - int[] slotGridSizes = determineSlotsGrid(itemInputsCount, fluidInputsCount); - int itemGridWidth = slotGridSizes[onlyFluids ? 2 : 0]; - int itemGridHeight = slotGridSizes[onlyFluids ? 3 : 1]; - - int fluidGridWidth = slotGridSizes[2]; - int fluidGridHeight = slotGridSizes[3]; - - int startX = isOutputs ? 106 : 70 - itemGridWidth * 18; - int startY = 33 - (int) (itemGridHeight / 2.0 * 18) + yOffset; - - // note: is 'wasGroup' for the electrolyzer/centrifuge? - // it's the only thing I can think of that has 12 of item and fluid slots - boolean wasGroup = itemInputsCount + fluidInputsCount == 12; - if (wasGroup || itemInputsCount >= 6 && fluidInputsCount >= 2 && !isOutputs) { - startY -= 9; - } - - var itemGrid = new Grid() - .debugName(String.format("%s.%s.grid", - onlyFluids ? "fluid" : "item", - isOutputs ? "output" : "input")) - .pos(startX, startY) - .width(itemGridWidth * 18) - .height(itemGridHeight * 18); - - if (onlyFluids) { - itemGrid.mapTo(fluidGridWidth, fluidInputsCount, i -> makeFluidSlot(i, fluidHandler, isOutputs)); - } else { - SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", itemGridWidth, 1, - !isOutputs); - itemGrid.mapTo(itemGridWidth, itemInputsCount, i -> makeItemSlot(slotGroup, i, itemHandler, isOutputs)); - } - - group.child(itemGrid); - - // we only have fluid slots, so we're done here - if (onlyFluids) return; - - // otherwise, now we add the fluid slots - if (wasGroup) startY += 2; // this is responsible for the spacing between the slots on the electrolyzer - - Grid fluidGrid = new Grid() - .debugName(String.format("fluid.%s.grid", isOutputs ? "output" : "inputs")) - .size(fluidGridWidth * 18, fluidGridHeight * 18); - - if (itemGridHeight >= fluidInputsCount && itemGridWidth < 3) { - // we have enough room to place fluid slots to the left of the item slots - // import has fluid slots left of item slots - // export has fluid slots right of item slots - int startSpecX = isOutputs ? startX + itemGridWidth * 18 : startX - 18; - group.child(fluidGrid - .mapTo(fluidGridWidth, fluidInputsCount, i -> makeFluidSlot(i, fluidHandler, isOutputs)) - .pos(startSpecX, startY)); - } else { - // otherwise place them below the item slots - int startSpecY = startY + itemGridHeight * 18; - int x = startX; - if (!isOutputs) { - if (itemGridWidth == 3) - // for assembler machine input fluid slot - x += (18 * itemGridWidth) - 18; - - if (fluidInputsCount > itemGridWidth) - // to move chem reactor fluid input to the left - x -= 18; - } - group.child(fluidGrid - .mapTo(fluidGridWidth, fluidInputsCount, i -> makeFluidSlot(i, fluidHandler, isOutputs)) - .pos(x, startSpecY)); - } + return flow; } protected ItemSlot makeItemSlot(SlotGroup group, int slotIndex, IItemHandlerModifiable itemHandler, @@ -835,7 +685,7 @@ protected GTFluidSlot makeFluidSlot(int slotIndex, FluidTankList fluidHandler, b @ApiStatus.Experimental protected IDrawable getDrawableOverlaysForSlot(boolean isOutput, boolean isFluid, int index) { UITexture base = isFluid ? GTGuiTextures.FLUID_SLOT : GTGuiTextures.SLOT; - var overlays = getOverlayMap(isOutput, isFluid); + Int2ObjectMap overlays = getOverlayMap(isOutput, isFluid); if (overlays.containsKey(index)) { return IDrawable.of(base, overlays.get(index)); } @@ -843,8 +693,14 @@ protected IDrawable getDrawableOverlaysForSlot(boolean isOutput, boolean isFluid } protected Int2ObjectMap getOverlayMap(boolean isOutput, boolean isFluid) { - if (isOutput) return isFluid ? fluidOutputOverlays : itemOutputOverlays; - else return isFluid ? fluidInputOverlays : itemInputOverlays; + return this.overlays.computeIfAbsent(computeKey(isOutput, isFluid), k -> new Int2ObjectArrayMap<>()); + } + + protected static byte computeKey(boolean isOutput, boolean isFluid) { + byte k = 0b00; + if (isOutput) k |= 0b10; + if (isFluid) k |= 0b01; + return k; } /** Marked experimental as this method will be removed when all GTCEu UIs are ported to MUI2. */ From 0639de4db28e2d8e80b24df2608180929848743e Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sat, 27 Sep 2025 20:40:24 -0700 Subject: [PATCH 45/55] fix no energy indicator fix generator ui --- .../SimpleMachineMetaTileEntity.java | 8 +++--- .../gregtech/api/recipes/ui/RecipeMapUI.java | 25 ++++++++++++------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 543c2a7d609..35ac0d4dcdc 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -516,11 +516,11 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) workableRecipeMap.getRecipeMapUI().constructPanel(panel, workable::getProgressPercent, importItems, exportItems, importFluids, exportFluids, yOffset, guiSyncManager) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) - .child(new Widget<>() + .child(GTGuiTextures.INDICATOR_NO_ENERGY.asWidget() .debugName("energy.indicator") - .size(18, 18) - .pos(79, 42 + yOffset) - .background(GTGuiTextures.INDICATOR_NO_ENERGY) + .size(18) + .alignX(0.5f) + .top(42 + yOffset + 18) .setEnabledIf($ -> hasEnergy.getBoolValue())) .child(col) .child(SlotGroupWidget.playerInventory().left(7)); diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 57a1cacfc58..f666b24ec3e 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -12,9 +12,6 @@ import gregtech.api.recipes.RecipeMap; import gregtech.common.mui.widget.GTFluidSlot; -import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; - import net.minecraftforge.items.IItemHandlerModifiable; import com.cleanroommc.modularui.api.drawable.IDrawable; @@ -30,8 +27,10 @@ import com.cleanroommc.modularui.widgets.ProgressWidget; import com.cleanroommc.modularui.widgets.layout.Flow; import com.cleanroommc.modularui.widgets.slot.SlotGroup; +import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap; import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap; import it.unimi.dsi.fastutil.bytes.Byte2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; @@ -548,7 +547,7 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu Flow row = Flow.row() .height(3 * 18 + 9) - .debugName("recipemapui.parent") + .debugName("row:recipemapui.parent") .crossAxisAlignment(Alignment.CrossAxis.CENTER) .top(23 - 7); @@ -556,8 +555,10 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu // panel size is hardcoded because you can't get the panel size from the panel int m = calculateCenter(importItems.getSlots(), importFluids.getTanks(), 176 + 20); - row.child(makeInventorySlotGroup(importItems, importFluids, false) - .marginLeft(m - 4)); + if (importItems.getSlots() > 0 || importFluids.getTanks() > 0) { + row.child(makeInventorySlotGroup(importItems, importFluids, false) + .marginLeft(m - 4)); + } row.child(new RecipeProgressWidget() .recipeMap(recipeMap) .debugName("recipe.progress") @@ -566,11 +567,14 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu .value(progressValue) .texture(progressTexture, 20) .direction(progressDirection)); - row.child(makeInventorySlotGroup(exportItems, exportFluids, true)); + if (exportItems.getSlots() > 0 || exportFluids.getTanks() > 0) { + row.child(makeInventorySlotGroup(exportItems, exportFluids, true)); + } panel.child(row); if (specialDrawableTexture != null) { panel.child(specialDrawableTexture.asWidget() .debugName("special_texture") + // todo fix these hard coded values .pos(specialTexturePosition.x(), specialTexturePosition.y()) .size(specialTexturePosition.w(), specialTexturePosition.h())); } @@ -622,13 +626,16 @@ private Widget makeFluidGroup(int width, FluidTankList handler, boolean isOut return col; } + @NotNull protected Widget makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemHandler, @NotNull FluidTankList fluidHandler, boolean isOutputs) { final int itemInputsCount = itemHandler.getSlots(); boolean onlyFluids = itemInputsCount == 0; final int fluidInputsCount = fluidHandler.getTanks(); - if (fluidInputsCount == 0 && onlyFluids) - return null; // nothing to do here + if (fluidInputsCount == 0 && onlyFluids) { + // nothing to do here + throw new IllegalArgumentException("item and fluid handlers are empty!"); + } int[] slotGridSizes = determineSlotsGrid(itemInputsCount, fluidInputsCount); int itemGridWidth = slotGridSizes[onlyFluids ? 2 : 0]; From caae70e1b32c1e0343c8dec67488f930df6f7e7d Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 28 Sep 2025 13:45:33 -0700 Subject: [PATCH 46/55] replace special texture with a widget consumer --- .../java/gregtech/api/recipes/RecipeMaps.java | 8 +++-- .../gregtech/api/recipes/ui/RecipeMapUI.java | 29 ++++++++----------- .../api/recipes/ui/RecipeMapUIBuilder.java | 17 +++++------ 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index bc47899d6b4..0ae8d34adcf 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -35,6 +35,7 @@ import net.minecraft.init.SoundEvents; import com.cleanroommc.modularui.api.drawable.IDrawable; +import com.cleanroommc.modularui.utils.Alignment; import com.cleanroommc.modularui.widgets.ProgressWidget.Direction; import crafttweaker.annotations.ZenRegister; import stanhebben.zenscript.annotations.ZenClass; @@ -901,7 +902,8 @@ public final class RecipeMaps { .itemOutputs(1) .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.HAMMER_OVERLAY, false) - .specialTexture(GTGuiTextures.PROGRESS_BAR_HAMMER_BASE, 78, 42, 20, 6) + .specialTexture(widget -> widget.overlay(GTGuiTextures.PROGRESS_BAR_HAMMER_BASE.asIcon() + .size(20, 6))) .progressBar(GTGuiTextures.PROGRESS_BAR_HAMMER, Direction.DOWN)) .sound(GTSoundEvents.FORGE_HAMMER) .build(); @@ -1135,7 +1137,9 @@ public final class RecipeMaps { .itemSlotOverlay(GTGuiTextures.PIPE_OVERLAY_1, false) .itemSlotOverlay(GTGuiTextures.PIPE_OVERLAY_2, true, false) .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true, true) - .specialTexture(GTGuiTextures.PROGRESS_BAR_LATHE_BASE, 98, 24, 5, 18) + .specialTexture(widget -> widget.overlay(GTGuiTextures.PROGRESS_BAR_LATHE_BASE.asIcon() + .size(5, 18) + .alignment(Alignment.CenterRight))) .progressBar(GTGuiTextures.PROGRESS_BAR_LATHE)) .sound(GTSoundEvents.CUT) .build(); diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index f666b24ec3e..4ce70f7a047 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -51,11 +51,12 @@ public class RecipeMapUI> { private final boolean isGenerator; - private @NotNull Area specialTexturePosition = new Area(); private boolean isJEIVisible = true; /* *********************** MUI 1 *********************** */ + @Deprecated + private final @NotNull Area specialTexturePosition = new Area(); @Deprecated private final Byte2ObjectMap slotOverlays = new Byte2ObjectOpenHashMap<>(); @@ -74,7 +75,7 @@ public class RecipeMapUI> { private boolean usesMui2 = false; private UITexture progressTexture = GTGuiTextures.PROGRESS_BAR_ARROW; private ProgressWidget.Direction progressDirection = ProgressWidget.Direction.RIGHT; - private @Nullable IDrawable specialDrawableTexture; + private Consumer> extraOverlays = null; /** * @param recipeMap the recipemap corresponding to this ui @@ -559,7 +560,11 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu row.child(makeInventorySlotGroup(importItems, importFluids, false) .marginLeft(m - 4)); } - row.child(new RecipeProgressWidget() + RecipeProgressWidget progressWidget = new RecipeProgressWidget(); + if (this.extraOverlays != null) { + this.extraOverlays.accept(progressWidget); + } + row.child(progressWidget .recipeMap(recipeMap) .debugName("recipe.progress") .size(20) @@ -570,15 +575,7 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu if (exportItems.getSlots() > 0 || exportFluids.getTanks() > 0) { row.child(makeInventorySlotGroup(exportItems, exportFluids, true)); } - panel.child(row); - if (specialDrawableTexture != null) { - panel.child(specialDrawableTexture.asWidget() - .debugName("special_texture") - // todo fix these hard coded values - .pos(specialTexturePosition.x(), specialTexturePosition.y()) - .size(specialTexturePosition.w(), specialTexturePosition.h())); - } - return panel; + return panel.child(row); } private int calculateCenter(int inputItems, int inputFluids, int panelSize) { @@ -746,12 +743,10 @@ public void setProgressBarDirection(@NotNull ProgressWidget.Direction direction) } /** - * @param specialTexture the special texture to set - * @param position the position of the texture: [x, y, width, height] + * @param extraOverlays Consumer for adding stuff to the progress widget */ - public void setSpecialTexture(@NotNull IDrawable specialTexture, @NotNull Area position) { - this.specialDrawableTexture = specialTexture; - this.specialTexturePosition = position; + public void setSpecialTexture(Consumer> extraOverlays) { + this.extraOverlays = extraOverlays; } /** diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java index 4622e869232..9c3c05bb59f 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUIBuilder.java @@ -2,11 +2,13 @@ import com.cleanroommc.modularui.api.drawable.IDrawable; import com.cleanroommc.modularui.drawable.UITexture; -import com.cleanroommc.modularui.widget.sizer.Area; +import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widgets.ProgressWidget; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import java.util.function.Consumer; + @ApiStatus.Experimental @SuppressWarnings({ "unused", "UnusedReturnValue" }) public class RecipeMapUIBuilder { @@ -141,14 +143,11 @@ public RecipeMapUIBuilder(RecipeMapUI mapUI) { return this; } - public @NotNull RecipeMapUIBuilder specialTexture(@NotNull UITexture texture, - int x, int y, - int width, int height) { - return specialTexture(texture, new Area(x, y, width, height)); - } - - public @NotNull RecipeMapUIBuilder specialTexture(@NotNull UITexture texture, @NotNull Area area) { - this.mapUI.setSpecialTexture(texture, area); + /** + * @param extraOverlays Consumer for adding stuff to the progress widget + */ + public @NotNull RecipeMapUIBuilder specialTexture(Consumer> extraOverlays) { + this.mapUI.setSpecialTexture(extraOverlays); return this; } From 341a3ac3c37164a15e2d3cd83925405c1b5fcff7 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 28 Sep 2025 16:02:21 -0700 Subject: [PATCH 47/55] fix special textures remove `+ 9` --- src/main/java/gregtech/api/recipes/RecipeMaps.java | 7 +++++-- src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/RecipeMaps.java b/src/main/java/gregtech/api/recipes/RecipeMaps.java index 0ae8d34adcf..3dcdd3b2f57 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMaps.java +++ b/src/main/java/gregtech/api/recipes/RecipeMaps.java @@ -903,7 +903,9 @@ public final class RecipeMaps { .uiBuilder(b -> b .itemSlotOverlay(GTGuiTextures.HAMMER_OVERLAY, false) .specialTexture(widget -> widget.overlay(GTGuiTextures.PROGRESS_BAR_HAMMER_BASE.asIcon() - .size(20, 6))) + .size(20, 6) + .alignment(Alignment.BottomCenter) + .marginBottom(-5))) .progressBar(GTGuiTextures.PROGRESS_BAR_HAMMER, Direction.DOWN)) .sound(GTSoundEvents.FORGE_HAMMER) .build(); @@ -1137,8 +1139,9 @@ public final class RecipeMaps { .itemSlotOverlay(GTGuiTextures.PIPE_OVERLAY_1, false) .itemSlotOverlay(GTGuiTextures.PIPE_OVERLAY_2, true, false) .itemSlotOverlay(GTGuiTextures.DUST_OVERLAY, true, true) - .specialTexture(widget -> widget.overlay(GTGuiTextures.PROGRESS_BAR_LATHE_BASE.asIcon() + .specialTexture(widget -> widget.background(GTGuiTextures.PROGRESS_BAR_LATHE_BASE.asIcon() .size(5, 18) + .marginRight(-3) .alignment(Alignment.CenterRight))) .progressBar(GTGuiTextures.PROGRESS_BAR_LATHE)) .sound(GTSoundEvents.CUT) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 4ce70f7a047..aa99b486217 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -547,7 +547,7 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier); Flow row = Flow.row() - .height(3 * 18 + 9) + .height(3 * 18) .debugName("row:recipemapui.parent") .crossAxisAlignment(Alignment.CrossAxis.CENTER) .top(23 - 7); From 526c738360881864cdeedbf4a98ac9608f415cc0 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 28 Sep 2025 16:05:21 -0700 Subject: [PATCH 48/55] remove if condition for simple machines --- .../SimpleMachineMetaTileEntity.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 35ac0d4dcdc..5f1d336777e 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -548,19 +548,17 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) .addTooltip(false, IKey.lang("gregtech.gui.fluid_auto_output.tooltip.disabled"))); } - if (exportItems.getSlots() + exportFluids.getTanks() <= 9) { - col.child(new Widget<>() - .size(17) - .marginTop(1) - .marginRight(1) - .bottom(0) - .background(GTGuiTextures.getLogo(getUITheme()))); - - if (hasGhostCircuitInventory() && circuitInventory != null) { - col.child(new GhostCircuitSlotWidget() - .slot(SyncHandlers.itemSlot(circuitInventory, 0)) - .background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY)); - } + col.child(new Widget<>() + .size(17) + .marginTop(1) + .marginRight(1) + .bottom(0) + .background(GTGuiTextures.getLogo(getUITheme()))); + + if (hasGhostCircuitInventory() && circuitInventory != null) { + col.child(new GhostCircuitSlotWidget() + .slot(SyncHandlers.itemSlot(circuitInventory, 0)) + .background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY)); } return panel; } From 9f57e43f7c5647d84f964ea4bfbcf7fb83ccab37 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Sun, 28 Sep 2025 23:27:51 -0700 Subject: [PATCH 49/55] increase progress widget margin --- src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index aa99b486217..97676f786be 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -555,10 +555,11 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu // this isn't great but it works for now // panel size is hardcoded because you can't get the panel size from the panel int m = calculateCenter(importItems.getSlots(), importFluids.getTanks(), 176 + 20); + int margin = 6; if (importItems.getSlots() > 0 || importFluids.getTanks() > 0) { row.child(makeInventorySlotGroup(importItems, importFluids, false) - .marginLeft(m - 4)); + .marginLeft(m - margin)); } RecipeProgressWidget progressWidget = new RecipeProgressWidget(); if (this.extraOverlays != null) { @@ -568,7 +569,7 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu .recipeMap(recipeMap) .debugName("recipe.progress") .size(20) - .margin(4, 0) + .margin(margin, 0) .value(progressValue) .texture(progressTexture, 20) .direction(progressDirection)); From ecd5559bc62d7fe144b1321627f804ed746ac6aa Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Mon, 29 Sep 2025 01:22:26 -0700 Subject: [PATCH 50/55] improve centering slots around progress widget --- .../gregtech/api/recipes/ui/RecipeMapUI.java | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 97676f786be..c0112e008a2 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -549,17 +549,20 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu Flow row = Flow.row() .height(3 * 18) .debugName("row:recipemapui.parent") + .alignX(0.5f) .crossAxisAlignment(Alignment.CrossAxis.CENTER) .top(23 - 7); - // this isn't great but it works for now - // panel size is hardcoded because you can't get the panel size from the panel - int m = calculateCenter(importItems.getSlots(), importFluids.getTanks(), 176 + 20); + int progressSize = 20; int margin = 6; + row.width(calculateWidth(importItems.getSlots(), importFluids.getTanks(), + exportItems.getSlots(), exportFluids.getTanks(), + progressSize, margin)); + + if (!this.isLeftGreater) row.mainAxisAlignment(Alignment.MainAxis.END); if (importItems.getSlots() > 0 || importFluids.getTanks() > 0) { - row.child(makeInventorySlotGroup(importItems, importFluids, false) - .marginLeft(m - margin)); + row.child(makeInventorySlotGroup(importItems, importFluids, false)); } RecipeProgressWidget progressWidget = new RecipeProgressWidget(); if (this.extraOverlays != null) { @@ -568,7 +571,7 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu row.child(progressWidget .recipeMap(recipeMap) .debugName("recipe.progress") - .size(20) + .size(progressSize) .margin(margin, 0) .value(progressValue) .texture(progressTexture, 20) @@ -579,15 +582,31 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu return panel.child(row); } - private int calculateCenter(int inputItems, int inputFluids, int panelSize) { - int[] ints = determineSlotsGrid(inputItems, inputFluids); - int leftSize = ints[1] >= inputFluids && ints[0] < 3 ? - (ints[0] + ints[2]) * 18 : - Math.max(ints[0] * 18, ints[2] * 18); - int p = panelSize / 2; - p -= 10; - p -= leftSize; - return p; + boolean isLeftGreater = false; + + private int calculateWidth(int inputItems, int inputFluids, + int outputItems, int outputFluids, + int progressSize, int margin) { + int[] inputGrid = determineSlotsGrid(inputItems, inputFluids); + int[] outputGrid = determineSlotsGrid(outputItems, outputFluids); + + int w1 = getGridWidth(inputGrid, inputFluids); + int w2 = getGridWidth(outputGrid, outputFluids); + + this.isLeftGreater = w1 >= w2; + return (Math.max(w1, w2) + margin) * 2 + progressSize; + } + + private int getGridWidth(int[] grid, int fluidCount) { + if (isSingleRow(grid, fluidCount)) { + return (grid[0] + grid[2]) * 18; + } else { + return Math.max(grid[0] * 18, (grid[2] * 18)); + } + } + + private boolean isSingleRow(int[] grid, int fluidCount) { + return grid[1] >= fluidCount && grid[0] < 3; } private Widget makeItemGroup(int width, IItemHandlerModifiable handler, boolean isOutputs) { @@ -641,10 +660,11 @@ protected Widget makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemH int fluidGridWidth = slotGridSizes[2]; int fluidGridHeight = slotGridSizes[3]; - boolean singleRow = itemGridHeight >= fluidInputsCount && itemGridWidth < 3; + boolean singleRow = isSingleRow(slotGridSizes, fluidInputsCount); - Flow flow = (singleRow ? Flow.row() : Flow.column()).coverChildren() - .debugName(singleRow ? "parent.row" : "parent.col"); + Flow flow = (singleRow ? Flow.row() : Flow.column()) + .coverChildren() + .debugName(singleRow ? "row:parent" : "col:parent"); flow.crossAxisAlignment(isOutputs ? Alignment.CrossAxis.START : Alignment.CrossAxis.END); if (!onlyFluids && fluidGridHeight > 1) { From 1bb7c67ac3e7b6c39d10d36968b16317aefd3b44 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Mon, 29 Sep 2025 01:44:23 -0700 Subject: [PATCH 51/55] improve item/fluid groups move special machine widgets around --- .../SimpleMachineMetaTileEntity.java | 18 +++--- .../gregtech/api/recipes/ui/RecipeMapUI.java | 63 +++++++++++-------- 2 files changed, 46 insertions(+), 35 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index 5f1d336777e..b539ff6354d 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -525,13 +525,6 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) .child(col) .child(SlotGroupWidget.playerInventory().left(7)); - col.child(new ItemSlot() - .debugName("charger.slot") - .slot(SyncHandlers.itemSlot(chargerInventory, 0)) - .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY) - .addTooltipLine(IKey.lang("gregtech.gui.charger_slot.tooltip", - GTValues.VNF[getTier()], GTValues.VNF[getTier()]))); - if (exportItems.getSlots() > 0) { col.child(new ToggleButton() .overlay(GTGuiTextures.BUTTON_ITEM_OUTPUT) @@ -548,15 +541,24 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) .addTooltip(false, IKey.lang("gregtech.gui.fluid_auto_output.tooltip.disabled"))); } + col.child(new ItemSlot() + .debugName("charger.slot") + .slot(SyncHandlers.itemSlot(chargerInventory, 0)) + .background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY) + .bottom(18 + 4) + .addTooltipLine(IKey.lang("gregtech.gui.charger_slot.tooltip", + GTValues.VNF[getTier()], GTValues.VNF[getTier()]))); + col.child(new Widget<>() .size(17) .marginTop(1) .marginRight(1) - .bottom(0) + .top(-17 - 2) .background(GTGuiTextures.getLogo(getUITheme()))); if (hasGhostCircuitInventory() && circuitInventory != null) { col.child(new GhostCircuitSlotWidget() + .bottom(0) .slot(SyncHandlers.itemSlot(circuitInventory, 0)) .background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY)); } diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index c0112e008a2..86b28a43071 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -609,34 +609,45 @@ private boolean isSingleRow(int[] grid, int fluidCount) { return grid[1] >= fluidCount && grid[0] < 3; } - private Widget makeItemGroup(int width, IItemHandlerModifiable handler, boolean isOutputs) { - Flow col = Flow.column().mainAxisAlignment(Alignment.MainAxis.END) - .coverChildren().debugName("item.col"); - int c = handler.getSlots(); - int h = (int) Math.ceil((double) c / width); - SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", - width, 1, !isOutputs); - for (int i = 0; i < h; i++) { - Flow row = Flow.row().mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END) - .coverChildren().debugName("item.row." + i); + /** + * @param grid [item grid width, item grid height, fluid grid width, fluid grid height] + */ + private Widget makeItemGroup(int[] grid, IItemHandlerModifiable handler, boolean isOutputs) { + Flow col = Flow.column() + .mainAxisAlignment(Alignment.MainAxis.END) + .coverChildren() + .debugName("col:item_grid"); + int width = grid[0], height = grid[1]; + SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", width, 1, !isOutputs); + for (int i = 0; i < height; i++) { + Flow row = Flow.row() + .mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END) + .coverChildren() + .debugName("row:item_" + i); for (int j = 0; j < width; j++) { - row.child(makeItemSlot(slotGroup, (i * h) + j, handler, isOutputs)); + row.child(makeItemSlot(slotGroup, (i * height) + j, handler, isOutputs)); } col.child(row); } return col; } - private Widget makeFluidGroup(int width, FluidTankList handler, boolean isOutputs) { - Flow col = Flow.column().mainAxisAlignment(Alignment.MainAxis.START) - .coverChildren().debugName("fluid.col"); - int c = handler.getTanks(); - int h = (int) Math.ceil((double) c / width); - for (int i = 0; i < h; i++) { - Flow row = Flow.row().mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END) - .coverChildren().debugName("fluid.row"); + /** + * @param grid [item grid width, item grid height, fluid grid width, fluid grid height] + */ + private Widget makeFluidGroup(int[] grid, FluidTankList handler, boolean isOutputs) { + Flow col = Flow.column() + .mainAxisAlignment(Alignment.MainAxis.START) + .coverChildren() + .debugName("col:fluid_grid"); + int width = grid[2], height = grid[3]; + for (int i = 0; i < height; i++) { + Flow row = Flow.row() + .mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END) + .coverChildren() + .debugName("row:fluid_" + i); for (int j = 0; j < width; j++) { - row.child(makeFluidSlot((i * h) + j, handler, isOutputs)); + row.child(makeFluidSlot((i * height) + j, handler, isOutputs)); } col.child(row); } @@ -655,11 +666,9 @@ protected Widget makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemH } int[] slotGridSizes = determineSlotsGrid(itemInputsCount, fluidInputsCount); - int itemGridWidth = slotGridSizes[onlyFluids ? 2 : 0]; int itemGridHeight = slotGridSizes[onlyFluids ? 3 : 1]; - - int fluidGridWidth = slotGridSizes[2]; int fluidGridHeight = slotGridSizes[3]; + boolean singleRow = isSingleRow(slotGridSizes, fluidInputsCount); Flow flow = (singleRow ? Flow.row() : Flow.column()) @@ -678,11 +687,11 @@ protected Widget makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemH } if (onlyFluids) { - flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(fluidGridWidth, fluidHandler, isOutputs)); + flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(slotGridSizes, fluidHandler, isOutputs)); } else { - flow.childIf(!singleRow || isOutputs, () -> makeItemGroup(itemGridWidth, itemHandler, isOutputs)); - flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(fluidGridWidth, fluidHandler, isOutputs)); - flow.childIf(singleRow && !isOutputs, () -> makeItemGroup(itemGridWidth, itemHandler, isOutputs)); + flow.childIf(!singleRow || isOutputs, () -> makeItemGroup(slotGridSizes, itemHandler, isOutputs)); + flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(slotGridSizes, fluidHandler, isOutputs)); + flow.childIf(singleRow && !isOutputs, () -> makeItemGroup(slotGridSizes, itemHandler, isOutputs)); } return flow; From 05f15e863053d2706d89c22f3db72cee5f90d4db Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Mon, 29 Sep 2025 02:21:40 -0700 Subject: [PATCH 52/55] make `setSize()` a builder method construct panel in map ui adjust height to remove empty space --- .../SimpleGeneratorMetaTileEntity.java | 10 ++-- .../SimpleMachineMetaTileEntity.java | 12 +++-- .../metatileentity/SteamMetaTileEntity.java | 12 ++--- .../gregtech/api/recipes/ui/RecipeMapUI.java | 51 ++++++++++++++++--- 4 files changed, 62 insertions(+), 23 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java index 12954f569bd..22377ed85bb 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java @@ -11,7 +11,6 @@ import gregtech.api.gui.widgets.LabelWidget; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.mui.GTGuiTextures; -import gregtech.api.mui.GTGuis; import gregtech.api.recipes.RecipeMap; import gregtech.client.renderer.ICubeRenderer; import gregtech.client.renderer.texture.Textures; @@ -151,9 +150,12 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) yOffset = FONT_HEIGHT; } - ModularPanel panel = GTGuis.createPanel(this, 176, 166 + yOffset); - workableRecipeMap.getRecipeMapUI().constructPanel(panel, workable::getProgressPercent, - importItems, exportItems, importFluids, exportFluids, yOffset, guiSyncManager) + ModularPanel panel = workableRecipeMap.getRecipeMapUI() + .setSize(176, 166 + yOffset) + .constructPanel(this, workable::getProgressPercent, + importItems, exportItems, + importFluids, exportFluids, + yOffset, guiSyncManager) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) .bindPlayerInventory(); diff --git a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java index b539ff6354d..597efe1eae3 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java @@ -17,7 +17,6 @@ import gregtech.api.items.itemhandlers.GTItemStackHandler; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.mui.GTGuiTextures; -import gregtech.api.mui.GTGuis; import gregtech.api.mui.widget.GhostCircuitSlotWidget; import gregtech.api.recipes.RecipeMap; import gregtech.api.util.GTTransferUtils; @@ -503,9 +502,8 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) yOffset = FONT_HEIGHT; } - ModularPanel panel = GTGuis.createPanel(this, 176 + 20, 166 + yOffset); Flow col = Flow.column() - .debugName("special.buttons") + .debugName("col:special.buttons") .right(7).bottom(7) .height(18 * 4 + 4) .width(18); @@ -513,8 +511,12 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) BooleanSyncValue hasEnergy = new BooleanSyncValue(workable::isHasNotEnoughEnergy); guiSyncManager.syncValue("has_energy", hasEnergy); - workableRecipeMap.getRecipeMapUI().constructPanel(panel, workable::getProgressPercent, - importItems, exportItems, importFluids, exportFluids, yOffset, guiSyncManager) + ModularPanel panel = workableRecipeMap.getRecipeMapUI() + .setSize(176 + 20, 166 + yOffset) + .constructPanel(this, workable::getProgressPercent, + importItems, exportItems, + importFluids, exportFluids, + yOffset, guiSyncManager) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) .child(GTGuiTextures.INDICATOR_NO_ENERGY.asWidget() .debugName("energy.indicator") diff --git a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java index 33a9935d49d..67f06395efb 100644 --- a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java @@ -9,7 +9,6 @@ import gregtech.api.gui.ModularUI; import gregtech.api.gui.widgets.ImageWidget; import gregtech.api.mui.GTGuiTheme; -import gregtech.api.mui.GTGuis; import gregtech.api.recipes.RecipeMap; import gregtech.api.util.GTUtility; import gregtech.client.particle.VanillaParticleEffects; @@ -145,14 +144,13 @@ public boolean usesMui2() { public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { RecipeMap map = Objects.requireNonNull(getRecipeMap()); - ModularPanel modularPanel = GTGuis.defaultPanel(this); - - map.getRecipeMapUI().constructPanel(modularPanel, workableHandler::getProgressPercent, - importItems, exportItems, EMPTY, exportFluids, 0, guiSyncManager) + return map.getRecipeMapUI() + .constructPanel(this, workableHandler::getProgressPercent, + importItems, exportItems, + EMPTY, exportFluids, + 0, guiSyncManager) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) .bindPlayerInventory(); - - return modularPanel; } @Override diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index 86b28a43071..b55b137972e 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -6,7 +6,9 @@ import gregtech.api.gui.resources.TextureArea; import gregtech.api.gui.widgets.SlotWidget; import gregtech.api.gui.widgets.TankWidget; +import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.mui.GTGuiTextures; +import gregtech.api.mui.GTGuis; import gregtech.api.mui.widget.RecipeProgressWidget; import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMap; @@ -76,6 +78,9 @@ public class RecipeMapUI> { private UITexture progressTexture = GTGuiTextures.PROGRESS_BAR_ARROW; private ProgressWidget.Direction progressDirection = ProgressWidget.Direction.RIGHT; private Consumer> extraOverlays = null; + private int width = GTGuis.DEFAULT_WIDTH; + private int height = GTGuis.DEFAULT_HIEGHT; + private boolean isLeftGreater = false; /** * @param recipeMap the recipemap corresponding to this ui @@ -540,14 +545,31 @@ public void setSlotOverlay(byte key, @NotNull TextureArea texture) { /* *********************** MUI 2 *********************** */ - public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSupplier, - IItemHandlerModifiable importItems, - IItemHandlerModifiable exportItems, FluidTankList importFluids, - FluidTankList exportFluids, int yOffset, PanelSyncManager syncManager) { + public RecipeMapUI setSize(int width, int height) { + this.width = width; + this.height = height; + return this; + } + + public ModularPanel constructPanel(MetaTileEntity mte, DoubleSupplier progressSupplier, + IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, + FluidTankList importFluids, FluidTankList exportFluids, + int yOffset, PanelSyncManager syncManager) { + int inputHeight = calculateHeight(determineSlotsGrid(importItems.getSlots(), importFluids.getTanks()), + importFluids.getTanks()); + int outputHeight = calculateHeight(determineSlotsGrid(exportItems.getSlots(), exportFluids.getTanks()), + exportFluids.getTanks()); + ModularPanel panel = GTGuis.createPanel(mte, this.width, adjustHeight(inputHeight, outputHeight)); + DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier); + int h = 3 * 18; + if (Math.max(inputHeight, outputHeight) < 3) { + h -= 18; + } + Flow row = Flow.row() - .height(3 * 18) + .height(h) .debugName("row:recipemapui.parent") .alignX(0.5f) .crossAxisAlignment(Alignment.CrossAxis.CENTER) @@ -582,8 +604,6 @@ public ModularPanel constructPanel(ModularPanel panel, DoubleSupplier progressSu return panel.child(row); } - boolean isLeftGreater = false; - private int calculateWidth(int inputItems, int inputFluids, int outputItems, int outputFluids, int progressSize, int margin) { @@ -609,6 +629,23 @@ private boolean isSingleRow(int[] grid, int fluidCount) { return grid[1] >= fluidCount && grid[0] < 3; } + private int adjustHeight(int inputHeight, int outputHeight) { + if (Math.max(inputHeight, outputHeight) < 4) { + return this.height - 18; + } + return this.height; + } + + private int calculateHeight(int[] inputs, int inputFluids) { + int inputHeight; + if (isSingleRow(inputs, inputFluids)) { + inputHeight = Math.max(inputs[1], inputs[3]); + } else { + inputHeight = inputs[1] + inputs[3]; + } + return inputHeight; + } + /** * @param grid [item grid width, item grid height, fluid grid width, fluid grid height] */ From 13fc654e1f882c5822a3fe586accd16bb9bd4a17 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:08:35 -0700 Subject: [PATCH 53/55] create CalculatedGrid to simplify and cleanup logic --- .../gregtech/api/recipes/ui/RecipeMapUI.java | 159 +++++++++++------- 1 file changed, 98 insertions(+), 61 deletions(-) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index b55b137972e..df0e3d9e0e7 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -555,10 +555,12 @@ public ModularPanel constructPanel(MetaTileEntity mte, DoubleSupplier progressSu IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset, PanelSyncManager syncManager) { - int inputHeight = calculateHeight(determineSlotsGrid(importItems.getSlots(), importFluids.getTanks()), - importFluids.getTanks()); - int outputHeight = calculateHeight(determineSlotsGrid(exportItems.getSlots(), exportFluids.getTanks()), - exportFluids.getTanks()); + CalculatedGrid inputGrid = CalculatedGrid.of(importItems, importFluids); + CalculatedGrid outputGrid = CalculatedGrid.of(exportItems, exportFluids); + + int inputHeight = inputGrid.getMaxHeight(); + int outputHeight = outputGrid.getMaxHeight(); + ModularPanel panel = GTGuis.createPanel(mte, this.width, adjustHeight(inputHeight, outputHeight)); DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier); @@ -577,14 +579,14 @@ public ModularPanel constructPanel(MetaTileEntity mte, DoubleSupplier progressSu int progressSize = 20; int margin = 6; - row.width(calculateWidth(importItems.getSlots(), importFluids.getTanks(), - exportItems.getSlots(), exportFluids.getTanks(), - progressSize, margin)); + row.width(calculatePixelWidth(inputGrid, outputGrid, progressSize, margin)); - if (!this.isLeftGreater) row.mainAxisAlignment(Alignment.MainAxis.END); + if (inputGrid.getMaxWidth() < outputGrid.getMaxWidth()) { + row.mainAxisAlignment(Alignment.MainAxis.END); + } if (importItems.getSlots() > 0 || importFluids.getTanks() > 0) { - row.child(makeInventorySlotGroup(importItems, importFluids, false)); + row.child(makeInventorySlotGroup(inputGrid, importItems, importFluids, false)); } RecipeProgressWidget progressWidget = new RecipeProgressWidget(); if (this.extraOverlays != null) { @@ -599,34 +601,17 @@ public ModularPanel constructPanel(MetaTileEntity mte, DoubleSupplier progressSu .texture(progressTexture, 20) .direction(progressDirection)); if (exportItems.getSlots() > 0 || exportFluids.getTanks() > 0) { - row.child(makeInventorySlotGroup(exportItems, exportFluids, true)); + row.child(makeInventorySlotGroup(outputGrid, exportItems, exportFluids, true)); } return panel.child(row); } - private int calculateWidth(int inputItems, int inputFluids, - int outputItems, int outputFluids, - int progressSize, int margin) { - int[] inputGrid = determineSlotsGrid(inputItems, inputFluids); - int[] outputGrid = determineSlotsGrid(outputItems, outputFluids); - - int w1 = getGridWidth(inputGrid, inputFluids); - int w2 = getGridWidth(outputGrid, outputFluids); + private static int calculatePixelWidth(CalculatedGrid inputGrid, CalculatedGrid outputGrid, + int progressSize, int margin) { + int leftWidth = inputGrid.getMaxWidth() * 18; + int rightWidth = outputGrid.getMaxWidth() * 18; - this.isLeftGreater = w1 >= w2; - return (Math.max(w1, w2) + margin) * 2 + progressSize; - } - - private int getGridWidth(int[] grid, int fluidCount) { - if (isSingleRow(grid, fluidCount)) { - return (grid[0] + grid[2]) * 18; - } else { - return Math.max(grid[0] * 18, (grid[2] * 18)); - } - } - - private boolean isSingleRow(int[] grid, int fluidCount) { - return grid[1] >= fluidCount && grid[0] < 3; + return (Math.max(leftWidth, rightWidth) + margin) * 2 + progressSize; } private int adjustHeight(int inputHeight, int outputHeight) { @@ -636,25 +621,14 @@ private int adjustHeight(int inputHeight, int outputHeight) { return this.height; } - private int calculateHeight(int[] inputs, int inputFluids) { - int inputHeight; - if (isSingleRow(inputs, inputFluids)) { - inputHeight = Math.max(inputs[1], inputs[3]); - } else { - inputHeight = inputs[1] + inputs[3]; - } - return inputHeight; - } - - /** - * @param grid [item grid width, item grid height, fluid grid width, fluid grid height] - */ - private Widget makeItemGroup(int[] grid, IItemHandlerModifiable handler, boolean isOutputs) { + private Widget makeItemGroup(CalculatedGrid grid, IItemHandlerModifiable handler, boolean isOutputs) { Flow col = Flow.column() .mainAxisAlignment(Alignment.MainAxis.END) .coverChildren() .debugName("col:item_grid"); - int width = grid[0], height = grid[1]; + int width = grid.getItemGridWidth(); + int height = grid.getItemGridHeight(); + SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", width, 1, !isOutputs); for (int i = 0; i < height; i++) { Flow row = Flow.row() @@ -669,15 +643,15 @@ private Widget makeItemGroup(int[] grid, IItemHandlerModifiable handler, bool return col; } - /** - * @param grid [item grid width, item grid height, fluid grid width, fluid grid height] - */ - private Widget makeFluidGroup(int[] grid, FluidTankList handler, boolean isOutputs) { + private Widget makeFluidGroup(CalculatedGrid grid, FluidTankList handler, boolean isOutputs) { Flow col = Flow.column() .mainAxisAlignment(Alignment.MainAxis.START) .coverChildren() .debugName("col:fluid_grid"); - int width = grid[2], height = grid[3]; + + int width = grid.getFluidGridWidth(); + int height = grid.getFluidGridHeight(); + for (int i = 0; i < height; i++) { Flow row = Flow.row() .mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END) @@ -692,7 +666,7 @@ private Widget makeFluidGroup(int[] grid, FluidTankList handler, boolean isOu } @NotNull - protected Widget makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemHandler, + protected Widget makeInventorySlotGroup(CalculatedGrid grid, @NotNull IItemHandlerModifiable itemHandler, @NotNull FluidTankList fluidHandler, boolean isOutputs) { final int itemInputsCount = itemHandler.getSlots(); boolean onlyFluids = itemInputsCount == 0; @@ -702,11 +676,13 @@ protected Widget makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemH throw new IllegalArgumentException("item and fluid handlers are empty!"); } - int[] slotGridSizes = determineSlotsGrid(itemInputsCount, fluidInputsCount); - int itemGridHeight = slotGridSizes[onlyFluids ? 3 : 1]; - int fluidGridHeight = slotGridSizes[3]; + int itemGridHeight = grid.getFluidGridHeight(); + int fluidGridHeight = grid.getFluidGridHeight(); + if (!onlyFluids) { + itemGridHeight = grid.getItemGridHeight(); + } - boolean singleRow = isSingleRow(slotGridSizes, fluidInputsCount); + boolean singleRow = grid.isSingleRow(); Flow flow = (singleRow ? Flow.row() : Flow.column()) .coverChildren() @@ -724,11 +700,11 @@ protected Widget makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemH } if (onlyFluids) { - flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(slotGridSizes, fluidHandler, isOutputs)); + flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(grid, fluidHandler, isOutputs)); } else { - flow.childIf(!singleRow || isOutputs, () -> makeItemGroup(slotGridSizes, itemHandler, isOutputs)); - flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(slotGridSizes, fluidHandler, isOutputs)); - flow.childIf(singleRow && !isOutputs, () -> makeItemGroup(slotGridSizes, itemHandler, isOutputs)); + flow.childIf(!singleRow || isOutputs, () -> makeItemGroup(grid, itemHandler, isOutputs)); + flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(grid, fluidHandler, isOutputs)); + flow.childIf(singleRow && !isOutputs, () -> makeItemGroup(grid, itemHandler, isOutputs)); } return flow; @@ -875,4 +851,65 @@ public boolean canModifyFluidOutputs() { public @NotNull R recipeMap() { return recipeMap; } + + protected static class CalculatedGrid { + + private final int itemCount; + private final int fluidCount; + private final int[] grid; + + protected static CalculatedGrid of(IItemHandlerModifiable itemHandler, FluidTankList fluidTankList) { + return new CalculatedGrid(itemHandler.getSlots(), fluidTankList.getTanks()); + } + + private CalculatedGrid(int itemCount, int fluidCount) { + this.itemCount = itemCount; + this.fluidCount = fluidCount; + this.grid = RecipeMapUI.determineSlotsGrid(this.itemCount, this.fluidCount); + } + + public int getItemCount() { + return this.itemCount; + } + + public int getItemGridWidth() { + return this.grid[0]; + } + + public int getItemGridHeight() { + return this.grid[1]; + } + + public int getFluidCount() { + return this.fluidCount; + } + + public int getFluidGridWidth() { + return this.grid[2]; + } + + public int getFluidGridHeight() { + return this.grid[3]; + } + + public int getMaxWidth() { + if (isSingleRow()) { + return getFluidGridWidth() + getItemGridWidth(); + } else { + return Math.max(getFluidGridWidth(), getItemGridWidth()); + } + } + + public int getMaxHeight() { + if (isSingleRow()) { + return Math.max(getFluidGridHeight(), getItemGridHeight()); + } else { + return getFluidGridHeight() + getItemGridHeight(); + } + } + + private boolean isSingleRow() { + return getItemGridHeight() >= getFluidCount() && getItemGridWidth() < 3; + } + } } From 7cb191a0991a090b3b767af329224bd112da805c Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:53:53 -0700 Subject: [PATCH 54/55] fix logo in SimpleGeneratorMetaTileEntity add heat tooltip + lang in SteamBoiler add todo for SteamMetaTileEntity --- .../api/metatileentity/SimpleGeneratorMetaTileEntity.java | 3 ++- .../gregtech/api/metatileentity/SteamMetaTileEntity.java | 1 + .../common/metatileentities/steam/boiler/SteamBoiler.java | 8 ++++++++ src/main/resources/assets/gregtech/lang/en_us.lang | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java index 22377ed85bb..70fb8eab295 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java @@ -162,7 +162,8 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) if (exportItems.getSlots() + exportFluids.getTanks() <= 9) { panel.child(new Widget<>() .size(17) - .pos(152, 63 + yOffset) + .right(7) + .top(45 + yOffset) .background(GTGuiTextures.getLogo(getUITheme()))); } return panel; diff --git a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java index 67f06395efb..8e43093ba3d 100644 --- a/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java @@ -144,6 +144,7 @@ public boolean usesMui2() { public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { RecipeMap map = Objects.requireNonNull(getRecipeMap()); + // todo remove logo from background and use a widget return map.getRecipeMapUI() .constructPanel(this, workableHandler::getProgressPercent, importItems, exportItems, diff --git a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java index c49f4d68d8a..14aa0e0e9c1 100644 --- a/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java +++ b/src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java @@ -50,6 +50,7 @@ import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.value.sync.DoubleSyncValue; +import com.cleanroommc.modularui.value.sync.IntSyncValue; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cleanroommc.modularui.widget.Widget; import com.cleanroommc.modularui.widgets.ItemSlot; @@ -161,12 +162,14 @@ public void readFromNBT(NBTTagCompound data) { public void writeInitialSyncData(PacketBuffer buf) { super.writeInitialSyncData(buf); buf.writeBoolean(isBurning); + buf.writeVarInt(currentTemperature); } @Override public void receiveInitialSyncData(PacketBuffer buf) { super.receiveInitialSyncData(buf); this.isBurning = buf.readBoolean(); + this.currentTemperature = buf.readVarInt(); } @Override @@ -346,12 +349,17 @@ public boolean usesMui2() { @Override public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { + IntSyncValue temp = new IntSyncValue(this::getCurrentTemperature); + guiSyncManager.syncValue("temperature", temp); return GTGuis.defaultPanel(this) .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) .child(new ProgressWidget() .texture(getEmptyBarDrawable(), GTGuiTextures.PROGRESS_BAR_BOILER_HEAT, -1) .direction(ProgressWidget.Direction.UP) .debugName("temp") + .tooltipBuilder( + tooltip -> tooltip.addLine(IKey.lang("gregtech.machine.steam_boiler.heat_tooltip", + temp.getIntValue(), getMaxTemperate()))) .value(new DoubleSyncValue(this::getTemperaturePercent)) .pos(96, 26) .size(10, 54)) diff --git a/src/main/resources/assets/gregtech/lang/en_us.lang b/src/main/resources/assets/gregtech/lang/en_us.lang index 79b97d5b382..bb01508bef7 100644 --- a/src/main/resources/assets/gregtech/lang/en_us.lang +++ b/src/main/resources/assets/gregtech/lang/en_us.lang @@ -3018,6 +3018,7 @@ gregtech.machine.steam_boiler_lava_steel.name=High Pressure Steam Liquid Boiler gregtech.machine.steam_boiler_lava_steel.tooltip=Faster than Small Steam Liquid Boiler gregtech.machine.steam_boiler.heat_amount=Heat Capacity: %s %% +gregtech.machine.steam_boiler.heat_tooltip=Heat: %,d°C / %,d°C gregtech.machine.steam_extractor_bronze.name=Steam Extractor gregtech.machine.steam_extractor_bronze.tooltip=Extracting your first Rubber From 393d54099bfe2c1a9a629ff9ad50e4ebd756450c Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Thu, 16 Oct 2025 00:21:54 -0700 Subject: [PATCH 55/55] remove unused field --- src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java index df0e3d9e0e7..9936800ed92 100644 --- a/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java +++ b/src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java @@ -80,7 +80,6 @@ public class RecipeMapUI> { private Consumer> extraOverlays = null; private int width = GTGuis.DEFAULT_WIDTH; private int height = GTGuis.DEFAULT_HIEGHT; - private boolean isLeftGreater = false; /** * @param recipeMap the recipemap corresponding to this ui