Skip to content

Commit 31d338d

Browse files
committed
Added enabled module list
1 parent b98738e commit 31d338d

File tree

1 file changed

+24
-39
lines changed

1 file changed

+24
-39
lines changed

common/src/main/java/com/lambda/mixin/CrashReportMixin.java

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
package com.lambda.mixin;
1919

2020
import com.lambda.Lambda;
21+
import com.lambda.module.Module;
22+
import com.lambda.module.ModuleRegistry;
2123
import com.lambda.util.DynamicException;
2224
import net.minecraft.client.MinecraftClient;
2325
import net.minecraft.util.Util;
@@ -28,10 +30,11 @@
2830
import org.spongepowered.asm.mixin.Shadow;
2931
import org.spongepowered.asm.mixin.injection.At;
3032
import org.spongepowered.asm.mixin.injection.Inject;
33+
import org.spongepowered.asm.mixin.injection.Redirect;
3134
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3235
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3336

34-
// Modify the crash report behavior for dynamic remapping and Easter egg
37+
// Modify the crash report behavior for dynamic remapping, Easter egg and github issue link
3538
@Mixin(CrashReport.class)
3639
public class CrashReportMixin {
3740
@Mutable
@@ -44,46 +47,28 @@ void injectConstructor(String message, Throwable cause, CallbackInfo ci) {
4447
}
4548
}
4649

50+
@Redirect(method = "asString()Ljava/lang/String;", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;addStackTrace(Ljava/lang/StringBuilder;)V"))
51+
void injectString(CrashReport instance, StringBuilder stringBuilder) {
52+
stringBuilder.append("If this issue is related to Lambda, check if other users have experienced this too, or create a new issue at https://github.com/lambda-client/lambda/issues.\n\n");
53+
54+
if (MinecraftClient.getInstance() != null) {
55+
stringBuilder.append("Enabled modules:\n");
56+
57+
ModuleRegistry.INSTANCE.getModules()
58+
.stream().filter(Module::isEnabled)
59+
.forEach(m -> stringBuilder.append("\t").append(m.getName()).append("\n"));
60+
}
61+
62+
stringBuilder.append("\n");
63+
stringBuilder.append("-".repeat(43));
64+
stringBuilder.append("\n\n");
65+
66+
instance.addStackTrace(stringBuilder);
67+
}
68+
4769
@Inject(method = "generateWittyComment()Ljava/lang/String;", at = @At("HEAD"), cancellable = true)
4870
private static void generateWittyComment(CallbackInfoReturnable<String> cir) {
49-
String[] strings = new String[]{
50-
"Who set us up the TNT?",
51-
"Everything's going to plan. No, really, that was supposed to happen.",
52-
"Uh... Did I do that?",
53-
"Oops.",
54-
"Why did you do that?",
55-
"I feel sad now :(",
56-
"My bad.",
57-
"I'm sorry, Dave.",
58-
"I let you down. Sorry :(",
59-
"On the bright side, I bought you a teddy bear!",
60-
"Daisy, daisy...",
61-
"Oh - I know what I did wrong!",
62-
"Hey, that tickles! Hehehe!",
63-
"I blame Dinnerbone.",
64-
"You should try our sister game, Minceraft!",
65-
"Don't be sad. I'll do better next time, I promise!",
66-
"Don't be sad, have a hug! <3",
67-
"I just don't know what went wrong :(",
68-
"Shall we play a game?",
69-
"Quite honestly, I wouldn't worry myself about that.",
70-
"I bet Cylons wouldn't have this problem.",
71-
"Sorry :(",
72-
"Surprise! Haha. Well, this is awkward.",
73-
"Would you like a cupcake?",
74-
"Hi. I'm Minecraft, and I'm a crashaholic.",
75-
"Ooh. Shiny.",
76-
"This doesn't make any sense!",
77-
"Why is it breaking :(",
78-
"Don't do that.",
79-
"Ouch. That hurt :(",
80-
"You're mean.",
81-
"This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]",
82-
"There are four lights!",
83-
"But it works on my machine.",
84-
"Popbob was here.",
85-
"The oldest anarchy server in Minecraft."
86-
};
71+
String[] strings = new String[]{"Who set us up the TNT?", "Everything's going to plan. No, really, that was supposed to happen.", "Uh... Did I do that?", "Oops.", "Why did you do that?", "I feel sad now :(", "My bad.", "I'm sorry, Dave.", "I let you down. Sorry :(", "On the bright side, I bought you a teddy bear!", "Daisy, daisy...", "Oh - I know what I did wrong!", "Hey, that tickles! Hehehe!", "I blame Dinnerbone.", "You should try our sister game, Minceraft!", "Don't be sad. I'll do better next time, I promise!", "Don't be sad, have a hug! <3", "I just don't know what went wrong :(", "Shall we play a game?", "Quite honestly, I wouldn't worry myself about that.", "I bet Cylons wouldn't have this problem.", "Sorry :(", "Surprise! Haha. Well, this is awkward.", "Would you like a cupcake?", "Hi. I'm Minecraft, and I'm a crashaholic.", "Ooh. Shiny.", "This doesn't make any sense!", "Why is it breaking :(", "Don't do that.", "Ouch. That hurt :(", "You're mean.", "This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]", "There are four lights!", "But it works on my machine.", "Popbob was here.", "The oldest anarchy server in Minecraft.", "Better luck next time..", "Fatal error occurred user is too based.", "Running premium software on a potato is not advised", "I don't know, ask that kilab guy", "Ah shit, here we go again.", "I will uhh, fix that sometime.", "Not a bug, a feature!", "You should try out Lambda on Windows XP.", "Blade did that."};
8772

8873
try {
8974
cir.setReturnValue(strings[(int)(Util.getMeasuringTimeNano() % (long)strings.length)]);

0 commit comments

Comments
 (0)