Skip to content

Commit 3bea34b

Browse files
committed
make all versions up to 1.21.5 compile
1 parent 502d2f9 commit 3bea34b

File tree

10 files changed

+168
-16
lines changed

10 files changed

+168
-16
lines changed

build.gradle.kts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,16 @@ dependencies {
8181

8282
val nec = mapOf(
8383
nec("1.16.5", "4.1.4"),
84-
nec("1.17.1", "4.1.4")
84+
nec("1.17.1", "4.1.4"),
85+
nec("1.18.2", "4.2.0"),
86+
nec("1.19.2", "5.0.0"),
87+
nec("1.19.4", "4.4.1"),
88+
nec("1.20.1", "4.4.9"),
89+
nec("1.20.4", "4.4.7"),
90+
nec("1.20.6", "4.4.7"),
91+
nec("1.21.1", "4.4.9"),
92+
nec("1.21.4", "4.4.8"),
93+
nec("1.21.5", "4.4.9")
8594
)
8695

8796
modImplementationCompat(nec[mcData.version.toString()])

root.gradle.kts

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,52 @@ preprocess {
1010
// "1.8.9-forge"(10809, "srg")
1111
// }
1212

13-
"1.16.5-fabric"(11605, "yarn") {
14-
"1.16.5-forge"(11605, "srg") {
15-
"1.12.2-forge"(11202, "srg", rootProject.file("versions/1.16.5-1.8.9.txt")) {
16-
"1.12.2-fabric"(11202, "yarn") {
17-
"1.8.9-fabric"(10809, "yarn") {
18-
"1.8.9-forge"(10809, "srg")
13+
"1.21.5-fabric"(1_21_05, "yarn") {
14+
"1.21.5-neoforge"(1_21_05, "srg") {
15+
"1.21.4-neoforge"(1_21_04, "srg") {
16+
"1.21.4-fabric"(1_21_04, "yarn") {
17+
"1.21.1-fabric"(1_21_01, "yarn") {
18+
"1.21.1-neoforge"(1_21_01, "srg") {
19+
"1.20.6-neoforge"(1_20_06, "srg") {
20+
"1.20.6-fabric"(1_20_06, "yarn") {
21+
"1.20.4-fabric"(1_20_04, "yarn") {
22+
"1.20.4-forge"(1_20_04, "srg") {
23+
"1.20.1-forge"(1_20_01, "srg") {
24+
"1.20.1-fabric"(1_20_01, "yarn") {
25+
"1.19.4-fabric"(1_19_04, "yarn") {
26+
"1.19.4-forge"(1_19_04, "srg") {
27+
"1.19.2-forge"(1_19_02, "srg") {
28+
"1.19.2-fabric"(1_19_02, "yarn") {
29+
"1.18.2-fabric"(1_18_02, "yarn") {
30+
"1.18.2-forge"(1_18_02, "srg") {
31+
"1.17.1-forge"(1_17_01, "srg") {
32+
"1.17.1-fabric"(1_17_01, "yarn") {
33+
"1.16.5-fabric"(1_16_05, "yarn"){
34+
"1.16.5-forge"(1_16_05, "srg") {
35+
"1.12.2-forge"(1_12_02, "srg", rootProject.file("versions/1.16.5-1.8.9.txt")) {
36+
"1.12.2-fabric"(1_12_02, "yarn") {
37+
"1.8.9-fabric"(1_08_09, "yarn"){
38+
"1.8.9-forge"(1_08_09, "srg")
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}
47+
}
48+
}
49+
}
50+
}
51+
}
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}
58+
}
1959
}
2060
}
2161
}

settings.gradle.kts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,42 @@ rootProject.buildFileName = "root.gradle.kts"
4242
listOf(
4343
"1.8.9-forge",
4444
"1.8.9-fabric",
45+
4546
"1.12.2-forge",
4647
"1.12.2-fabric",
48+
4749
"1.16.5-forge",
4850
"1.16.5-fabric",
51+
52+
"1.17.1-forge",
53+
"1.17.1-fabric",
54+
55+
"1.18.2-forge",
56+
"1.18.2-fabric",
57+
58+
"1.19.2-forge",
59+
"1.19.2-fabric",
60+
61+
"1.19.4-forge",
62+
"1.19.4-fabric",
63+
64+
"1.20.1-forge",
65+
"1.20.1-fabric",
66+
67+
"1.20.4-forge",
68+
"1.20.4-fabric",
69+
70+
"1.20.6-neoforge",
71+
"1.20.6-fabric",
72+
73+
"1.21.1-neoforge",
74+
"1.21.1-fabric",
75+
76+
"1.21.4-neoforge",
77+
"1.21.4-fabric",
78+
79+
"1.21.5-neoforge",
80+
"1.21.5-fabric"
4981
).forEach { version ->
5082
include(":$version")
5183
project(":$version").apply {

src/main/java/org/polyfrost/crashpatch/mixin/MixinCrashReport.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ public String getSuspectedCrashPatchMods() {
2929
return crashpatch$suspectedMod;
3030
}
3131

32-
@Inject(method = "populateEnvironment", at = @At("TAIL"))
32+
@Inject(method =
33+
//#if MC<1.17
34+
"populateEnvironment"
35+
//#else
36+
//$$ "<init>"
37+
//#endif
38+
, at = @At("TAIL"))
3339
private void afterPopulateEnvironment(CallbackInfo ci) {
3440
ModMetadata susMod = ModIdentifier.INSTANCE.identifyFromStacktrace((CrashReport) (Object) this, this.cause);
3541
crashpatch$suspectedMod = (susMod == null ? "Unknown" : susMod.getName());

src/main/kotlin/org/polyfrost/crashpatch/gui/CrashUI.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,17 @@ class CrashUI @JvmOverloads constructor(
4242

4343
@JvmOverloads
4444
constructor(report: CrashReport, type: GuiType = GuiType.NORMAL) : this(
45-
report.completeReport,
46-
report.file,
45+
report
46+
//#if MC < 1.21
47+
.completeReport,
48+
//#else
49+
//$$ .getFriendlyReport(net.minecraft.ReportType.CRASH),
50+
//#endif
51+
report.file
52+
//#if MC >= 1.21
53+
//$$ ?.toFile()
54+
//#endif
55+
,
4756
(report as CrashReportHook).suspectedCrashPatchMods,
4857
type,
4958
report.crashCause

versions/1.16.5-forge/src/main/java/org/polyfrost/crashpatch/mixin/MixinEntryPointCatcher_UseCrashPatchGui.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@Mixin(value = EntryPointCatcher.class)
1313
public class MixinEntryPointCatcher_UseCrashPatchGui {
1414

15-
@Shadow private static CrashReport crashReport;
15+
@Shadow(remap = false) private static CrashReport crashReport;
1616

1717
@ModifyArg(method = "displayInitErrorScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V"), index = 0)
1818
private static Screen useCrashPatchGui(Screen screen) {

versions/1.16.5-forge/src/main/java/org/polyfrost/crashpatch/mixin/MixinGuiConnecting.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ protected MixinGuiConnecting(Component arg) {
2929
}
3030

3131
@Inject(method = "render", at = @At("TAIL"))
32-
private void drawWarningText(PoseStack arg, int i, int j, float f, CallbackInfo ci) {
32+
private void drawWarningText(
33+
//#if MC<1.20
34+
PoseStack arg,
35+
//#else
36+
//$$ net.minecraft.client.gui.DrawContext arg,
37+
//#endif
38+
int i, int j, float f, CallbackInfo ci) {
3339
if (((MinecraftHook) Minecraft.getInstance()).hasRecoveredFromCrash()) {
3440
crashpatch$drawSplitCenteredString(arg, crashpatch$getText(), width / 2, 5, Color.WHITE.getRGB());
3541
}
@@ -65,9 +71,20 @@ public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
6571
}
6672

6773
@Unique
68-
public void crashpatch$drawSplitCenteredString(PoseStack stack, String text, int x, int y, int color) {
74+
public void crashpatch$drawSplitCenteredString(
75+
//#if MC<1.20
76+
PoseStack stack,
77+
//#else
78+
//$$ net.minecraft.client.gui.DrawContext ctx,
79+
//#endif
80+
String text, int x, int y, int color) {
6981
for (FormattedCharSequence line : this.font.split(FormattedText.of(text), width)) {
70-
this.font.drawShadow(stack, line, (float) (x - this.font.width(line) / 2), (float) y, color);
82+
//#if MC<1.20
83+
this.font.drawShadow(stack,
84+
//#else
85+
//$$ ctx.drawTextWithShadow(this.textRenderer,
86+
//#endif
87+
line, (int) (x - ((float) this.font.width(line) / 2)), y, color);
7188
y += this.font.lineHeight + 2;
7289
}
7390
}

versions/1.16.5-forge/src/main/java/org/polyfrost/crashpatch/mixin/MixinInGameCatcher_UseCrashPatchGui.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ public class MixinInGameCatcher_UseCrashPatchGui {
1414

1515
@Unique private static CrashReport crashpatch$crashReport;
1616

17-
@ModifyArg(method = "displayCrashScreen", at = @At(value = "INVOKE", target = "Lfudge/notenoughcrashes/stacktrace/CrashUtils;outputReport(Lnet/minecraft/CrashReport;Z)V"), index = 0)
17+
@ModifyArg(method = "displayCrashScreen", at = @At(value = "INVOKE", target = "Lfudge/notenoughcrashes/stacktrace/CrashUtils;outputReport(Lnet/minecraft/CrashReport;Z)V"), index = 0, remap = false)
1818
private static CrashReport captureCrashReport(CrashReport report) {
1919
// Capture the crash report to be used in the CrashPatch GUI
2020
crashpatch$crashReport = report;
2121
return report;
2222
}
2323

24-
@ModifyArg(method = "displayCrashScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V"), index = 0)
24+
@ModifyArg(method = "displayCrashScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V", remap = true), index = 0, remap = false)
2525
private static Screen useCrashPatchGui(Screen par1) {
2626
// Use the CrashPatch GUI instead of the default one
2727
return new CrashUI(crashpatch$crashReport, CrashUI.GuiType.NORMAL).create();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.polyfrost.crashpatch.mixin;
2+
3+
import net.minecraft.client.gui.screens.DisconnectedScreen;
4+
import net.minecraft.network.DisconnectionDetails;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.gen.Accessor;
7+
8+
@Mixin(DisconnectedScreen.class)
9+
public interface AccessorGuiDisconnected {
10+
@Accessor
11+
DisconnectionDetails getDetails();
12+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.polyfrost.crashpatch.utils
2+
3+
import org.polyfrost.crashpatch.crashes.CrashScanStorage.scanReport
4+
import org.polyfrost.crashpatch.mixin.AccessorGuiDisconnected
5+
import net.minecraft.client.gui.screens.DisconnectedScreen
6+
import net.minecraft.client.gui.screens.Screen
7+
import org.polyfrost.crashpatch.CrashPatchConfig
8+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo
9+
import org.polyfrost.crashpatch.gui.CrashUI
10+
import org.polyfrost.oneconfig.utils.v1.dsl.mc
11+
12+
object GuiDisconnectedHook {
13+
14+
@JvmStatic
15+
fun onGUIDisplay(screen: Screen?, ci: CallbackInfo) {
16+
if (screen is DisconnectedScreen && CrashPatchConfig.disconnectCrashPatch) {
17+
val reason = (screen as AccessorGuiDisconnected).details.reason.string
18+
19+
val scan = scanReport(reason, true)
20+
if (scan != null && scan.solutions.size > 1) {
21+
ci.cancel()
22+
mc.setScreen(CrashUI(reason, null, reason, CrashUI.GuiType.DISCONNECT).create())
23+
}
24+
}
25+
}
26+
27+
}

0 commit comments

Comments
 (0)