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