Wraps {@link YaclScreenProvider} and provides a backup screen for use when
- * the YACL mod is not loaded. This allows the dependency on YACL to be defined
- * as optional.
+ * Wraps the config screen implementation and provides a backup screen for
+ * use when the config lib mod is not loaded. This allows the dependency to be
+ * defined as optional.
*/
public class ConfigScreenProvider {
public static Screen getConfigScreen(Screen parent) {
try {
return YaclScreenProvider.getConfigScreen(parent);
- }
- catch (NoClassDefFoundError ignored) {
- return new BackupScreen(parent);
+ } catch (NoClassDefFoundError ignored) {
+ return new BackupScreen(parent, "installYacl", "https://modrinth.com/mod/1eAoo2KR");
}
}
- static class BackupScreen extends OptionsSubScreen {
- public BackupScreen(Screen parent) {
- super(parent, Minecraft.getInstance().options, localized("screen", "default"));
+ static class BackupScreen extends Screen {
+ private final Screen parent;
+ private final String modKey;
+ private final String modUrl;
+
+ public BackupScreen(Screen parent, String modKey, String modUrl) {
+ super(localized("name"));
+ this.parent = parent;
+ this.modKey = modKey;
+ this.modUrl = modUrl;
}
@Override
public void init() {
MultiLineTextWidget messageWidget = new MultiLineTextWidget(
width / 2 - 120, height / 2 - 40,
- localized("message", "install_yacl"),
+ localized("message", modKey),
minecraft.font);
messageWidget.setMaxWidth(240);
messageWidget.setCentered(true);
addRenderableWidget(messageWidget);
- String link = "https://modrinth.com/mod/1eAoo2KR";
- Button openLinkButton = Button.builder(localized("message", "go_modrinth"),
+ Button openLinkButton = Button.builder(localized("message", "viewModrinth"),
(button) -> minecraft.setScreen(new ConfirmLinkScreen(
(open) -> {
- if (open) Util.getPlatform().openUri(link);
- minecraft.setScreen(lastScreen);
- }, link, true)))
+ if (open) Util.getPlatform().openUri(modUrl);
+ minecraft.setScreen(parent);
+ }, modUrl, true)))
.pos(width / 2 - 120, height / 2)
.size(115, 20)
.build();
@@ -80,8 +83,5 @@ public void init() {
.build();
addRenderableWidget(exitButton);
}
-
- @Override
- protected void addOptions() {}
}
}
diff --git a/common/src/main/java/dev/terminalmc/autoreconnectrf/gui/screen/YaclScreenProvider.java b/common/src/main/java/dev/terminalmc/autoreconnectrf/gui/screen/YaclScreenProvider.java
index b67d748..c5da1eb 100644
--- a/common/src/main/java/dev/terminalmc/autoreconnectrf/gui/screen/YaclScreenProvider.java
+++ b/common/src/main/java/dev/terminalmc/autoreconnectrf/gui/screen/YaclScreenProvider.java
@@ -59,7 +59,7 @@ static Screen getConfigScreen(Screen parent) {
Config.Options options = Config.get().options;
YetAnotherConfigLib.Builder builder = YetAnotherConfigLib.createBuilder()
- .title(localized("screen", "options"))
+ .title(localized("name"))
.save(Config::save);
// Attempts
diff --git a/common/src/main/java/dev/terminalmc/autoreconnectrf/mixin/accessor/ScreenAccessor.java b/common/src/main/java/dev/terminalmc/autoreconnectrf/mixin/accessor/ScreenAccessor.java
new file mode 100644
index 0000000..5d5f9ef
--- /dev/null
+++ b/common/src/main/java/dev/terminalmc/autoreconnectrf/mixin/accessor/ScreenAccessor.java
@@ -0,0 +1,33 @@
+/*
+ * AutoReconnect
+ * Copyright (C) 2023 Bstn1802
+ * Copyright (C) 2024 TerminalMC
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package dev.terminalmc.autoreconnectrf.mixin.accessor;
+
+import net.minecraft.client.gui.components.Renderable;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.gui.narration.NarratableEntry;
+import net.minecraft.client.gui.screens.Screen;
+import org.spongepowered.asm.mixin.Mixin;
+
+@Mixin(Screen.class)
+public interface ScreenAccessor {
+ // Inexplicably, NeoForge crashes claiming "java.lang.NoClassDefFoundError:
+ // dev.terminalmc.autoreconnectrf.mixin.MixinDisconnectedScreen is invalid"
+ // if this mixin is removed.
+}
\ No newline at end of file
diff --git a/common/src/main/java/dev/terminalmc/autoreconnectrf/util/ScreenMixinUtil.java b/common/src/main/java/dev/terminalmc/autoreconnectrf/util/ScreenMixinUtil.java
index cc7706c..5545032 100644
--- a/common/src/main/java/dev/terminalmc/autoreconnectrf/util/ScreenMixinUtil.java
+++ b/common/src/main/java/dev/terminalmc/autoreconnectrf/util/ScreenMixinUtil.java
@@ -103,11 +103,11 @@ public static Optional