mirror of
https://github.com/GTNewHorizons/BetterCrashes.git
synced 2026-11-22 04:52:29 +00:00
Fix crash count not being read (#14)
* Fix crash count not being read * move mixins accessor interfaces under mixins\interfaces package --------- Co-authored-by: Alexdoru <[email protected]>
This commit is contained in:
1 parent
38434843b1
commit
badcd5a38c
7 files changed
+37
-58
No files matched your search
+2
-2
@@ -1,4 +1,4 @@
|
||||
//version: 1697697256
|
||||
//version: 1698936026
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
@@ -646,7 +646,7 @@ repositories {
|
||||
|
||||
def mixinProviderGroup = "io.github.legacymoddingmc"
|
||||
def mixinProviderModule = "unimixins"
|
||||
def mixinProviderVersion = "0.1.7.1"
|
||||
def mixinProviderVersion = "0.1.13"
|
||||
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
|
||||
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
|
||||
ext.mixinProviderSpec = mixinProviderSpec
|
||||
|
||||
@@ -33,12 +33,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import vfyjxf.bettercrashes.BetterCrashesConfig;
|
||||
import vfyjxf.bettercrashes.utils.IPatchedCrashReport;
|
||||
import vfyjxf.bettercrashes.mixins.interfaces.CrashReportExt;
|
||||
import vfyjxf.bettercrashes.utils.ModIdentifier;
|
||||
import vfyjxf.bettercrashes.utils.StacktraceDeobfuscator;
|
||||
|
||||
@Mixin(value = CrashReport.class, priority = 500)
|
||||
public class CrashReportMixin implements IPatchedCrashReport {
|
||||
public class CrashReportMixin implements CrashReportExt {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
import cpw.mods.fml.client.SplashProgress;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import vfyjxf.bettercrashes.BetterCrashesConfig;
|
||||
import vfyjxf.bettercrashes.mixins.interfaces.MinecraftExt;
|
||||
import vfyjxf.bettercrashes.utils.CrashUtils;
|
||||
import vfyjxf.bettercrashes.utils.GuiCrashScreen;
|
||||
import vfyjxf.bettercrashes.utils.GuiInitErrorScreen;
|
||||
@@ -54,7 +55,7 @@ import vfyjxf.bettercrashes.utils.StateManager;
|
||||
* @author Runemoro
|
||||
*/
|
||||
@Mixin(Minecraft.class)
|
||||
public abstract class MinecraftMixin {
|
||||
public abstract class MinecraftMixin implements MinecraftExt {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
@@ -222,6 +223,16 @@ public abstract class MinecraftMixin {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int betterCrashes$getClientCrashCount() {
|
||||
return betterCrashes$clientCrashCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int betterCrashes$getServerCrashCount() {
|
||||
return betterCrashes$serverCrashCount;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void betterCrashes$displayCrashScreen(CrashReport report) {
|
||||
try {
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
* dimdev/vanillafix/crashes/IPatchedCrashReport.java The source file uses the MIT License.
|
||||
*/
|
||||
|
||||
package vfyjxf.bettercrashes.utils;
|
||||
package vfyjxf.bettercrashes.mixins.interfaces;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -13,7 +13,7 @@ import cpw.mods.fml.common.ModContainer;
|
||||
/**
|
||||
* @author Runemoro
|
||||
*/
|
||||
public interface IPatchedCrashReport {
|
||||
public interface CrashReportExt {
|
||||
|
||||
Set<ModContainer> betterCrashes$getSuspectedMods();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package vfyjxf.bettercrashes.mixins.interfaces;
|
||||
|
||||
public interface MinecraftExt {
|
||||
|
||||
int betterCrashes$getClientCrashCount();
|
||||
|
||||
int betterCrashes$getServerCrashCount();
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
package vfyjxf.bettercrashes.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -28,26 +27,13 @@ import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import vfyjxf.bettercrashes.BetterCrashesConfig;
|
||||
import vfyjxf.bettercrashes.mixins.interfaces.CrashReportExt;
|
||||
import vfyjxf.bettercrashes.mixins.interfaces.MinecraftExt;
|
||||
import vfyjxf.bettercrashes.upload.CrashReportUpload;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class GuiProblemScreen extends GuiScreen {
|
||||
|
||||
private static Field fieldClientCrashCount = null;
|
||||
private static Field fieldServerCrashCount = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
// these are actually reachable, see MinecraftMixin
|
||||
fieldClientCrashCount = Minecraft.class.getDeclaredField("clientCrashCount");
|
||||
fieldClientCrashCount.setAccessible(true);
|
||||
fieldServerCrashCount = Minecraft.class.getDeclaredField("serverCrashCount");
|
||||
fieldServerCrashCount.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected final CrashReport report;
|
||||
private volatile URL pasteLink = null;
|
||||
private String modListString;
|
||||
@@ -205,7 +191,7 @@ public abstract class GuiProblemScreen extends GuiScreen {
|
||||
|
||||
protected String getModListString() {
|
||||
if (modListString == null) {
|
||||
final Set<ModContainer> suspectedMods = ((IPatchedCrashReport) report).betterCrashes$getSuspectedMods();
|
||||
final Set<ModContainer> suspectedMods = ((CrashReportExt) report).betterCrashes$getSuspectedMods();
|
||||
if (suspectedMods == null) {
|
||||
return modListString = I18n.format("bettercrashes.gui.common.identificationErrored");
|
||||
}
|
||||
@@ -248,30 +234,16 @@ public abstract class GuiProblemScreen extends GuiScreen {
|
||||
return installedUnsupportedMods;
|
||||
}
|
||||
|
||||
private int getClientCrashCount() {
|
||||
if (fieldClientCrashCount != null) {
|
||||
try {
|
||||
return (int) fieldClientCrashCount.get(Minecraft.getMinecraft());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getServerCrashCount() {
|
||||
if (fieldServerCrashCount != null) {
|
||||
try {
|
||||
return (int) fieldServerCrashCount.get(Minecraft.getMinecraft());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected boolean isCrashLogExpectedToBeGenerated() {
|
||||
return getClientCrashCount() <= BetterCrashesConfig.crashLogLimitClient
|
||||
&& getServerCrashCount() <= BetterCrashesConfig.crashLogLimitServer;
|
||||
}
|
||||
|
||||
private int getClientCrashCount() {
|
||||
return ((MinecraftExt) Minecraft.getMinecraft()).betterCrashes$getClientCrashCount();
|
||||
}
|
||||
|
||||
private int getServerCrashCount() {
|
||||
return ((MinecraftExt) Minecraft.getMinecraft()).betterCrashes$getServerCrashCount();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package vfyjxf.bettercrashes.utils;
|
||||
|
||||
import net.minecraft.crash.CrashReport;
|
||||
|
||||
public interface IPatchedMinecraft {
|
||||
|
||||
boolean shouldCrashIntegratedServerNextTick();
|
||||
|
||||
void showWarningScreen(CrashReport report);
|
||||
|
||||
void makeErrorNotification(CrashReport report);
|
||||
}
|
||||
Reference in new issue
Block a user