Fix compiling on MC 1.19.2 and below

This commit is contained in:
James Seibel
2024-02-06 07:17:43 -06:00
parent 42bcc28d3e
commit 41f8c8cfa4
3 changed files with 24 additions and 25 deletions
@@ -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;
@@ -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