Skip to content

Commit

Permalink
recrash_cleanroomversion (#273)
Browse files Browse the repository at this point in the history
Clear unnecessary patches and patch hunks
  • Loading branch information
Ecdcaeb authored Jan 1, 2025
1 parent 2638d0d commit d31ea10
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 105 deletions.
110 changes: 9 additions & 101 deletions patches/minecraft/net/minecraft/crash/CrashReport.java.patch
Original file line number Diff line number Diff line change
@@ -1,122 +1,30 @@
--- before/net/minecraft/crash/CrashReport.java
+++ after/net/minecraft/crash/CrashReport.java
@@ -13,6 +13,9 @@
@@ -13,6 +13,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
+import java.util.Set;
+
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import net.minecraft.util.ReportedException;
import net.minecraft.world.gen.layer.IntCache;
import net.minecraftforge.fml.relauncher.Side;
@@ -21,6 +24,9 @@
import org.apache.commons.lang3.ArrayUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
+import org.spongepowered.asm.mixin.transformer.ClassInfo;
+import org.spongepowered.asm.mixin.transformer.MixinInfo;

public class CrashReport
{
@@ -28,7 +34,7 @@
private final String field_71513_a;
private final Throwable field_71511_b;
private final CrashReportCategory field_85061_c = new CrashReportCategory(this, "System Details");
- private final List<CrashReportCategory> field_71512_c = Lists.newArrayList();
+ private final List<CrashReportCategory> field_71512_c = Lists.<CrashReportCategory>newArrayList();
private File field_71510_d;
private boolean field_85059_f = true;
private StackTraceElement[] field_85060_g = new StackTraceElement[0];
@@ -49,6 +55,13 @@
return "1.12.2";
}
});
+ this.field_85061_c.func_189529_a("Cleanroom Version", new ICrashReportDetail<String>()
+ {
+ public String call() throws Exception
+ {
+ return com.cleanroommc.common.CleanroomVersion.BUILD_VERSION;
+ }
+ });
this.field_85061_c.func_189529_a("Operating System", new ICrashReportDetail<String>()
{
public String call()
@@ -116,6 +129,7 @@
@@ -116,6 +117,7 @@
return IntCache.func_85144_b();
}
});
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().enhanceCrashReport(this, this.field_85061_c);
}

public String func_71501_a()
@@ -132,7 +146,7 @@
{
if ((this.field_85060_g == null || this.field_85060_g.length <= 0) && !this.field_71512_c.isEmpty())
{
- this.field_85060_g = ArrayUtils.subarray(this.field_71512_c.get(0).func_147152_a(), 0, 1);
+ this.field_85060_g = (StackTraceElement[])ArrayUtils.subarray(((CrashReportCategory)this.field_71512_c.get(0)).func_147152_a(), 0, 1);
}

if (this.field_85060_g != null && this.field_85060_g.length > 0)
@@ -143,7 +157,7 @@

for (StackTraceElement stacktraceelement : this.field_85060_g)
{
- p_71506_1_.append("\t").append("at ").append(stacktraceelement);
+ p_71506_1_.append("\t").append("at ").append((Object)stacktraceelement);
p_71506_1_.append("\n");
}

@@ -198,6 +212,46 @@
@@ -198,18 +200,19 @@
IOUtils.closeQuietly((Writer)printwriter);
}

+ StackTraceElement[] stacktrace = throwable.getStackTrace();
+ if (stacktrace.length > 0) {
+ try {
+ StringBuilder mixinMetadataBuilder = null;
+ Set<String> classes = new ObjectOpenHashSet<>();
+ for (StackTraceElement stackTraceElement : stacktrace) {
+ classes.add(stackTraceElement.getClassName());
+ }
+ for (String className : classes) {
+ ClassInfo classInfo = ClassInfo.fromCache(className);
+ if (classInfo != null) {
+ @SuppressWarnings("unchecked")
+ Set<MixinInfo> mixinInfos = classInfo.getMixins();
+ if (!mixinInfos.isEmpty()) {
+ if (mixinMetadataBuilder == null) {
+ mixinMetadataBuilder = new StringBuilder("\n(MixinBooter) Mixins in Stacktrace:");
+ }
+ mixinMetadataBuilder.append("\n\t");
+ mixinMetadataBuilder.append(className);
+ mixinMetadataBuilder.append(":");
+ for (IMixinInfo mixinInfo : mixinInfos) {
+ mixinMetadataBuilder.append("\n\t\t");
+ mixinMetadataBuilder.append(mixinInfo.getClassName());
+ mixinMetadataBuilder.append(" (");
+ mixinMetadataBuilder.append(mixinInfo.getConfig().getName());
+ mixinMetadataBuilder.append(")");
+ }
+ }
+ }
+ }
+
+ if (mixinMetadataBuilder == null) {
+ return s + "\nNo Mixin Metadata is found in the Stacktrace.\n";
+ } else {
+ return s + mixinMetadataBuilder;
+ }
+ } catch (Throwable t) {
+ return s + "\nFailed to find Mixin Metadata in Stacktrace:\n" + t;
+ }
+ }
return s;
- return s;
+ return s + net.minecraftforge.common.ForgeHooks.gatherMixinInfo(throwable);
}

