From a9ce71575051014ad3b31e4f640f737b75ac7824 Mon Sep 17 00:00:00 2001 From: QuImUfu Date: Fri, 11 Oct 2024 20:57:23 +0200 Subject: [PATCH] fix sodium compat --- build.gradle | 2 +- .../fluid/SodiumPortalFluidRenderHandler.java | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 6f8228d..1b8a040 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,7 @@ dependencies { modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}" include "maven.modrinth:midnightlib:${project.midnightlib_version}" - modCompileOnly("maven.modrinth:sodium:${project.sodium_version}") + modImplementation("maven.modrinth:sodium:${project.sodium_version}") } loom { diff --git a/src/main/java/quimufu/colourful_portals/client/rendering/fluid/SodiumPortalFluidRenderHandler.java b/src/main/java/quimufu/colourful_portals/client/rendering/fluid/SodiumPortalFluidRenderHandler.java index ba37189..5133505 100644 --- a/src/main/java/quimufu/colourful_portals/client/rendering/fluid/SodiumPortalFluidRenderHandler.java +++ b/src/main/java/quimufu/colourful_portals/client/rendering/fluid/SodiumPortalFluidRenderHandler.java @@ -31,6 +31,7 @@ public class SodiumPortalFluidRenderHandler implements VertexEater { private int i; private ChunkModelBuilder chunkModelBuilder; private Material material; + private Vector3f rotBuffer = new Vector3f(); public SodiumPortalFluidRenderHandler() { } @@ -39,8 +40,8 @@ public class SodiumPortalFluidRenderHandler implements VertexEater { material = DefaultMaterials.forFluidState(fluidState); this.chunkModelBuilder = buffers.get(material); Vector3f vOffset = new Vector3f(offset.getX(), offset.getY(), offset.getZ()); - vOffset.add(0.5f,0.5f,0.5f); - return commonPortalFluidRenderer.render(world,fluidState,pos, vOffset,this); + vOffset.add(0.5f, 0.5f, 0.5f); + return commonPortalFluidRenderer.render(world, fluidState, pos, vOffset, this); } @@ -56,23 +57,24 @@ public class SodiumPortalFluidRenderHandler implements VertexEater { quad.setZ(i, z); quad.setTexU(i, u); quad.setTexV(i, v); - i = (i+1)%4; + i = (i + 1) % 4; } @Override public void drawQuad(Vector3f offset, Quaternionf rot, Direction direction) { - writeQuad(chunkModelBuilder, material, offset, quad, ModelQuadFacing.fromDirection(direction), false); + writeQuad(chunkModelBuilder, material, offset, quad, rot, ModelQuadFacing.fromDirection(direction), false); } - private void writeQuad(ChunkModelBuilder builder, Material material, Vector3f offset, ModelQuadView quad, ModelQuadFacing facing, boolean flip) { + private void writeQuad(ChunkModelBuilder builder, Material material, Vector3f offset, ModelQuadView quad, Quaternionf rot, ModelQuadFacing facing, boolean flip) { var vertices = this.vertices; for (int i = 0; i < 4; i++) { var out = vertices[flip ? 3 - i : i]; - out.x = offset.x + quad.getX(i); - out.y = offset.y + quad.getY(i); - out.z = offset.z + quad.getZ(i); + rot.transform(quad.getX(i), quad.getY(i), quad.getZ(i), rotBuffer); + out.x = offset.x + rotBuffer.x; + out.y = offset.y + rotBuffer.y; + out.z = offset.z + rotBuffer.z; out.color = 0xFFFFFFFF; out.u = quad.getTexU(i); out.v = quad.getTexV(i); @@ -90,5 +92,4 @@ public class SodiumPortalFluidRenderHandler implements VertexEater { } - }