diff --git a/fabric/src/main/java/com/unascribed/blockrenderer/fabric/client/varia/rendering/GL.java b/fabric/src/main/java/com/unascribed/blockrenderer/fabric/client/varia/rendering/GL.java index 6a23505..5532b6b 100644 --- a/fabric/src/main/java/com/unascribed/blockrenderer/fabric/client/varia/rendering/GL.java +++ b/fabric/src/main/java/com/unascribed/blockrenderer/fabric/client/varia/rendering/GL.java @@ -1,8 +1,6 @@ package com.unascribed.blockrenderer.fabric.client.varia.rendering; import com.mojang.blaze3d.systems.RenderSystem; -import com.unascribed.blockrenderer.varia.logging.Log; -import com.unascribed.blockrenderer.varia.logging.Markers; import com.unascribed.blockrenderer.varia.rendering.GLI; import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; @@ -15,18 +13,6 @@ public class GL implements GLI { public static final GLI INSTANCE = new GL(); - Minecraft client; - MainWindow window; - - @SuppressWarnings("ConstantConditions") - public GL() { - client = Minecraft.getInstance(); - window = client != null ? client.getMainWindow() : null; - - if (client == null) Log.warn(Markers.ROOT, "Minecraft Instance isn't present. If your not in a data-gen context this is an error!"); - if (client != null && window == null) throw new AssertionError("Minecraft Instance is present but the Window isn't."); - } - /* ================================================================================================== Matrix ==== */ @Override @@ -115,42 +101,42 @@ public void clearDepthBuffer() { @Override public void unbindFBO() { - client.getFramebuffer().unbindFramebuffer(); + client().getFramebuffer().unbindFramebuffer(); } @Override public void flipFrame() { - window.flipFrame(); + window().flipFrame(); } @Override public void rebindFBO() { - client.getFramebuffer().bindFramebuffer(false); + client().getFramebuffer().bindFramebuffer(false); } @Override public int getScaledWidth() { - return window.getScaledWidth(); + return window().getScaledWidth(); } @Override public int getScaledHeight() { - return window.getScaledHeight(); + return window().getScaledHeight(); } @Override public int getFramebufferWidth() { - return window.getFramebufferWidth(); + return window().getFramebufferWidth(); } @Override public int getFramebufferHeight() { - return window.getFramebufferHeight(); + return window().getFramebufferHeight(); } @Override public double getScaleFactor() { - return window.getGuiScaleFactor(); + return window().getGuiScaleFactor(); } /* ============================================================================================= Projections ==== */ @@ -165,4 +151,14 @@ public void matrixModeModelView() { RenderSystem.matrixMode(GL11.GL_MODELVIEW); } + /* ================================================================================================= Utility ==== */ + + private Minecraft client() { + return Minecraft.getInstance(); + } + + private MainWindow window() { + return Minecraft.getInstance().getMainWindow(); + } + } diff --git a/forge/src/main/java/com/unascribed/blockrenderer/forge/client/varia/rendering/GL.java b/forge/src/main/java/com/unascribed/blockrenderer/forge/client/varia/rendering/GL.java index 10ae143..86e369f 100644 --- a/forge/src/main/java/com/unascribed/blockrenderer/forge/client/varia/rendering/GL.java +++ b/forge/src/main/java/com/unascribed/blockrenderer/forge/client/varia/rendering/GL.java @@ -1,8 +1,6 @@ package com.unascribed.blockrenderer.forge.client.varia.rendering; import com.mojang.blaze3d.systems.RenderSystem; -import com.unascribed.blockrenderer.varia.logging.Log; -import com.unascribed.blockrenderer.varia.logging.Markers; import com.unascribed.blockrenderer.varia.rendering.GLI; import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; @@ -15,18 +13,6 @@ public class GL implements GLI { public static final GLI INSTANCE = new GL(); - Minecraft client; - MainWindow window; - - @SuppressWarnings("ConstantConditions") - public GL() { - client = Minecraft.getInstance(); - window = client != null ? client.getMainWindow() : null; - - if (client == null) Log.warn(Markers.ROOT, "Minecraft Instance isn't present. If your not in a data-gen context this is an error!"); - if (client != null && window == null) throw new AssertionError("Minecraft Instance is present but the Window isn't."); - } - /* ================================================================================================== Matrix ==== */ @Override @@ -115,42 +101,42 @@ public void clearDepthBuffer() { @Override public void unbindFBO() { - client.getFramebuffer().unbindFramebuffer(); + client().getFramebuffer().unbindFramebuffer(); } @Override public void flipFrame() { - window.flipFrame(); + window().flipFrame(); } @Override public void rebindFBO() { - client.getFramebuffer().bindFramebuffer(false); + client().getFramebuffer().bindFramebuffer(false); } @Override public int getScaledWidth() { - return window.getScaledWidth(); + return window().getScaledWidth(); } @Override public int getScaledHeight() { - return window.getScaledHeight(); + return window().getScaledHeight(); } @Override public int getFramebufferWidth() { - return window.getFramebufferWidth(); + return window().getFramebufferWidth(); } @Override public int getFramebufferHeight() { - return window.getFramebufferHeight(); + return window().getFramebufferHeight(); } @Override public double getScaleFactor() { - return window.getGuiScaleFactor(); + return window().getGuiScaleFactor(); } /* ============================================================================================= Projections ==== */ @@ -165,4 +151,14 @@ public void matrixModeModelView() { RenderSystem.matrixMode(GL11.GL_MODELVIEW); } + /* ================================================================================================= Utility ==== */ + + private Minecraft client() { + return Minecraft.getInstance(); + } + + private MainWindow window() { + return Minecraft.getInstance().getMainWindow(); + } + } diff --git a/patches/forge2fabric/client/varia/rendering/GL.java.patch b/patches/forge2fabric/client/varia/rendering/GL.java.patch index d49857d..0acb76a 100644 --- a/patches/forge2fabric/client/varia/rendering/GL.java.patch +++ b/patches/forge2fabric/client/varia/rendering/GL.java.patch @@ -5,4 +5,4 @@ +package com.unascribed.blockrenderer.fabric.client.varia.rendering; import com.mojang.blaze3d.systems.RenderSystem; - import com.unascribed.blockrenderer.varia.logging.Log; + import com.unascribed.blockrenderer.varia.rendering.GLI;