From 2b388f015a4a9327d2f75aba56c8814c9ccecd11 Mon Sep 17 00:00:00 2001 From: 3TUSK Date: Sun, 15 Sep 2024 11:47:44 -0700 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E6=B2=A1=E6=95=91=E4=BA=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/SectionRenderDispatcherMixin.java | 34 +++++++++++++++++++ src/main/resources/powertool.mixins.json | 3 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/teacon/powertool/mixin/client/SectionRenderDispatcherMixin.java diff --git a/src/main/java/org/teacon/powertool/mixin/client/SectionRenderDispatcherMixin.java b/src/main/java/org/teacon/powertool/mixin/client/SectionRenderDispatcherMixin.java new file mode 100644 index 0000000..21d7cc4 --- /dev/null +++ b/src/main/java/org/teacon/powertool/mixin/client/SectionRenderDispatcherMixin.java @@ -0,0 +1,34 @@ +package org.teacon.powertool.mixin.client; + +import net.minecraft.client.renderer.chunk.SectionRenderDispatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.Marker; +import org.slf4j.MarkerFactory; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Mixin(SectionRenderDispatcher.class) +public class SectionRenderDispatcherMixin { + + @Unique + private static final Logger powerTool$LOGGER = LoggerFactory.getLogger("NamelessBugHunter"); + @Unique + private static final Marker powerTool$MARKER = MarkerFactory.getMarker("SectionRenderDispatcher"); + + /** + * Tracing the exception thrown when batching all sections. + * It is not a @Inject mixin because of a non-public class. + * @param t The exception + * @return The exception verbatim; we are only tracing it, not modifying it + */ + @ModifyArg(method = "lambda$runTask$3", at = @At(value = "INVOKE", target = "Lnet/minecraft/CrashReport;forThrowable(Ljava/lang/Throwable;Ljava/lang/String;)Lnet/minecraft/CrashReport;")) + private Throwable tracingStackTrace(Throwable t) { + powerTool$LOGGER.error(powerTool$MARKER, "SectionRenderDispatcher encounters error!", t); + return t; + } + + +} diff --git a/src/main/resources/powertool.mixins.json b/src/main/resources/powertool.mixins.json index 1b3f9b9..ca5d90e 100644 --- a/src/main/resources/powertool.mixins.json +++ b/src/main/resources/powertool.mixins.json @@ -14,7 +14,8 @@ "client": [ "client.GameModeSwitcherScreenMixin", "client.KeyboardHandlerMixin", - "client.PlayerMixin" + "client.PlayerMixin", + "client.SectionRenderDispatcherMixin" ], "injectors": { "defaultRequire": 1