Skip to content

Commit

Permalink
Fixed cloud culling
Browse files Browse the repository at this point in the history
  • Loading branch information
1foxy2 committed Dec 14, 2024
1 parent 431a1f0 commit 369d110
Showing 1 changed file with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,32 @@ private static boolean isEastEmpty(long l) {
return false;
}

@Inject(
method = "buildMesh(Lnet/minecraft/client/renderer/CloudRenderer$RelativeCameraPos;Lcom/mojang/blaze3d/vertex/BufferBuilder;IIIIIIZ)V",
at = @At(value = "HEAD")
)
private void moreculling$enableCull(CloudRenderer.RelativeCameraPos p_363221_, BufferBuilder p_364486_,
int p_361006_, int p_362674_, int p_362100_, int p_360889_, int p_360776_,
int p_365003_, boolean p_362207_, CallbackInfo ci) {
if (p_362207_ && MoreCulling.CONFIG.cloudCulling)
RenderSystem.enableCull();
}

@Inject(
method = "buildExtrudedCell",
at = @At(value = "HEAD"),
cancellable = true
)
private void moreculling$renderClouds(CloudRenderer.RelativeCameraPos relativeCameraPos,
BufferBuilder bufferBuilder, int i, int j, int k,
int l, int m, int n, long o, CallbackInfo ci) {
private void moreculling$renderClouds(
CloudRenderer.RelativeCameraPos relativeCameraPos,
BufferBuilder bufferBuilder,
int i,
int j,
int k,
int l,
int m,
int n,
long o, CallbackInfo ci) {
if (!MoreCulling.CONFIG.cloudCulling) {
return;
}
Expand All @@ -58,10 +76,10 @@ private static boolean isEastEmpty(long l) {
float q = (float)n * 12.0F;
float r = q + 12.0F;
if (relativeCameraPos != CloudRenderer.RelativeCameraPos.BELOW_CLOUDS) {
bufferBuilder.addVertex(g, 4.0F, q).setColor(j);
bufferBuilder.addVertex(g, 4.0F, r).setColor(j);
bufferBuilder.addVertex(f, 4.0F, r).setColor(j);
bufferBuilder.addVertex(g, 4.0F, q).setColor(j);
bufferBuilder.addVertex(f, 4.0F, q).setColor(j);
bufferBuilder.addVertex(f, 4.0F, r).setColor(j);
}

if (relativeCameraPos != CloudRenderer.RelativeCameraPos.ABOVE_CLOUDS) {
Expand All @@ -79,10 +97,10 @@ private static boolean isEastEmpty(long l) {
}

if (isSouthEmpty(o) && n < 0) {
bufferBuilder.addVertex(f, 0.0F, r).setColor(l);
bufferBuilder.addVertex(f, 4.0F, r).setColor(l);
bufferBuilder.addVertex(g, 4.0F, r).setColor(l);
bufferBuilder.addVertex(f, 0.0F, r).setColor(l);
bufferBuilder.addVertex(g, 0.0F, r).setColor(l);
bufferBuilder.addVertex(g, 4.0F, r).setColor(l);
}

if (isWestEmpty(o) && m > 0) {
Expand All @@ -93,10 +111,10 @@ private static boolean isEastEmpty(long l) {
}

if (isEastEmpty(o) && m < 0) {
bufferBuilder.addVertex(g, 0.0F, r).setColor(k);
bufferBuilder.addVertex(g, 4.0F, r).setColor(k);
bufferBuilder.addVertex(g, 4.0F, q).setColor(k);
bufferBuilder.addVertex(g, 0.0F, r).setColor(k);
bufferBuilder.addVertex(g, 0.0F, q).setColor(k);
bufferBuilder.addVertex(g, 4.0F, q).setColor(k);
}

boolean bl = Math.abs(m) <= 1 && Math.abs(n) <= 1;
Expand Down

0 comments on commit 369d110

Please sign in to comment.