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

Fixes #1593
Dieser Commit ist enthalten in:
Jordan 2022-02-17 19:34:25 +01:00 committet von GitHub
Ursprung f7a0c14a1b
Commit 39081e62c9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 10 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -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);

Datei anzeigen

@ -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));
}