From 3fd0fc0d9593c459b918700ff046627bf56cd8e0 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Thu, 17 Aug 2023 16:04:47 -0700 Subject: [PATCH] Remove sodium version checks --- src/main/java/net/coderbot/iris/Iris.java | 12 +----- .../compat/sodium/AllowedSodiumVersion.java | 43 ------------------- .../compat/sodium/SodiumVersionCheck.java | 34 --------------- .../coderbot/iris/mixin/MixinTitleScreen.java | 5 +-- .../mixin/IrisSodiumCompatMixinPlugin.java | 7 +-- 5 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 src/main/java/net/coderbot/iris/compat/sodium/AllowedSodiumVersion.java delete mode 100644 src/main/java/net/coderbot/iris/compat/sodium/SodiumVersionCheck.java diff --git a/src/main/java/net/coderbot/iris/Iris.java b/src/main/java/net/coderbot/iris/Iris.java index 1bef7edb70..065f8ddb7b 100644 --- a/src/main/java/net/coderbot/iris/Iris.java +++ b/src/main/java/net/coderbot/iris/Iris.java @@ -3,7 +3,6 @@ import com.google.common.base.Throwables; import com.mojang.blaze3d.platform.GlDebug; import com.mojang.blaze3d.platform.InputConstants; -import net.coderbot.iris.compat.sodium.SodiumVersionCheck; import net.coderbot.iris.config.IrisConfig; import net.coderbot.iris.gl.GLDebug; import net.coderbot.iris.gl.shader.ShaderCompileException; @@ -115,16 +114,7 @@ public class Iris { */ public void onEarlyInitialize() { FabricLoader.getInstance().getModContainer("sodium").ifPresent( - modContainer -> { - sodiumInstalled = true; - String versionString = modContainer.getMetadata().getVersion().getFriendlyString(); - - // This makes it so that if we don't have the right version of Sodium, it will show the user a - // nice warning, and prevent them from playing the game with a wrong version of Sodium. - if (!SodiumVersionCheck.isAllowedVersion(versionString)) { - sodiumInvalid = true; - } - } + modContainer -> sodiumInstalled = true ); hasNEC = FabricLoader.getInstance().isModLoaded("notenoughcrashes"); diff --git a/src/main/java/net/coderbot/iris/compat/sodium/AllowedSodiumVersion.java b/src/main/java/net/coderbot/iris/compat/sodium/AllowedSodiumVersion.java deleted file mode 100644 index 2cfa8deb28..0000000000 --- a/src/main/java/net/coderbot/iris/compat/sodium/AllowedSodiumVersion.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.coderbot.iris.compat.sodium; - -import java.util.Optional; - -public class AllowedSodiumVersion { - private final String version; - private final String downloadLink; - private final boolean prefixMatch; - - public AllowedSodiumVersion(String version, String downloadLink, boolean prefixMatch) { - this.version = version; - this.downloadLink = downloadLink; - this.prefixMatch = prefixMatch; - } - - public static AllowedSodiumVersion prefix(String prefix) { - return new AllowedSodiumVersion(prefix, null, true); - } - - public static AllowedSodiumVersion exact(String version, String downloadLink) { - return new AllowedSodiumVersion(version, downloadLink, false); - } - - public boolean matches(String candidate) { - if (prefixMatch) { - return candidate.startsWith(version); - } else { - return candidate.equals(version); - } - } - - public String getVersion() { - return version; - } - - public boolean isPrefixMatch() { - return prefixMatch; - } - - public Optional getDownloadLink() { - return Optional.ofNullable(downloadLink); - } -} diff --git a/src/main/java/net/coderbot/iris/compat/sodium/SodiumVersionCheck.java b/src/main/java/net/coderbot/iris/compat/sodium/SodiumVersionCheck.java deleted file mode 100644 index b93f6f8da3..0000000000 --- a/src/main/java/net/coderbot/iris/compat/sodium/SodiumVersionCheck.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.coderbot.iris.compat.sodium; - -import com.google.common.collect.ImmutableList; -import net.fabricmc.loader.api.FabricLoader; - -import java.util.Optional; - -public class SodiumVersionCheck { - // The allowed versions of Sodium for use with Iris - // - // Make sure to update the comments / download links when editing this!!! - // If you forget to edit the download links you'll cause the support team a bunch - // of pain. So don't forget! - private static final ImmutableList ALLOWED_SODIUM_VERSIONS = ImmutableList.of( - // Dev version - AllowedSodiumVersion.exact("0.5.1", - "https://modrinth.com/mod/sodium/version/mc1.20.1-0.5.1") - ); - - public static String getDownloadLink() { - return ALLOWED_SODIUM_VERSIONS.stream().map(AllowedSodiumVersion::getDownloadLink) - .filter(Optional::isPresent).findFirst().get().get(); - } - - public static boolean isAllowedVersion(String sodiumVersion) { - for (AllowedSodiumVersion allowed : ALLOWED_SODIUM_VERSIONS) { - if (allowed.matches(sodiumVersion)) { - return true; - } - } - - return false; - } -} diff --git a/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java b/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java index 1455b4c5d6..1dad30b435 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java @@ -2,7 +2,6 @@ import com.google.common.collect.ImmutableList; import net.coderbot.iris.Iris; -import net.coderbot.iris.compat.sodium.SodiumVersionCheck; import net.coderbot.iris.gui.debug.DebugLoadFailedGridScreen; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.ChatFormatting; @@ -73,7 +72,7 @@ protected MixinTitleScreen(Component arg) { } iris$hasFirstInit = true; - Minecraft.getInstance().setScreen(new ConfirmScreen( + /*Minecraft.getInstance().setScreen(new ConfirmScreen( (boolean accepted) -> { if (accepted) { try { @@ -92,6 +91,6 @@ protected MixinTitleScreen(Component arg) { Component.translatable("iris.sodium.failure.title").withStyle(ChatFormatting.RED), Component.translatable(reason), Component.translatable("iris.sodium.failure.download"), - FabricLoader.getInstance().isDevelopmentEnvironment() ? Component.literal("Continue (Development)") : Component.translatable("menu.quit"))); + FabricLoader.getInstance().isDevelopmentEnvironment() ? Component.literal("Continue (Development)") : Component.translatable("menu.quit")));*/ } } diff --git a/src/sodiumCompatibility/java/net/coderbot/iris/compat/sodium/mixin/IrisSodiumCompatMixinPlugin.java b/src/sodiumCompatibility/java/net/coderbot/iris/compat/sodium/mixin/IrisSodiumCompatMixinPlugin.java index 30d754232b..9ae6d7c693 100644 --- a/src/sodiumCompatibility/java/net/coderbot/iris/compat/sodium/mixin/IrisSodiumCompatMixinPlugin.java +++ b/src/sodiumCompatibility/java/net/coderbot/iris/compat/sodium/mixin/IrisSodiumCompatMixinPlugin.java @@ -1,6 +1,5 @@ package net.coderbot.iris.compat.sodium.mixin; -import net.coderbot.iris.compat.sodium.SodiumVersionCheck; import net.fabricmc.loader.api.FabricLoader; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; @@ -19,11 +18,7 @@ public class IrisSodiumCompatMixinPlugin implements IMixinConfigPlugin { @Override public void onLoad(String mixinPackage) { - validSodiumVersion = FabricLoader.getInstance().getModContainer("sodium").map(sodium -> { - String version = sodium.getMetadata().getVersion().getFriendlyString(); - - return FabricLoader.getInstance().isDevelopmentEnvironment() || SodiumVersionCheck.isAllowedVersion(version); - }).orElse(false); + validSodiumVersion = FabricLoader.getInstance().isModLoaded("sodium"); if (!validSodiumVersion) { // We can't use Iris' logger here due to classloading issues.