builder) {
@@ -377,7 +342,6 @@ default void postResize() {}
*
* @return if this element is enabled
*/
- @Override
boolean isEnabled();
void setEnabled(boolean enabled);
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/GuiDraw.java b/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/GuiDraw.java
index f95927392f0..dd516c1a558 100644
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/GuiDraw.java
+++ b/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/GuiDraw.java
@@ -3,7 +3,9 @@
import com.gregtechceu.gtceu.api.mui.drawable.text.TextRenderer;
import com.gregtechceu.gtceu.api.mui.utils.Alignment;
import com.gregtechceu.gtceu.api.mui.utils.Color;
+import com.gregtechceu.gtceu.api.mui.utils.RectangleF;
import com.gregtechceu.gtceu.api.mui.widget.sizer.Area;
+import com.gregtechceu.gtceu.client.GuiSpriteManager;
import com.gregtechceu.gtceu.client.mui.screen.RichTooltip;
import com.gregtechceu.gtceu.client.mui.screen.event.RichTooltipEvent;
import com.gregtechceu.gtceu.client.mui.screen.viewport.GuiContext;
@@ -18,6 +20,7 @@
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
+import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
@@ -52,6 +55,7 @@
import java.util.List;
import java.util.function.BiConsumer;
+import static com.gregtechceu.gtceu.api.mui.drawable.UITexture.GUI_TEXTURE_ID_CONVERTER;
import static net.minecraft.util.Mth.HALF_PI;
import static net.minecraft.util.Mth.TWO_PI;
@@ -188,7 +192,7 @@ public static void drawRoundedRect(GuiGraphics graphics, float x0, float y0, flo
for (int i = 1; i <= segments; i++) {
float x = x0 + cornerRadius - Mth.cos(HALF_PI / segments * i) * cornerRadius;
float y = y1 - cornerRadius + Mth.sin(HALF_PI / segments * i) * cornerRadius;
- bufferbuilder.vertex(x, y, 0.0f)
+ bufferbuilder.vertex(pose, x, y, 0.0f)
.color(Color.getRed(colorBL), Color.getGreen(colorBL), Color.getBlue(colorBL),
Color.getAlpha(colorBL))
.endVertex();
@@ -237,10 +241,57 @@ public static void drawRoundedRect(GuiGraphics graphics, float x0, float y0, flo
.endVertex();
}
+ /**
+ * Set up the texture as a sampler differently depending on if it's part of the GUI atlas or not.
+ *
+ * If the texture is part of the GUI atlas, the atlas will be used for drawing and the UV coordinates will be scaled
+ * to the atlas texture.
+ * If it's not part of the GUI atlas, nothing special is done.
+ *
+ * @param location the texture file's location, e.g. {@code "modularui:textures/gui/slot/item.png"}
+ * @param u0 u0 UV coordinate
+ * @param v0 v0 UV coordinate
+ * @param u1 u1 UV coordinate
+ * @param v1 v1 UV coordinate
+ * @return If texture is in the GUI atlas, rescaled UV coordinates {@code u0, v0, u1, v1}.
+ * If not, the same coordinates that were passed in.
+ */
+ public static RectangleF setupTexture(ResourceLocation location, float u0, float v0, float u1, float v1) {
+ TextureAtlasSprite sprite = GuiSpriteManager.getInstance()
+ .getSprite(GUI_TEXTURE_ID_CONVERTER.fileToId(location));
+
+ // check if the atlas doesn't have this sprite, default to using the resloc as is if so
+ if (!sprite.contents().name().equals(MissingTextureAtlasSprite.getLocation())) {
+ RenderSystem.setShaderTexture(0, sprite.atlasLocation());
+
+ // have to multiply by 16 here because of MC weirdness
+ // REMOVE THE MULTIPLICATION IN 1.21!!!
+ return new RectangleF(sprite.getU(u0 * 16), sprite.getV(v0 * 16), sprite.getU(u1 * 16),
+ sprite.getV(v1 * 16));
+ } else {
+ RenderSystem.setShaderTexture(0, location);
+ return new RectangleF(u0, v0, u1, v1);
+ }
+ }
+
+ public static boolean isGuiAtlasSprite(ResourceLocation location) {
+ location = GUI_TEXTURE_ID_CONVERTER.fileToId(location);
+ return GuiSpriteManager.getInstance().getSprite(location).atlasLocation() !=
+ MissingTextureAtlasSprite.getLocation();
+ }
+
public static void drawTexture(Matrix4f pose, ResourceLocation location, float x, float y, float w, float h,
int u, int v, int textureWidth, int textureHeight) {
- RenderSystem.setShaderTexture(0, location);
- drawTexture(pose, x, y, u, v, w, h, textureWidth, textureHeight);
+ if (!isGuiAtlasSprite(location)) {
+ RenderSystem.setShaderTexture(0, location);
+ drawTexture(pose, x, y, u, v, w, h, textureWidth, textureHeight);
+ return;
+ }
+
+ float tw = 1F / textureWidth;
+ float th = 1F / textureHeight;
+ RectangleF newUvs = setupTexture(location, u * tw, v * th, (u + w) * tw, (v + h) * th);
+ drawTexture(pose, x, y, x + w, y + h, newUvs.u0(), newUvs.v0(), newUvs.u1(), newUvs.v1());
}
public static void drawTexture(Matrix4f pose, float x, float y, int u, int v, float w, float h,
@@ -308,14 +359,14 @@ public static void drawTexture(Matrix4f pose, ResourceLocation location, float x
public static void drawTexture(Matrix4f pose, ResourceLocation location, float x0, float y0, float x1, float y1,
float u0, float v0, float u1, float v1, boolean withBlend) {
- RenderSystem.setShaderTexture(0, location);
+ RectangleF newUvs = setupTexture(location, u0, v0, u1, v1);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
if (withBlend) {
RenderSystem.enableBlend();
} else {
RenderSystem.disableBlend();
}
- drawTexture(pose, x0, y0, x1, y1, u0, v0, u1, v1, 0);
+ drawTexture(pose, x0, y0, x1, y1, newUvs.u0(), newUvs.v0(), newUvs.u1(), newUvs.v1(), 0);
}
public static void drawTexture(Matrix4f pose, float x0, float y0, float x1, float y1,
@@ -342,9 +393,19 @@ public static void drawTexture(Matrix4f pose, VertexConsumer buffer, float x0, f
}
public static void drawTiledTexture(Matrix4f pose, ResourceLocation location, float x, float y, float w, float h,
- int u, int v, int tileW, int tileH, int tw, int th, float z) {
- RenderSystem.setShaderTexture(0, location);
- drawTiledTexture(pose, x, y, w, h, u, v, tileW, tileH, tw, th, z);
+ int u, int v, int tileWidth, int tileHeight, int textureWidth,
+ int textureHeight, float z) {
+ if (!isGuiAtlasSprite(location)) {
+ RenderSystem.setShaderTexture(0, location);
+ drawTiledTexture(pose, x, y, w, h, u, v, tileWidth, tileHeight, textureWidth, textureHeight, z);
+ return;
+ }
+
+ float wRatio = 1f / textureWidth;
+ float hRatio = 1f / textureHeight;
+ RectangleF newUvs = setupTexture(location, u * wRatio, v * hRatio, (u + w) * wRatio, (v + h) * hRatio);
+ drawTiledTexture(pose, x, y, x + w, y + h, newUvs.u0(), newUvs.v0(),
+ newUvs.u1(), newUvs.v1(), tileWidth, tileHeight, z);
}
public static void drawTiledTexture(Matrix4f pose, float x, float y, float w, float h,
@@ -376,8 +437,9 @@ public static void drawTiledTexture(Matrix4f pose, ResourceLocation location, fl
float u0, float v0, float u1, float v1,
int textureWidth, int textureHeight, float z) {
RenderSystem.enableBlend();
- RenderSystem.setShaderTexture(0, location);
- drawTiledTexture(pose, x, y, w, h, u0, v0, u1, v1, textureWidth, textureHeight, z);
+ RectangleF newUvs = setupTexture(location, u0, v0, u1, v1);
+ drawTiledTexture(pose, x, y, w, h, newUvs.u0(), newUvs.v0(), newUvs.u1(), newUvs.v1(), textureWidth,
+ textureHeight, z);
RenderSystem.disableBlend();
}
@@ -641,7 +703,7 @@ public static void drawStandardSlotAmountText(GuiContext context, int amount, St
public static void drawAmountText(ModularGuiContext context, int amount, String format,
int x, int y, int width, int height, Alignment alignment, float z) {
- if (amount == 1) return;
+ if (amount <= 1) return;
String amountText = FormattingUtil.formatNumberReadable(amount, false);
if (format != null) {
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/UITexture.java b/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/UITexture.java
index 302673bcf07..d03ee52243f 100644
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/UITexture.java
+++ b/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/UITexture.java
@@ -10,6 +10,7 @@
import com.gregtechceu.gtceu.client.mui.screen.viewport.GuiContext;
import com.gregtechceu.gtceu.utils.serialization.json.JsonHelper;
+import net.minecraft.resources.FileToIdConverter;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -24,6 +25,7 @@
public class UITexture implements IDrawable, IJsonSerializable {
public static final UITexture DEFAULT = fullImage("gui/options_background", ColorType.DEFAULT);
+ public static final FileToIdConverter GUI_TEXTURE_ID_CONVERTER = new FileToIdConverter("textures/gui", ".png");
private static final ResourceLocation ICONS_LOCATION = GTCEu.id("textures/gui/icons.png");
@@ -174,6 +176,11 @@ public void drawSubArea(GuiContext context, float x, float y, float width, float
lerpV(vEnd), this.nonOpaque);
}
+ @Override
+ public boolean canApplyTheme() {
+ return this.colorType != null;
+ }
+
@Override
public void applyColor(int themeColor) {
if (this.colorOverride != 0) {
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/text/RichTextCompiler.java b/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/text/RichTextCompiler.java
index 2325539690d..4228dd5dee1 100644
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/text/RichTextCompiler.java
+++ b/src/main/java/com/gregtechceu/gtceu/api/mui/drawable/text/RichTextCompiler.java
@@ -126,7 +126,14 @@ private void compileString(String text) {
if (i == 0) {
// doesn't fit at the end of the line, try new line
if (this.x > 0) i = fr.getSplitter().plainIndexAtWidth(subText, this.maxWidth, Style.EMPTY);
- if (i == 0) throw new IllegalStateException("No space for string '" + subText + "'");
+ if (i <= 0) {
+ i = 1; // force at least one char
+ if (subText.charAt(0) == '\u00a7' && subText.length() > 1) {
+ // include format char if it is one
+ i++;
+ if (subText.length() > 2) i++;
+ }
+ }
newLine();
} else if (i < subText.length()) {
// the whole string doesn't fit
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/factory/ClientGUI.java b/src/main/java/com/gregtechceu/gtceu/api/mui/factory/ClientGUI.java
index f5864255ea2..19eb36af969 100644
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/factory/ClientGUI.java
+++ b/src/main/java/com/gregtechceu/gtceu/api/mui/factory/ClientGUI.java
@@ -3,8 +3,8 @@
import com.gregtechceu.gtceu.api.mui.base.MCHelper;
import com.gregtechceu.gtceu.client.mui.screen.ModularContainerMenu;
import com.gregtechceu.gtceu.client.mui.screen.ModularScreen;
+import com.gregtechceu.gtceu.client.mui.screen.RecipeViewerSettingsImpl;
import com.gregtechceu.gtceu.client.mui.screen.UISettings;
-import com.gregtechceu.gtceu.client.mui.screen.XeiSettingsImpl;
import net.minecraft.client.gui.screens.Screen;
import net.minecraftforge.api.distmarker.Dist;
@@ -36,11 +36,11 @@ public static void open(@NotNull ModularScreen screen) {
* Opens a modular screen on the next client tick with custom jei settings.
* It needs to be opened in next tick, because we might break the current GUI if we open it now.
*
- * @param screen new modular screen
- * @param jeiSettings custom jei settings
+ * @param screen new modular screen
+ * @param recipeViewerSettings custom jei settings
*/
- public static void open(@NotNull ModularScreen screen, @NotNull XeiSettingsImpl jeiSettings) {
- GuiManager.openScreen(screen, new UISettings(jeiSettings));
+ public static void open(@NotNull ModularScreen screen, @NotNull RecipeViewerSettingsImpl recipeViewerSettings) {
+ GuiManager.openScreen(screen, new UISettings(recipeViewerSettings));
}
/**
@@ -57,16 +57,16 @@ public static void open(@NotNull ModularScreen screen, @Nullable IntFunction container) {
- UISettings settings = new UISettings(jeiSettings);
+ UISettings settings = new UISettings(recipeViewerSettings);
settings.customContainer(container);
GuiManager.openScreen(screen, settings);
}
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/factory/GuiManager.java b/src/main/java/com/gregtechceu/gtceu/api/mui/factory/GuiManager.java
index b556deee40c..330056f2da9 100644
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/factory/GuiManager.java
+++ b/src/main/java/com/gregtechceu/gtceu/api/mui/factory/GuiManager.java
@@ -3,8 +3,8 @@
import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.mui.base.IMuiScreen;
import com.gregtechceu.gtceu.api.mui.base.MCHelper;
+import com.gregtechceu.gtceu.api.mui.base.RecipeViewerSettings;
import com.gregtechceu.gtceu.api.mui.base.UIFactory;
-import com.gregtechceu.gtceu.api.mui.base.XeiSettings;
import com.gregtechceu.gtceu.api.mui.value.sync.ModularSyncManager;
import com.gregtechceu.gtceu.api.mui.value.sync.PanelSyncManager;
import com.gregtechceu.gtceu.api.mui.widget.WidgetTree;
@@ -72,7 +72,7 @@ public static void open(@NotNull UIFactory factory, @NotN
if (player instanceof FakePlayer || openedContainers.contains(player)) return;
openedContainers.add(player);
// create panel, collect sync handlers and create menu
- UISettings settings = new UISettings(XeiSettings.DUMMY);
+ UISettings settings = new UISettings(RecipeViewerSettings.DUMMY);
settings.defaultCanInteractWith(factory, guiData);
ModularSyncManager msm = new ModularSyncManager(false);
PanelSyncManager syncManager = new PanelSyncManager(msm, true);
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/factory/PlayerInventoryUIFactory.java b/src/main/java/com/gregtechceu/gtceu/api/mui/factory/PlayerInventoryUIFactory.java
index cd1bec52668..0fb895f32ad 100644
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/factory/PlayerInventoryUIFactory.java
+++ b/src/main/java/com/gregtechceu/gtceu/api/mui/factory/PlayerInventoryUIFactory.java
@@ -33,7 +33,7 @@ public void openFromHand(Player player, InteractionHand hand) {
public void openFromCurios(Player player, String type, int index) {
if (!GTCEu.Mods.isCuriosLoaded()) {
- throw new IllegalArgumentException("Can't open UI for curios item when bauble is not loaded!");
+ throw new IllegalArgumentException("Can't open UI for curio item when curios is not loaded!");
}
GuiManager.open(
this, PlayerInventoryGuiData.of(player, InventoryTypes.CURIOS, type, index), verifyServerSide(player));
@@ -59,7 +59,7 @@ public void openFromHandClient(InteractionHand hand) {
@SideOnly(Side.CLIENT)
public void openFromCuriosClient(String type, int index) {
if (!GTCEu.Mods.isCuriosLoaded()) {
- throw new IllegalArgumentException("Can't open UI for baubles item when bauble is not loaded!");
+ throw new IllegalArgumentException("Can't open UI for curio item when curios is not loaded!");
}
GuiManager.openFromClient(
this, PlayerInventoryGuiData.of(MCHelper.getPlayer(), InventoryTypes.CURIOS, type, index));
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/DebugOverlay.java b/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/DebugOverlay.java
index 1db715f8ffe..c1fc2ccd812 100644
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/DebugOverlay.java
+++ b/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/DebugOverlay.java
@@ -4,6 +4,7 @@
import com.gregtechceu.gtceu.api.mui.base.IMuiScreen;
import com.gregtechceu.gtceu.api.mui.base.drawable.IIcon;
import com.gregtechceu.gtceu.api.mui.base.drawable.IKey;
+import com.gregtechceu.gtceu.api.mui.base.value.IBoolValue;
import com.gregtechceu.gtceu.api.mui.base.widget.IWidget;
import com.gregtechceu.gtceu.api.mui.drawable.NamedDrawableRow;
import com.gregtechceu.gtceu.api.mui.drawable.Rectangle;
@@ -24,6 +25,8 @@
import org.jetbrains.annotations.NotNull;
+import java.lang.reflect.Field;
+
public class DebugOverlay extends CustomModularScreen {
private static final IIcon CHECKMARK = GTGuiTextures.CHECK_BOX.asIcon().size(8);
@@ -47,8 +50,9 @@ public DebugOverlay(IMuiScreen screen) {
.background(
new Rectangle()
.color(Color.withAlpha(
- Long.decode(ConfigHolder.INSTANCE.dev.mui.outlineColor).intValue(),
- 0.4f)))
+ Color.parseString(ConfigHolder.INSTANCE.dev.mui.outlineColor),
+ 0.4f))
+ .cornerRadius(4))
.disableHoverBackground()
.overlay(IKey.str("Debug Options"))
.openUp()
@@ -83,18 +87,12 @@ public DebugOverlay(IMuiScreen screen) {
.child(new ListWidget<>()
.maxSize(100)
.widthRel(1f)
- .child(toggleOption(0, "Any",
- ConfigHolder.INSTANCE.dev.mui.showHovered))
- .child(toggleOption(1, "Pos",
- ConfigHolder.INSTANCE.dev.mui.showPos))
- .child(toggleOption(2, "Size",
- ConfigHolder.INSTANCE.dev.mui.showSize))
- .child(toggleOption(3, "Widget Theme",
- ConfigHolder.INSTANCE.dev.mui.showWidgetTheme))
- .child(toggleOption(4, "Extra info",
- ConfigHolder.INSTANCE.dev.mui.showExtra))
- .child(toggleOption(5, "Outline",
- ConfigHolder.INSTANCE.dev.mui.showOutline)))))
+ .child(toggleOption(0, "Any", "showHovered"))
+ .child(toggleOption(1, "Pos", "showPos"))
+ .child(toggleOption(2, "Size", "showSize"))
+ .child(toggleOption(3, "Widget Theme", "showWidgetTheme"))
+ .child(toggleOption(4, "Extra info", "showExtra"))
+ .child(toggleOption(5, "Outline", "showOutline")))))
.child(new ContextMenuButton<>("menu_parent_hover_info")
.name("menu_button_parent_hover_info")
.height(10)
@@ -108,25 +106,43 @@ public DebugOverlay(IMuiScreen screen) {
.child(new ListWidget<>()
.maxSize(100)
.widthRel(1f)
- .child(toggleOption(10, "Any",
- ConfigHolder.INSTANCE.dev.mui.showParent))
- .child(toggleOption(11, "Pos",
- ConfigHolder.INSTANCE.dev.mui.showParentPos))
- .child(toggleOption(12, "Size",
- ConfigHolder.INSTANCE.dev.mui.showParentSize))
+ .child(toggleOption(10, "Any", "showParent"))
+ .child(toggleOption(11, "Pos", "showParentPos"))
+ .child(toggleOption(12, "Size", "showParentSize"))
.child(toggleOption(13, "Widget Theme",
- ConfigHolder.INSTANCE.dev.mui.showParentWidgetTheme))
- .child(toggleOption(14, "Outline",
- ConfigHolder.INSTANCE.dev.mui.showParentOutline)))))));
+ "showParentWidgetTheme"))
+ .child(toggleOption(14, "Outline", "showParentOutline")))))));
}
- public static IWidget toggleOption(int i, String name, boolean boolValue) {
+ public static IWidget toggleOption(int i, String name, String field) {
+ ConfigHolder.DeveloperConfigs.MuiConfigs c = ConfigHolder.INSTANCE.dev.mui;
+ Field f;
+ try {
+ f = c.getClass().getField(field);
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ }
+
+ IBoolValue> val = new BoolValue.Dynamic(() -> {
+ try {
+ return (boolean) f.get(c);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }, v -> {
+ try {
+ f.set(c, v);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ });
+
return new ToggleButton()
.name("hover_info_toggle" + i)
.invisible()
.widthRel(1f)
.height(12)
- .value(new BoolValue(boolValue))
+ .value(val)
.overlay(true, new NamedDrawableRow()
.name(IKey.str(name))
.drawable(CHECKMARK))
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/OverlayHandler.java b/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/OverlayHandler.java
deleted file mode 100644
index 5dc8a02b908..00000000000
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/OverlayHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.gregtechceu.gtceu.api.mui.overlay;
-
-import com.gregtechceu.gtceu.client.mui.screen.ModularScreen;
-
-import net.minecraft.client.gui.screens.Screen;
-
-import org.jetbrains.annotations.ApiStatus;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.function.Function;
-import java.util.function.Predicate;
-
-@Deprecated
-@ApiStatus.ScheduledForRemoval(inVersion = "3.2.0")
-public class OverlayHandler implements Comparable {
-
- private final Predicate test;
- private final Function overlayFunction;
- private final int priority;
-
- public OverlayHandler(Predicate test, Function overlayFunction) {
- this(test, overlayFunction, 1000);
- }
-
- public OverlayHandler(Predicate test, Function overlayFunction, int priority) {
- this.test = test;
- this.overlayFunction = overlayFunction;
- this.priority = priority;
- }
-
- public boolean isValidFor(Screen screen) {
- return this.test.test(screen);
- }
-
- public ModularScreen createOverlay(Screen screen) {
- return this.overlayFunction.apply(screen);
- }
-
- @Override
- public int compareTo(@NotNull OverlayHandler o) {
- return Integer.compare(this.priority, o.priority);
- }
-}
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/OverlayManager.java b/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/OverlayManager.java
deleted file mode 100644
index 5ee7d296c0e..00000000000
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/OverlayManager.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.gregtechceu.gtceu.api.mui.overlay;
-
-import com.gregtechceu.gtceu.GTCEu;
-
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.fml.common.Mod;
-
-import org.jetbrains.annotations.ApiStatus;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Deprecated
-@ApiStatus.ScheduledForRemoval(inVersion = "3.2.0")
-@Mod.EventBusSubscriber(modid = GTCEu.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
-public class OverlayManager {
-
- public static final List overlays = new ArrayList<>();
-
- public static void register(OverlayHandler handler) {
- if (!overlays.contains(handler)) {
- overlays.add(handler);
- overlays.sort(OverlayHandler::compareTo);
- }
- }
-}
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/OverlayStack.java b/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/OverlayStack.java
index 819cb07fbc5..1a8fe2c3325 100644
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/OverlayStack.java
+++ b/src/main/java/com/gregtechceu/gtceu/api/mui/overlay/OverlayStack.java
@@ -18,7 +18,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -124,15 +123,6 @@ public static boolean isHoveringOverlay() {
public static void onOpenScreen(Screen newScreen) {
closeAll();
if (newScreen != null) {
- // backwards compat
- for (OverlayHandler handler : OverlayManager.overlays) {
- if (handler.isValidFor(newScreen)) {
- ModularScreen overlay = Objects.requireNonNull(handler.createOverlay(newScreen),
- "Overlays must not be null!");
- overlay.constructOverlay(newScreen);
- OverlayStack.open(overlay);
- }
- }
OpenScreenEvent event = new OpenScreenEvent(newScreen);
MinecraftForge.EVENT_BUS.post(event);
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/schema/ArraySchema.java b/src/main/java/com/gregtechceu/gtceu/api/mui/schema/ArraySchema.java
index b0719cde521..786fc5af0c0 100644
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/schema/ArraySchema.java
+++ b/src/main/java/com/gregtechceu/gtceu/api/mui/schema/ArraySchema.java
@@ -171,12 +171,13 @@ public Builder where(char c, Block block) {
return where(c, block.defaultBlockState());
}
+ public Builder where(char c, String registryName) {
+ return where(c, new ResourceLocation(registryName));
+ }
+
public Builder where(char c, ResourceLocation registryName) {
- Optional block = BuiltInRegistries.BLOCK.getOptional(registryName);
- if (block.isEmpty()) {
- throw new IllegalArgumentException(registryName + " isn't a valid block");
- }
- return where(c, block.get());
+ return where(c, BuiltInRegistries.BLOCK.getOptional(registryName)
+ .orElseThrow(() -> new IllegalArgumentException(registryName + " isn't a valid block")));
}
private void validate() {
diff --git a/src/main/java/com/gregtechceu/gtceu/api/mui/theme/ThemeManager.java b/src/main/java/com/gregtechceu/gtceu/api/mui/theme/ThemeManager.java
index 003dd3d44a8..7a3e7e26815 100644
--- a/src/main/java/com/gregtechceu/gtceu/api/mui/theme/ThemeManager.java
+++ b/src/main/java/com/gregtechceu/gtceu/api/mui/theme/ThemeManager.java
@@ -7,7 +7,7 @@
import com.gregtechceu.gtceu.utils.serialization.json.JsonBuilder;
import com.gregtechceu.gtceu.utils.serialization.json.JsonHelper;
-import net.minecraft.resources.FileToIdConverter;
+import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
@@ -34,13 +34,23 @@
public class ThemeManager extends SimplePreparableReloadListener