byte cannot be used to represent height anymore (#1618)

Fixes #1593
This commit is contained in:
Jordan 2022-02-17 19:34:25 +01:00 committed by GitHub
parent f7a0c14a1b
commit 39081e62c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -8,7 +8,7 @@ public class ExtentHeightCacher extends PassthroughExtent {
private transient int cacheBotX = Integer.MIN_VALUE;
private transient int cacheBotZ = Integer.MIN_VALUE;
private transient byte[] cacheHeights;
private transient short[] cacheHeights;
private transient int lastY;
public ExtentHeightCacher(Extent extent) {
@ -19,7 +19,7 @@ public class ExtentHeightCacher extends PassthroughExtent {
cacheBotX = Integer.MIN_VALUE;
cacheBotZ = Integer.MIN_VALUE;
if (cacheHeights != null) {
Arrays.fill(cacheHeights, (byte) 0);
Arrays.fill(cacheHeights, (short) 0);
}
}
@ -36,9 +36,10 @@ public class ExtentHeightCacher extends PassthroughExtent {
rz = z - cacheBotZ + 16;
index = rx + (rz << 8);
if (cacheHeights == null) {
cacheHeights = new byte[65536];
cacheHeights = new short[65536];
Arrays.fill(cacheHeights, (short) minY);
} else {
Arrays.fill(cacheHeights, (byte) 0);
Arrays.fill(cacheHeights, (short) minY);
}
} else {
index = rx + (rz << 8);

View File

@ -24,7 +24,7 @@ public class AngleMask extends AbstractExtentMask implements ResettableMask {
protected final int distance;
protected transient int cacheBotX = Integer.MIN_VALUE;
protected transient int cacheBotZ = Integer.MIN_VALUE;
protected transient byte[] cacheHeights;
protected transient short[] cacheHeights;
protected transient int lastY;
protected transient int lastX = Integer.MIN_VALUE;
protected transient int lastZ = Integer.MIN_VALUE;
@ -65,14 +65,15 @@ public class AngleMask extends AbstractExtentMask implements ResettableMask {
rz = z - cacheBotZ + 16;
index = rx + (rz << 8);
if (cacheHeights == null) {
cacheHeights = new byte[65536];
cacheHeights = new short[65536];
Arrays.fill(cacheHeights, (short) minY);
} else {
Arrays.fill(cacheHeights, (byte) 0);
Arrays.fill(cacheHeights, (short) minY);
}
} else {
index = rx + (rz << 8);
}
int result = cacheHeights[index] & 0xFF;
int result = cacheHeights[index];
if (y > result) {
cacheHeights[index] = (byte) (result = lastY = extent.getNearestSurfaceTerrainBlock(x, z, lastY, minY, maxY));
}