Skip to content

Commit

Permalink
Sync with Framework (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotRyken committed Nov 3, 2024
1 parent d33ba65 commit 408d950
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 64 deletions.
6 changes: 5 additions & 1 deletion buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ repositories {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
maven {
name = "isXander"
url = "https://maven.isxander.dev/releases"
}
}

// Declare capabilities on the outgoing configurations.
Expand Down Expand Up @@ -120,7 +124,7 @@ processResources {
// Dependencies
"yacl_versions_fabric_list": asJsonList(yacl_versions_fabric),
"yacl_versions_neoforge": yacl_versions_neoforge,
"modmenu_versions_fabric_list": asJsonList(modmenu_versions),
"modmenu_versions_fabric_list": asJsonList(modmenu_versions_fabric),
]
filesMatching(["pack.mcmeta", "*.mod.json", "META-INF/*mods.toml", "*.mixins.json"]) {
expand expandProps
Expand Down
1 change: 0 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
- Initial full release
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}")

// Mod dependencies use NeoForge version to avoid remapping complications
implementation("maven.modrinth:1eAoo2KR:${yacl_version_neoforge}")
api("dev.isxander:yet-another-config-lib:${yacl_version}-neoforge")
}

neoForge {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,54 +20,57 @@
package dev.terminalmc.autoreconnectrf.gui.screen;

import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.MultiLineTextWidget;
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;

import static dev.terminalmc.autoreconnectrf.util.Localization.localized;

/**
* <p>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.</p>
* 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();
Expand All @@ -80,8 +83,5 @@ public void init() {
.build();
addRenderableWidget(exitButton);
}

@Override
protected void addOptions() {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

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<T extends GuiEventListener & Renderable & NarratableEntry> {
// Inexplicably, NeoForge crashes claiming "java.lang.NoClassDefFoundError:
// dev.terminalmc.autoreconnectrf.mixin.MixinDisconnectedScreen is invalid"
// if this mixin is removed.
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public static Optional<Button> findBackButton(Screen screen) {
public static void countdownCallback(Button reconnectButton, int seconds) {
if (seconds < 0) {
// indicates that we're out of attempts
reconnectButton.setMessage(localized("message", "reconnect_failed")
reconnectButton.setMessage(localized("message", "reconnectFailed")
.withStyle(s -> s.withColor(ChatFormatting.RED)));
reconnectButton.active = false;
} else {
reconnectButton.setMessage(localized("message", "reconnect_in", seconds)
reconnectButton.setMessage(localized("message", "reconnectIn", seconds)
.withStyle(s -> s.withColor(ChatFormatting.GREEN)));
}
}
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# https://docs.neoforged.net/docs/advanced/accesstransformers/
# https://docs.neoforged.net/docs/advanced/accesstransformers
12 changes: 5 additions & 7 deletions common/src/main/resources/assets/autoreconnectrf/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"screen.autoreconnectrf.default": "AutoReconnect",
"screen.autoreconnectrf.options": "AutoReconnect Options",
"autoreconnectrf.name": "AutoReconnect",

"message.autoreconnectrf.install_yacl": "Install Yet Another Config Lib (YACL) to access mod options.",
"message.autoreconnectrf.go_modrinth": "View on Modrinth",
"message.framework.viewModrinth": "View on Modrinth",
"message.framework.installYacl": "Install Yet Another Config Lib to access mod options",

"message.autoreconnectrf.reconnect": "Reconnect",
"message.autoreconnectrf.reconnect_in": "Reconnect in %d...",
"message.autoreconnectrf.reconnect_failed": "Could not reconnect!",
"message.autoreconnectrf.reconnectIn": "Reconnect in %d...",
"message.autoreconnectrf.reconnectFailed": "Could not reconnect!",

"option.autoreconnectrf.attempts": "Attempts",
"option.autoreconnectrf.attempts.delays": "Delays",
Expand All @@ -26,7 +25,6 @@
"option.autoreconnectrf.conditions.patterns.tooltip": "Regex patterns to check against the disconnect reason string, to determine whether to reconnect.\n\nLast disconnect reason string:\n%s",
"option.autoreconnectrf.conditions.last.none": "[None]",


"option.autoreconnectrf.messages": "AutoMessages",
"option.autoreconnectrf.messages.tooltip": "Messages to send after a successful automatic reconnect.",
"option.autoreconnectrf.messages.instance": "AutoMessages Object %d",
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/resources/autoreconnectrf.accesswidener
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
accessWidener v1 named
accessWidener v2 named
# https://fabricmc.net/wiki/tutorial:accesswideners
7 changes: 4 additions & 3 deletions common/src/main/resources/autoreconnectrf.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
"refmap": "${mod_id}.refmap.json",
"compatibilityLevel": "JAVA_${java_version}",
"mixins": [
"accessor.DisconnectedScreenAccessor",
"accessor.YACLScreenAccessor"
],
"client": [
"MixinClientPacketListener",
"MixinConnectScreen",
"MixinDisconnectedRealmsScreen",
"MixinDisconnectedScreen",
"MixinMinecraft",
"MixinRealmsConnect"
"MixinRealmsConnect",
"accessor.DisconnectedScreenAccessor",
"accessor.ScreenAccessor",
"accessor.YACLScreenAccessor"
],
"server": [
],
Expand Down
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_api_version}")

modImplementation("maven.modrinth:mOgUt4GM:${modmenu_version}")
modImplementation("maven.modrinth:1eAoo2KR:${yacl_version_fabric}")
modApi("dev.isxander:yet-another-config-lib:${yacl_version}-fabric")
}

loom {
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"custom": {
"modmenu": {
"links": {
"Contact": "${contact_url}"
"Contact": "${contact_url}"
}
},
"formatSpec": {
Expand Down
17 changes: 4 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ sources_url=https://github.com/TerminalMC/AutoReconnect
issues_url=https://github.com/TerminalMC/AutoReconnect/issues
contact_url=https://terminalmc.dev

# Environment
mod_environment=client

# Java
java_version=21
java_versions_fabric=>=21
Expand Down Expand Up @@ -48,20 +45,14 @@ neoforge_versions=[21.0.143, 22)
# NeoForm https://projects.neoforged.net/neoforged/neoform
neoform_version=1.21-20240613.152323

# Cloth Config https://modrinth.com/mod/9s6osm5g/versions
clothconfig_version=15.0.140
clothconfig_versions_fabric=>=15
clothconfig_versions_neoforge=[15,)

# YACL https://modrinth.com/mod/1eAoo2KR/versions
yacl_version_fabric=3.5.0+1.21-fabric
yacl_version_neoforge=3.5.0+1.21-neoforge
yacl_versions_fabric=>=3.5.0
yacl_versions_neoforge=[3.5.0,)
yacl_version=3.6.1+1.21
yacl_versions_fabric=>=3.6.1
yacl_versions_neoforge=[3.6.1,)

# ModMenu https://modrinth.com/mod/mOgUt4GM/versions
modmenu_version=11.0.2
modmenu_versions=>10
modmenu_versions_fabric=>10

# GitHub, Modrinth, CurseForge releases
# Plural properties expect CSV lists
Expand Down
2 changes: 1 addition & 1 deletion neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

dependencies {
implementation("maven.modrinth:1eAoo2KR:${yacl_version_neoforge}")
api("dev.isxander:yet-another-config-lib:${yacl_version}-neoforge")
}

neoForge {
Expand Down
12 changes: 6 additions & 6 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ issueTrackerURL="${issues_url}" #optional:none
displayURL="${homepage_url}" #optional: none
#displayTest="" #optional:"MATCH_VERSION"

[[mixins]]
config="${mod_id}.mixins.json"
[[mixins]]
config="${mod_id}.neoforge.mixins.json"

[[dependencies."${mod_id}"]]
modId="minecraft"
#type="" #optional:"required" #options:"required","optional","incompatible","discouraged"
Expand All @@ -30,11 +35,6 @@ issueTrackerURL="${issues_url}" #optional:none
#side="" #optional:"BOTH" #options:"CLIENT","SERVER","BOTH"
#referralUrl="" #optional:none

[[mixins]]
config="${mod_id}.mixins.json"
[[mixins]]
config="${mod_id}.neoforge.mixins.json"

[[dependencies."${mod_id}"]]
modId="neoforge"
versionRange="${neoforge_versions}"
Expand All @@ -47,4 +47,4 @@ issueTrackerURL="${issues_url}" #optional:none
side="CLIENT"

# https://docs.neoforged.net/docs/gettingstarted/modfiles/#modstoml
# https://docs.neoforged.net/docs/misc/updatechecker/
# https://docs.neoforged.net/docs/misc/updatechecker
8 changes: 4 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ pluginManagement {
}
exclusiveContent {
forRepositories(
maven {
name = "NeoForge"
url = "https://maven.neoforged.net/releases"
}
maven {
name = "NeoForge"
url = "https://maven.neoforged.net/releases"
}
)
filter { includeGroupAndSubgroups("net.neoforged.licenser") }
}
Expand Down

0 comments on commit 408d950

Please sign in to comment.