From a8a085f296e82e46bfb00c2ac60a137ea5ef6945 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 26 Jun 2025 07:50:53 -0500 Subject: [PATCH] Move RenderState to core --- .../core/api/internal/ClientApi.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java index 31ff41bc3..e91691633 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java @@ -89,6 +89,15 @@ public class ClientApi /** this includes the is dev build message and low allocated memory warning */ private static final int MS_BETWEEN_STATIC_STARTUP_MESSAGES = 4_000; + /** + * This isn't the cleanest way of storing variables before passing them to the LOD renderer, + * but due to how mixins work and the inconsistency between MC versions, + * having a static object that stores a single frame's data + * is often the easiest solution.

+ * + * Only downside is making sure each variable is populated before rendering. + */ + public static final RenderState RENDER_STATE = new RenderState(); private boolean isDevBuildMessagePrinted = false; @@ -760,4 +769,47 @@ public class ClientApi */ public void showOverlayMessageNextFrame(String message) { this.overlayMessageQueueForNextFrame.add(message); } + + + //================// + // helper classes // + //================// + + public static class RenderState + { + public Mat4f mcModelViewMatrix = null; + public Mat4f mcProjectionMatrix = null; + public float frameTime = -1; + + + public void canRenderOrThrow() throws IllegalStateException + { + String errorReasons = ""; + + if (this.mcModelViewMatrix == null) + { + errorReasons += "no MVM Matrix, "; + } + + if (this.mcProjectionMatrix == null) + { + errorReasons += "no Projection Matrix, "; + } + + if (this.frameTime == -1) + { + errorReasons += "no Frame Time, "; + } + + + if (!errorReasons.isEmpty()) + { + throw new IllegalStateException(errorReasons); + } + + } + } + + + }