diff options
author | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-04-18 12:28:14 -0400 |
---|---|---|
committer | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-04-18 12:28:14 -0400 |
commit | 3836eb98ca5b9a7fb55c24beb4dfed3f174c7d39 (patch) | |
tree | 2628592b7de23984d64819f5cfbb00a361e727ac /src/main | |
parent | f200d21467b63b2d038883253e668b18e594e955 (diff) | |
download | SkytilsMod-3836eb98ca5b9a7fb55c24beb4dfed3f174c7d39.tar.gz SkytilsMod-3836eb98ca5b9a7fb55c24beb4dfed3f174c7d39.tar.bz2 SkytilsMod-3836eb98ca5b9a7fb55c24beb4dfed3f174c7d39.zip |
Add Skytils & Sychic blame
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/skytils/skytilsmod/mixins/MixinCrashReport.java | 51 | ||||
-rw-r--r-- | src/main/resources/mixins.skytils.json | 1 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/skytils/skytilsmod/mixins/MixinCrashReport.java b/src/main/java/skytils/skytilsmod/mixins/MixinCrashReport.java new file mode 100644 index 00000000..163eeff6 --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/MixinCrashReport.java @@ -0,0 +1,51 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins; + +import net.minecraft.crash.CrashReport; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Mixin(CrashReport.class) +public abstract class MixinCrashReport { + + public boolean isSkytilsCrash = false; + + @Shadow public abstract String getCauseStackTraceOrString(); + + @ModifyArg(method = "getCompleteReport", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/asm/transformers/BlamingTransformer;onCrash(Ljava/lang/StringBuilder;)V", remap = false)) + private StringBuilder blameSkytils(StringBuilder stringbuilder) { + if (getCauseStackTraceOrString().contains("skytils.skytilsmod")) { + isSkytilsCrash = true; + stringbuilder.append("Skytils may have caused this crash.\nJoin the Discord for support at discord.gg/skytils\n"); + } + return stringbuilder; + } + + @ModifyArg(method = "getCompleteReport", at = @At(value = "INVOKE", target = "Ljava/lang/StringBuilder;append(Ljava/lang/String;)Ljava/lang/StringBuilder;", ordinal = 2, remap = false)) + private String replaceWittyComment(String comment) { + if (isSkytilsCrash) { + comment = "Did Sychic do that?"; + } + return comment; + } + +} diff --git a/src/main/resources/mixins.skytils.json b/src/main/resources/mixins.skytils.json index 6cc0396d..25b582c7 100644 --- a/src/main/resources/mixins.skytils.json +++ b/src/main/resources/mixins.skytils.json @@ -10,6 +10,7 @@ "MixinBlockRendererDispatcher", "MixinBossStatus", "MixinChunk", + "MixinCrashReport", "MixinEntityBlaze", "MixinEntityLivingBase", "MixinEntityPlayerSP", |