From 406cf5dd7e8999691619165c01ee4c40723560fa Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Tue, 2 Jul 2024 23:22:15 -0700 Subject: [PATCH 1/3] fix minimap incompatible screen not always opening --- fabric/src/main/java/xaeroplus/fabric/XaeroPlusFabric.java | 4 ++++ .../util/compat/XaeroPlusCompatibleMinimapMixinPlugin.java | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fabric/src/main/java/xaeroplus/fabric/XaeroPlusFabric.java b/fabric/src/main/java/xaeroplus/fabric/XaeroPlusFabric.java index d3ec1efe..fc8f4af8 100644 --- a/fabric/src/main/java/xaeroplus/fabric/XaeroPlusFabric.java +++ b/fabric/src/main/java/xaeroplus/fabric/XaeroPlusFabric.java @@ -5,6 +5,7 @@ import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; +import net.fabricmc.loader.api.Version; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import xaeroplus.Globals; @@ -39,6 +40,9 @@ public void onInitializeClient() { // needed as we can either accept Xaero's Minimap or BetterPVP but can't describe this in the fabric.mod.json var versionCheckResult = MinimapBaseVersionCheck.versionCheck(); if (versionCheckResult.minimapCompatible()) return; + XaeroPlus.LOGGER.error("Incompatible Xaero Minimap version detected! Expected: {} Actual: {}", + versionCheckResult.expectedVersion().getFriendlyString(), + versionCheckResult.anyPresentMinimapVersion().map(Version::getFriendlyString).orElse("None!")); var anyPresentVersion = versionCheckResult.minimapVersion().or(versionCheckResult::betterPvpVersion); Minecraft.getInstance().setScreen( new IncompatibleMinimapWarningScreen(anyPresentVersion, versionCheckResult.expectedVersion())); diff --git a/fabric/src/main/java/xaeroplus/fabric/util/compat/XaeroPlusCompatibleMinimapMixinPlugin.java b/fabric/src/main/java/xaeroplus/fabric/util/compat/XaeroPlusCompatibleMinimapMixinPlugin.java index 237ce339..5c3bddc3 100644 --- a/fabric/src/main/java/xaeroplus/fabric/util/compat/XaeroPlusCompatibleMinimapMixinPlugin.java +++ b/fabric/src/main/java/xaeroplus/fabric/util/compat/XaeroPlusCompatibleMinimapMixinPlugin.java @@ -32,7 +32,11 @@ public String getRefMapperConfig() { public boolean shouldApplyMixin(final String targetClassName, final String mixinClassName) { if (FabricLoader.getInstance().getEnvironmentType() != EnvType.CLIENT) return true; if (versionCheckResult.minimapCompatible()) return true; - return !mixinClassName.startsWith("xaeroplus"); + if (mixinClassName.startsWith("xaeroplus")) { + return mixinClassName.contains("MixinMinecraftClientFabric"); + } else { + return true; + } } @Override From 1466dda00632f7016b0210725293f797fda6b922 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Tue, 2 Jul 2024 23:29:49 -0700 Subject: [PATCH 2/3] loom 1.7 --- build.gradle.kts | 2 +- forge/build.gradle.kts | 3 --- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 2 +- settings.gradle.kts | 4 ++-- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 934161e6..298ab4a0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ import net.fabricmc.loom.api.LoomGradleExtensionAPI plugins { id("architectury-plugin") version "3.4-SNAPSHOT" - id("dev.architectury.loom") version "1.6-SNAPSHOT" apply false + id("dev.architectury.loom") version "1.7-SNAPSHOT" apply false id("com.github.johnrengelman.shadow") version "8.1.1" apply false idea } diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index cd8cdfd4..e11694b5 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -17,9 +17,6 @@ loom { mixinConfigs.set(listOf("xaeroplus.mixins.json", "xaeroplus-forge.mixins.json")) convertAccessWideners = true extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name) - mixin { - defaultRefmapName.set("xaeroplus-refmap.json") - } } runs { getByName("client") { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a..a4413138 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a42..b740cf13 100644 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/settings.gradle.kts b/settings.gradle.kts index efe03e09..39c0313b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -34,8 +34,8 @@ dependencyResolutionManagement { library("worldmap-forge", "maven.modrinth:xaeros-world-map:${gradle.extra.get("worldmap_version_forge")}_Forge_1.20") library("minimap-fabric", "maven.modrinth:xaeros-minimap:${gradle.extra.get("minimap_version_fabric")}_Fabric_1.20") library("minimap-forge", "maven.modrinth:xaeros-minimap:${gradle.extra.get("minimap_version_forge")}_Forge_1.20") - library("mixinextras-common", "io.github.llamalad7:mixinextras-common:0.3.5") - library("mixinextras-forge", "io.github.llamalad7:mixinextras-forge:0.3.5") + library("mixinextras-common", "io.github.llamalad7:mixinextras-common:0.3.6") + library("mixinextras-forge", "io.github.llamalad7:mixinextras-forge:0.3.6") library("caffeine", "com.github.ben-manes.caffeine:caffeine:3.1.8") library("lambdaEvents", "net.lenni0451:LambdaEvents:2.4.2") library("waystones-fabric", "maven.modrinth:waystones:14.1.3+fabric-1.20") From a00107d77f329ce36d2fea9b76a2ddc12ca83a02 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Tue, 2 Jul 2024 23:56:16 -0700 Subject: [PATCH 3/3] register ModMenu config screen --- fabric/build.gradle.kts | 2 +- .../java/xaeroplus/fabric/XaeroPlusModMenu.java | 13 +++++++++++++ fabric/src/main/resources/fabric.mod.json | 3 +++ .../main/java/xaeroplus/forge/XaeroPlusForge.java | 8 ++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 fabric/src/main/java/xaeroplus/fabric/XaeroPlusModMenu.java diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index be12fbe1..a5543298 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -45,7 +45,7 @@ dependencies { modImplementation(libs.balm.fabric) modCompileOnly(libs.fabric.waystones) modRuntimeOnly(libs.immediatelyfast) - modRuntimeOnly(libs.modmenu) + modImplementation(libs.modmenu) modCompileOnly(libs.sodium) modRuntimeOnly(libs.fpsdisplay) modRuntimeOnly(libs.cloth.config.fabric) { diff --git a/fabric/src/main/java/xaeroplus/fabric/XaeroPlusModMenu.java b/fabric/src/main/java/xaeroplus/fabric/XaeroPlusModMenu.java new file mode 100644 index 00000000..59ce3a3b --- /dev/null +++ b/fabric/src/main/java/xaeroplus/fabric/XaeroPlusModMenu.java @@ -0,0 +1,13 @@ +package xaeroplus.fabric; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import xaero.map.gui.GuiWorldMapSettings; +import xaeroplus.feature.extensions.GuiXaeroPlusWorldMapSettings; + +public class XaeroPlusModMenu implements ModMenuApi { + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return screen -> new GuiXaeroPlusWorldMapSettings(new GuiWorldMapSettings(screen), screen); + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 9d69e834..799ede32 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -17,6 +17,9 @@ "entrypoints": { "client": [ "xaeroplus.fabric.XaeroPlusFabric" + ], + "modmenu": [ + "xaeroplus.fabric.XaeroPlusModMenu" ] }, "mixins": [ diff --git a/forge/src/main/java/xaeroplus/forge/XaeroPlusForge.java b/forge/src/main/java/xaeroplus/forge/XaeroPlusForge.java index 9e6da170..b62466d6 100644 --- a/forge/src/main/java/xaeroplus/forge/XaeroPlusForge.java +++ b/forge/src/main/java/xaeroplus/forge/XaeroPlusForge.java @@ -5,15 +5,19 @@ import net.minecraft.client.KeyMapping; import net.minecraft.commands.CommandSourceStack; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.ConfigScreenHandler; import net.minecraftforge.client.event.RegisterClientCommandsEvent; import net.minecraftforge.client.event.RegisterKeyMappingsEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import xaero.map.gui.GuiWorldMapSettings; import xaeroplus.Globals; import xaeroplus.XaeroPlus; +import xaeroplus.feature.extensions.GuiXaeroPlusWorldMapSettings; import xaeroplus.module.ModuleManager; import xaeroplus.settings.XaeroPlusSettingRegistry; import xaeroplus.settings.XaeroPlusSettingsReflectionHax; @@ -38,6 +42,10 @@ public XaeroPlusForge() { if (EmbeddiumHelper.isEmbeddiumPresent()) FORGE_EVENT_BUS.addListener(XaeroPlusEmbeddiumOptionsInit::onEmbeddiumOptionGUIConstructionEvent); RemovalCause explicit = RemovalCause.EXPLICIT; // force class load to stop forge shitting itself at runtime?? + ModLoadingContext.get().registerExtensionPoint( + ConfigScreenHandler.ConfigScreenFactory.class, + () -> new ConfigScreenHandler.ConfigScreenFactory((mc, screen) -> new GuiXaeroPlusWorldMapSettings(new GuiWorldMapSettings(screen), screen)) + ); }; }); }