fix sodium compat

This commit is contained in:
QuImUfu 2024-10-11 20:57:23 +02:00
parent 7aefd13755
commit a9ce715750
2 changed files with 11 additions and 10 deletions

View File

@ -66,7 +66,7 @@ dependencies {
modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}" modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"
include "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 { loom {

View File

@ -31,6 +31,7 @@ public class SodiumPortalFluidRenderHandler implements VertexEater {
private int i; private int i;
private ChunkModelBuilder chunkModelBuilder; private ChunkModelBuilder chunkModelBuilder;
private Material material; private Material material;
private Vector3f rotBuffer = new Vector3f();
public SodiumPortalFluidRenderHandler() { public SodiumPortalFluidRenderHandler() {
} }
@ -39,8 +40,8 @@ public class SodiumPortalFluidRenderHandler implements VertexEater {
material = DefaultMaterials.forFluidState(fluidState); material = DefaultMaterials.forFluidState(fluidState);
this.chunkModelBuilder = buffers.get(material); this.chunkModelBuilder = buffers.get(material);
Vector3f vOffset = new Vector3f(offset.getX(), offset.getY(), offset.getZ()); Vector3f vOffset = new Vector3f(offset.getX(), offset.getY(), offset.getZ());
vOffset.add(0.5f,0.5f,0.5f); vOffset.add(0.5f, 0.5f, 0.5f);
return commonPortalFluidRenderer.render(world,fluidState,pos, vOffset,this); return commonPortalFluidRenderer.render(world, fluidState, pos, vOffset, this);
} }
@ -56,23 +57,24 @@ public class SodiumPortalFluidRenderHandler implements VertexEater {
quad.setZ(i, z); quad.setZ(i, z);
quad.setTexU(i, u); quad.setTexU(i, u);
quad.setTexV(i, v); quad.setTexV(i, v);
i = (i+1)%4; i = (i + 1) % 4;
} }
@Override @Override
public void drawQuad(Vector3f offset, Quaternionf rot, Direction direction) { 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; var vertices = this.vertices;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
var out = vertices[flip ? 3 - i : i]; var out = vertices[flip ? 3 - i : i];
out.x = offset.x + quad.getX(i); rot.transform(quad.getX(i), quad.getY(i), quad.getZ(i), rotBuffer);
out.y = offset.y + quad.getY(i); out.x = offset.x + rotBuffer.x;
out.z = offset.z + quad.getZ(i); out.y = offset.y + rotBuffer.y;
out.z = offset.z + rotBuffer.z;
out.color = 0xFFFFFFFF; out.color = 0xFFFFFFFF;
out.u = quad.getTexU(i); out.u = quad.getTexU(i);
out.v = quad.getTexV(i); out.v = quad.getTexV(i);
@ -90,5 +92,4 @@ public class SodiumPortalFluidRenderHandler implements VertexEater {
} }
} }