Skip to content

Commit

Permalink
Fix fluid rendering issues
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jan 26, 2024
1 parent 8fea1ff commit 5d8886b
Showing 1 changed file with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ public void render(WorldSlice world, FluidState fluidState, BlockPos blockPos, B
if (velocity.x == 0.0D && velocity.z == 0.0D) {
sprite = sprites[0];
facing = ModelQuadFacing.POS_Y;
u1 = sprite.getFrameU(0.0f);
v1 = sprite.getFrameV(0.0f);
u1 = sprite.getFrameU(0.0D);
v1 = sprite.getFrameV(0.0D);
u2 = u1;
v2 = sprite.getFrameV(1.0f);
u3 = sprite.getFrameU(1.0f);
v2 = sprite.getFrameV(16.0D);
u3 = sprite.getFrameU(16.0D);
v3 = v2;
u4 = u3;
v4 = v1;
Expand All @@ -194,19 +194,21 @@ public void render(WorldSlice world, FluidState fluidState, BlockPos blockPos, B
float dir = (float) MathHelper.atan2(velocity.z, velocity.x) - (1.5707964f);
float sin = MathHelper.sin(dir) * 0.25F;
float cos = MathHelper.cos(dir) * 0.25F;
u1 = sprite.getFrameU(0.5F + (-cos - sin));
v1 = sprite.getFrameV(0.5F + -cos + sin);
u2 = sprite.getFrameU(0.5F + -cos + sin);
v2 = sprite.getFrameV(0.5F + cos + sin);
u3 = sprite.getFrameU(0.5F + cos + sin);
v3 = sprite.getFrameV(0.5F + (cos - sin));
u4 = sprite.getFrameU(0.5F + (cos - sin));
v4 = sprite.getFrameV(0.5F + (-cos - sin));
u1 = sprite.getFrameU(8.0F + (-cos - sin) * 16.0F);
v1 = sprite.getFrameV(8.0F + (-cos + sin) * 16.0F);
u2 = sprite.getFrameU(8.0F + (-cos + sin) * 16.0F);
v2 = sprite.getFrameV(8.0F + (cos + sin) * 16.0F);
u3 = sprite.getFrameU(8.0F + (cos + sin) * 16.0F);
v3 = sprite.getFrameV(8.0F + (cos - sin) * 16.0F);
u4 = sprite.getFrameU(8.0F + (cos - sin) * 16.0F);
v4 = sprite.getFrameV(8.0F + (-cos - sin) * 16.0F);
}

float uAvg = (u1 + u2 + u3 + u4) / 4.0F;
float vAvg = (v1 + v2 + v3 + v4) / 4.0F;
float s3 = sprites[0].getAnimationFrameDelta();
float s1 = (float) sprites[0].getContents().getWidth() / (sprites[0].getMaxU() - sprites[0].getMinU());
float s2 = (float) sprites[0].getContents().getHeight() / (sprites[0].getMaxV() - sprites[0].getMinV());
float s3 = 4.0F / Math.max(s2, s1);

u1 = MathHelper.lerp(s3, u1, uAvg);
u2 = MathHelper.lerp(s3, u2, uAvg);
Expand Down Expand Up @@ -333,11 +335,11 @@ public void render(WorldSlice world, FluidState fluidState, BlockPos blockPos, B
}
}

float u1 = sprite.getFrameU(0.0F);
float u2 = sprite.getFrameU(0.5F);
float v1 = sprite.getFrameV((1.0F - c1) * 0.5F);
float v2 = sprite.getFrameV((1.0F - c2) * 0.5F);
float v3 = sprite.getFrameV(0.5F);
float u1 = sprite.getFrameU(0.0D);
float u2 = sprite.getFrameU(8.0D);
float v1 = sprite.getFrameV((1.0F - c1) * 16.0F * 0.5F);
float v2 = sprite.getFrameV((1.0F - c2) * 16.0F * 0.5F);
float v3 = sprite.getFrameV(8.0D);

quad.setSprite(sprite);

Expand Down

0 comments on commit 5d8886b

Please sign in to comment.