@@ -205,11 +259,12 @@
public String func_71502_e()
{
StringBuilder stringbuilder = new StringBuilder();
stringbuilder.append("---- Minecraft Crash Report ----\n");
Expand All @@ -130,7 +38,7 @@
stringbuilder.append("\n");
stringbuilder.append("Description: ");
stringbuilder.append(this.field_71513_a);
@@ -217,7 +272,7 @@
@@ -217,7 +220,7 @@
stringbuilder.append(this.func_71498_d());
stringbuilder.append("\n\nA detailed walkthrough of the error, its code path and all known details is as follows:\n");

Expand All @@ -139,7 +47,7 @@
{
stringbuilder.append("-");
}
@@ -247,26 +302,27 @@
@@ -247,26 +250,27 @@
}

Writer writer = null;
Expand Down Expand Up @@ -171,7 +79,7 @@
}
}

@@ -331,49 +387,13 @@
@@ -331,49 +335,13 @@

private static String func_71503_h()
{
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/net/minecraftforge/common/ForgeHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementManager;
import net.minecraft.block.Block;
Expand All @@ -51,6 +52,7 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.crash.CrashReport;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -165,6 +167,9 @@

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import org.spongepowered.asm.mixin.transformer.ClassInfo;
import org.spongepowered.asm.mixin.transformer.MixinInfo;

public class ForgeHooks
{
Expand Down Expand Up @@ -1518,4 +1523,48 @@ public static int getSerializerId(DataSerializer<?> serializer, IntIdentityHashB
}
return id;
}

public static String gatherMixinInfo(Throwable throwable){
StackTraceElement[] stacktrace = throwable.getStackTrace();
if (stacktrace.length > 0) {
try {
StringBuilder mixinMetadataBuilder = null;
ObjectOpenHashSet<String> classes = new ObjectOpenHashSet<>();
for (StackTraceElement stackTraceElement : stacktrace) {
classes.add(stackTraceElement.getClassName());
}
for (String className : classes) {
ClassInfo classInfo = ClassInfo.fromCache(className);
if (classInfo != null) {
java.util.Set<MixinInfo> mixinInfos = classInfo.getMixins();
if (!mixinInfos.isEmpty()) {
if (mixinMetadataBuilder == null) {
mixinMetadataBuilder = new StringBuilder("\n(MixinBooter) Mixins in Stacktrace:");
}
mixinMetadataBuilder.append("\n\t");
mixinMetadataBuilder.append(className);
mixinMetadataBuilder.append(":");
for (IMixinInfo mixinInfo : mixinInfos) {
mixinMetadataBuilder.append("\n\t\t");
mixinMetadataBuilder.append(mixinInfo.getClassName());
mixinMetadataBuilder.append(" (");
mixinMetadataBuilder.append(mixinInfo.getConfig().getName());
mixinMetadataBuilder.append(")");
}
}
}
}

if (mixinMetadataBuilder == null) {
return "No Mixin Metadata is found in the Stacktrace.\n";
} else {
return mixinMetadataBuilder.toString();
}
} catch (Throwable t) {
return "Failed to find Mixin Metadata in Stacktrace:\n" + t;
}
}

return "";
}
}
19 changes: 15 additions & 4 deletions src/main/java/net/minecraftforge/fml/common/FMLCommonHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,27 @@ public class FMLCommonHandler

private FMLCommonHandler()
{
registerCrashCallable(new ICrashCallable() {
@Override
public String call() {
return com.cleanroommc.common.CleanroomVersion.BUILD_VERSION;
}

@Override
public String getLabel() {
return "Cleanroom Version";
}
});

registerCrashCallable(new ICrashCallable()
{
@Override
public String call() throws Exception
{
public String call() {
StringBuilder builder = new StringBuilder();
Joiner joiner = Joiner.on("\n ");
for(String coreMod : CoreModManager.getTransformers().keySet())
{
builder.append("\n" + coreMod + "\n ").append(joiner.join(CoreModManager.getTransformers().get(coreMod)));
builder.append("\n").append(coreMod).append("\n ").append(joiner.join(CoreModManager.getTransformers().get(coreMod)));
}
return builder.toString();
}
Expand All @@ -146,7 +157,7 @@ public String getLabel()
/**
* The FML event bus. Subscribe here for FML related events
*
* @Deprecated Use {@link MinecraftForge#EVENT_BUS} they're the same thing now
* @deprecated Use {@link MinecraftForge#EVENT_BUS} they're the same thing now
* @return the event bus
*/
@Deprecated
Expand Down

0 comments on commit d31ea10

Please sign in to comment.