From 41f8c8cfa45adcf70588be2a7ee84638ab4c5b6c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 6 Feb 2024 07:17:43 -0600 Subject: [PATCH] Fix compiling on MC 1.19.2 and below --- .../common/wrappers/McObjectConverter.java | 45 +++++++++---------- .../minecraft/MinecraftRenderWrapper.java | 2 +- coreSubProjects | 2 +- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java index f9422eba4..ebcab8af8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java @@ -23,12 +23,6 @@ import java.nio.FloatBuffer; import java.util.function.BiConsumer; import java.util.function.Consumer; -#if MC_VER < MC_1_19_4 -import com.mojang.math.Matrix4f; -#else -import org.joml.Matrix4f; -#endif - import com.seibel.distanthorizons.core.enums.EDhDirection; import com.seibel.distanthorizons.core.pos.DhBlockPos; import com.seibel.distanthorizons.core.pos.DhChunkPos; @@ -51,8 +45,29 @@ public class McObjectConverter { return y * 4 + x; } + + + /** 4x4 float matrix converter */ + @Deprecated + public static Mat4f Convert( + #if MC_VER < MC_1_19_4 com.mojang.math.Matrix4f + #else org.joml.Matrix4f #endif + mcMatrix) + { + FloatBuffer buffer = FloatBuffer.allocate(16); + storeMatrix(mcMatrix, buffer); + Mat4f matrix = new Mat4f(buffer); + #if MC_VER < MC_1_19_4 + matrix.transpose(); // In 1.19.3 and later, we no longer need to transpose it + #endif + return matrix; + } /** Taken from Minecraft's com.mojang.math.Matrix4f class from 1.18.2 */ - private static void storeMatrix(Matrix4f matrix, FloatBuffer buffer) + private static void storeMatrix( + #if MC_VER < MC_1_19_4 com.mojang.math.Matrix4f + #else org.joml.Matrix4f #endif + matrix, + FloatBuffer buffer) { #if MC_VER < MC_1_19_4 matrix.store(buffer); @@ -77,22 +92,6 @@ public class McObjectConverter #endif } - /** - * 4x4 float matrix converter - * TODO this should be moved into Mat4f's constructor - */ - @Deprecated - public static Mat4f Convert(Matrix4f mcMatrix) - { - FloatBuffer buffer = FloatBuffer.allocate(16); - storeMatrix(mcMatrix, buffer); - Mat4f matrix = new Mat4f(buffer); - #if MC_VER < MC_1_19_4 - matrix.transpose(); // In 1.19.3 and later, we no longer need to transpose it - #endif - return matrix; - } - static final Direction[] directions; static final EDhDirection[] lodDirections; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index 9c4a13f74..b1a2a0604 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -164,7 +164,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper .rotateX((float)Math.toRadians(camera.getXRot())) .rotateY((float)Math.toRadians(camera.getYRot() + 180f)) .translate(cameraVec3); - return McObjectConverter.Convert(matWorldView); + return new Mat4f(matWorldView); } @Override diff --git a/coreSubProjects b/coreSubProjects index 06b43d662..bc1a4ec13 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 06b43d6627914062be3af752e04a4e8e1099bb8c +Subproject commit bc1a4ec1389aebab233961cfe8e2be8879e15ee8