Skip to content

Commit 967b0c1

Browse files
committed
Prevent Forge's crash report analyser from complaining about ModernFix
1 parent fcea407 commit 967b0c1

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.embeddedt.modernfix.forge.mixin.core;
2+
3+
import net.minecraftforge.forgespi.language.IModInfo;
4+
import net.minecraftforge.logging.CrashReportAnalyser;
5+
import org.spongepowered.asm.mixin.Final;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Shadow;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11+
12+
import java.util.Map;
13+
14+
@Mixin(CrashReportAnalyser.class)
15+
public class CrashReportAnalyserMixin {
16+
@Shadow @Final private static Map<IModInfo, String[]> SUSPECTED_MODS;
17+
18+
/**
19+
* @author embeddedt
20+
* @reason Remove ModernFix from the list of suspected mods when a crash happens. Otherwise, we get blamed
21+
* for "registry object not present" crashes if users don't interpret the crash before reporting
22+
* it.
23+
*
24+
* It seems unlikely ModernFix will simultaneously cause a crash while it's not obvious it caused it.
25+
*/
26+
@Inject(method = "buildSuspectedModsSection", at = @At("HEAD"), require = 0)
27+
private static void removeOurselvesFromSuspectedMods(StringBuilder stringBuilder, CallbackInfo ci) {
28+
SUSPECTED_MODS.keySet().removeIf(iModInfo -> iModInfo.getModId().equals("modernfix"));
29+
}
30+
31+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mixinextras_version=0.4.1
77
mod_id=modernfix
88
minecraft_version=1.20.1
99
enabled_platforms=fabric,forge
10-
forge_version=1.20.1-47.1.3
10+
forge_version=1.20.1-47.4.0
1111
parchment_version=2023.07.09
1212
refined_storage_version=4392788
1313
jei_version=15.8.0.11

0 commit comments

Comments
 (0)