aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md6
-rw-r--r--gradle.properties2
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/mixin/MainMixin.java75
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/mixin/MinecraftMixin.java75
-rw-r--r--src/main/resources/iceberg.mixins.json6
5 files changed, 162 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4f4f755..f8d735b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+### 1.0.44
+- Fixed incompatibility with some mods causing a crash at startup.
+
+### 1.0.43
+- Fixed update checking not working for multiple dependent mods.
+
### 1.0.42
- Increased required Forge version to 40.1.6 to prevent a crash.
diff --git a/gradle.properties b/gradle.properties
index a060dfd..65c8492 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,6 +6,6 @@ org.gradle.daemon=false
name=${rootProject.name}
group=com.anthonyhilyard.${name.toLowerCase()}
author=anthonyhilyard
-version=1.0.42
+version=1.0.44
mcVersion=1.18.2
forgeVersion=40.1.17 \ No newline at end of file
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/MainMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/MainMixin.java
new file mode 100644
index 0000000..c52f265
--- /dev/null
+++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/MainMixin.java
@@ -0,0 +1,75 @@
+package com.anthonyhilyard.iceberg.mixin;
+
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Optional;
+
+import com.anthonyhilyard.iceberg.Loader;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import net.minecraft.server.Main;
+import net.minecraftforge.fml.loading.FMLLoader;
+import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
+import net.minecraftforge.forgespi.language.IModInfo;
+
+@Mixin(Main.class)
+public class MainMixin
+{
+ @SuppressWarnings("unchecked")
+ @Inject(method = "main", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/server/loading/ServerModLoader;load()V", remap = false), remap = false)
+ private static void fixUpdateURLs(String[] args, CallbackInfo info)
+ {
+ for (IModInfo mod : FMLLoader.getLoadingModList().getMods())
+ {
+ Optional<Object> authors = mod.getConfig().getConfigElement("authors");
+ if (!authors.isPresent())
+ {
+ continue;
+ }
+
+ boolean madeByGrend = false;
+ if (authors.get() instanceof String author)
+ {
+ madeByGrend = author.contentEquals("Grend");
+ }
+ else if (authors.get() instanceof ArrayList<?> authorList)
+ {
+ madeByGrend = authorList.contains("Grend");
+ }
+
+ if (madeByGrend)
+ {
+ // Found a mod I made, so patch the update URL.
+ // Yeah, it's a dirty hack but it lets me fix all my mods at once before I have the time to update them all properly.
+ ModInfo modInfo = (ModInfo)mod;
+
+ try
+ {
+ Field updateJSONURLField = ModInfo.class.getDeclaredField("updateJSONURL");
+ updateJSONURLField.setAccessible(true);
+
+ Optional<URL> updateJSONURL = (Optional<URL>)updateJSONURLField.get(modInfo);
+ if (updateJSONURL.isPresent())
+ {
+ String url = updateJSONURL.get().toString();
+ url = url.replace("mc-curse-update-checker.herokuapp.com", "mc-update-check.anthonyhilyard.com");
+ updateJSONURLField.set(modInfo, Optional.of(new URL(url)));
+
+ }
+ }
+ catch (Exception e)
+ {
+ Loader.LOGGER.debug(ExceptionUtils.getStackTrace(e));
+ }
+ }
+
+ }
+ }
+
+}
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/MinecraftMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/MinecraftMixin.java
new file mode 100644
index 0000000..67c63f5
--- /dev/null
+++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/MinecraftMixin.java
@@ -0,0 +1,75 @@
+package com.anthonyhilyard.iceberg.mixin;
+
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Optional;
+
+import com.anthonyhilyard.iceberg.Loader;
+import com.mojang.blaze3d.pipeline.RenderTarget;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+import net.minecraft.client.Minecraft;
+import net.minecraftforge.fml.loading.FMLLoader;
+import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
+import net.minecraftforge.forgespi.language.IModInfo;
+
+@Mixin(Minecraft.class)
+public class MinecraftMixin
+{
+ @SuppressWarnings("unchecked")
+ @Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/pipeline/RenderTarget;clear(Z)V", ordinal = 0), require = 0)
+ public void fixUpdateURLs(RenderTarget renderTarget, boolean onOSX)
+ {
+ for (IModInfo mod : FMLLoader.getLoadingModList().getMods())
+ {
+ Optional<Object> authors = mod.getConfig().getConfigElement("authors");
+ if (!authors.isPresent())
+ {
+ continue;
+ }
+
+ boolean madeByGrend = false;
+ if (authors.get() instanceof String author)
+ {
+ madeByGrend = author.contentEquals("Grend");
+ }
+ else if (authors.get() instanceof ArrayList<?> authorList)
+ {
+ madeByGrend = authorList.contains("Grend");
+ }
+
+ if (madeByGrend)
+ {
+ // Found a mod I made, so patch the update URL.
+ // Yeah, it's a dirty hack but it lets me fix all my mods at once before I have the time to update them all properly.
+ ModInfo modInfo = (ModInfo)mod;
+
+ try
+ {
+ Field updateJSONURLField = ModInfo.class.getDeclaredField("updateJSONURL");
+ updateJSONURLField.setAccessible(true);
+
+ Optional<URL> updateJSONURL = (Optional<URL>)updateJSONURLField.get(modInfo);
+ if (updateJSONURL.isPresent())
+ {
+ String url = updateJSONURL.get().toString();
+ url = url.replace("mc-curse-update-checker.herokuapp.com", "mc-update-check.anthonyhilyard.com");
+ updateJSONURLField.set(modInfo, Optional.of(new URL(url)));
+
+ }
+ }
+ catch (Exception e)
+ {
+ Loader.LOGGER.debug(ExceptionUtils.getStackTrace(e));
+ }
+ }
+
+ }
+ renderTarget.clear(onOSX);
+ }
+}
diff --git a/src/main/resources/iceberg.mixins.json b/src/main/resources/iceberg.mixins.json
index 1faddec..f5c7ec5 100644
--- a/src/main/resources/iceberg.mixins.json
+++ b/src/main/resources/iceberg.mixins.json
@@ -13,7 +13,11 @@
"TextColorMixin",
"ConfigMenusForgeIEntryDataMixin",
"ConfigMenusForgeConfigScreenMixin",
- "ConfigMenusForgeServerConfigUploaderMixin"
+ "ConfigMenusForgeServerConfigUploaderMixin",
+ "MinecraftMixin"
+ ],
+ "server": [
+ "MainMixin"
],
"injectors": {
"defaultRequire": 1