|
| 1 | +/* |
| 2 | + * Copyright 2025 Lambda |
| 3 | + * |
| 4 | + * This program is free software: you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation, either version 3 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License |
| 15 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + */ |
| 17 | + |
| 18 | +package com.lambda.mixin; |
| 19 | + |
| 20 | +import com.lambda.Lambda; |
| 21 | +import com.lambda.util.DynamicException; |
| 22 | +import net.minecraft.client.MinecraftClient; |
| 23 | +import net.minecraft.util.Util; |
| 24 | +import net.minecraft.util.crash.CrashReport; |
| 25 | +import org.spongepowered.asm.mixin.Final; |
| 26 | +import org.spongepowered.asm.mixin.Mixin; |
| 27 | +import org.spongepowered.asm.mixin.Mutable; |
| 28 | +import org.spongepowered.asm.mixin.Shadow; |
| 29 | +import org.spongepowered.asm.mixin.injection.At; |
| 30 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 31 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 32 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 33 | + |
| 34 | +// Modify the crash report behavior for dynamic remapping and Easter egg |
| 35 | +@Mixin(CrashReport.class) |
| 36 | +public class CrashReportMixin { |
| 37 | + @Mutable |
| 38 | + @Shadow @Final private Throwable cause; |
| 39 | + |
| 40 | + @Inject(method = "<init>(Ljava/lang/String;Ljava/lang/Throwable;)V", at = @At("TAIL")) |
| 41 | + void injectConstructor(String message, Throwable cause, CallbackInfo ci) { |
| 42 | + if (!Lambda.INSTANCE.isDebug() && MinecraftClient.getInstance() != null) { |
| 43 | + this.cause = new DynamicException(cause); |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + @Inject(method = "generateWittyComment()Ljava/lang/String;", at = @At("HEAD"), cancellable = true) |
| 48 | + 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 | + }; |
| 87 | + |
| 88 | + try { |
| 89 | + cir.setReturnValue(strings[(int)(Util.getMeasuringTimeNano() % (long)strings.length)]); |
| 90 | + } catch (Throwable var2) { |
| 91 | + cir.setReturnValue("Witty comment unavailable :("); |
| 92 | + } |
| 93 | + } |
| 94 | +} |
0 commit comments