From 39081e62c95450a098004cef335acc54ab32a795 Mon Sep 17 00:00:00 2001 From: Jordan Date: Thu, 17 Feb 2022 19:34:25 +0100 Subject: [PATCH] byte cannot be used to represent height anymore (#1618) Fixes #1593 --- .../core/extent/ExtentHeightCacher.java | 9 +++++---- .../fastasyncworldedit/core/function/mask/AngleMask.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ExtentHeightCacher.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ExtentHeightCacher.java index dee157658..107360cc4 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ExtentHeightCacher.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ExtentHeightCacher.java @@ -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); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AngleMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AngleMask.java index 12deadc31..d7abc36a3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AngleMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AngleMask.java @@ -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)); }