diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/tree/TraversableTree.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/tree/TraversableTree.java index a2a5c43b3f..a1dda59668 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/tree/TraversableTree.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/tree/TraversableTree.java @@ -63,10 +63,11 @@ public void traverse(SectionTree.VisibleSectionVisitor visitor, Viewport viewpor var transform = viewport.getTransform(); - // + 1 to section position to compensate for shifted global offset - this.cameraOffsetX = (transform.intX >> 4) - this.offsetX + 1; - this.cameraOffsetY = (transform.intY >> 4) - this.offsetY + 1; - this.cameraOffsetZ = (transform.intZ >> 4) - this.offsetZ + 1; + // + 1 to offset section position to compensate for shifted global offset + // adjust camera block position to account for fractional part of camera position + this.cameraOffsetX = ((transform.intX + (int) Math.signum(transform.fracX)) >> 4) - this.offsetX + 1; + this.cameraOffsetY = ((transform.intY + (int) Math.signum(transform.fracY)) >> 4) - this.offsetY + 1; + this.cameraOffsetZ = ((transform.intZ + (int) Math.signum(transform.fracZ)) >> 4) - this.offsetZ + 1; // everything is already inside the distance limit if the build distance is smaller var initialInside = this.distanceLimit >= buildDistance ? INSIDE_DISTANCE : 0;