@@ -39,10 +39,9 @@ public final class SpongeChunkLayout implements ChunkLayout {
3939 private final Vector3i spaceSize ;
4040
4141 public SpongeChunkLayout (final int minY , final int height ) {
42- final var totalHeight = Math .abs (minY ) + height ;
43- this .size = new Vector3i (16 , totalHeight , 16 );
42+ this .size = new Vector3i (16 , height , 16 );
4443 this .mask = this .size .sub (1 , 1 , 1 );
45- this .spaceMax = new Vector3i (Constants .World .BLOCK_MAX .x (), height , Constants .World .BLOCK_MAX .z ()).sub (1 , 1 , 1 );
44+ this .spaceMax = new Vector3i (Constants .World .BLOCK_MAX .x (), minY + height , Constants .World .BLOCK_MAX .z ()).sub (1 , 1 , 1 );
4645 this .spaceMin = new Vector3i (Constants .World .BLOCK_MIN .x (), minY , Constants .World .BLOCK_MIN .z ());
4746 this .spaceSize = this .spaceMax .sub (this .spaceMin ).add (1 , 1 , 1 );
4847 }
@@ -88,17 +87,17 @@ public boolean isInChunk(final int x, final int y, final int z) {
8887
8988 @ Override
9089 public boolean isInChunk (final int wx , final int wy , final int wz , final int cx , final int cy , final int cz ) {
91- return this .isInChunk (wx - (cx << 4 ), wy - (cy << 8 ), wz - (cz << 4 ));
90+ return this .isInChunk (wx - (cx << 4 ), wy - Math . floorDiv (cy - this . spaceMin . y (), this . size . y () ), wz - (cz << 4 ));
9291 }
9392
9493 @ Override
9594 public Vector3i forceToChunk (final int x , final int y , final int z ) {
96- return new Vector3i (x >> 4 , y >> 8 , z >> 4 );
95+ return new Vector3i (x >> 4 , Math . floorDiv ( y - this . spaceMin . y (), this . size . y ()) , z >> 4 );
9796 }
9897
9998 @ Override
10099 public Vector3i forceToWorld (final int x , final int y , final int z ) {
101- return new Vector3i (x << 4 , y << 8 , z << 4 );
100+ return new Vector3i (x << 4 , ( y * this . size . y ()) + this . spaceMin . y () , z << 4 );
102101 }
103102
104103}
0 commit comments