13
0
geforkt von Mirrors/Paper

Fix block key with negative y unpacking (#7219)

Fixes #7218
Dieser Commit ist enthalten in:
Nassim Jahnke 2021-12-29 10:34:38 +01:00
Ursprung 3d1ddee8a7
Commit 7a47d06a49

Datei anzeigen

@ -104,7 +104,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Computed via: {@code Block.getBlockKey(this.getX(), this.getY(), this.getZ())}
+ * @see Block#getBlockKey(int, int, int)
+ * @return This block's x, y, and z coordinates packed into a long value
+ * @deprecated see {@link #getBlockKey(int, int, int)}
+ */
+ @Deprecated
+ public default long getBlockKey() {
+ return Block.getBlockKey(this.getX(), this.getY(), this.getZ());
+ }
@ -122,13 +124,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <br>
+ * {@code int x = (int) ((packed << 37) >> 37);}
+ * <br>
+ * {@code int y = (int) (packed >>> 54);}
+ * {@code int y = (int) (packed >> 54);}
+ * <br>
+ * {@code int z = (int) ((packed << 10) >> 37);}
+ * </p>
+ *
+ * @return This block's x, y, and z coordinates packed into a long value
+ * @deprecated only encodes y block ranges from -512 to 511 and represents an already changed implementation detail
+ */
+ @Deprecated
+ public static long getBlockKey(int x, int y, int z) {
+ return ((long)x & 0x7FFFFFF) | (((long)z & 0x7FFFFFF) << 27) | ((long)y << 54);
+ }
@ -138,7 +142,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param packed The packed value, as computed by {@link Block#getBlockKey(int, int, int)}
+ * @see Block#getBlockKey(int, int, int)
+ * @return The x component from the packed value.
+ * @deprecated see {@link #getBlockKey(int, int, int)}
+ */
+ @Deprecated
+ public static int getBlockKeyX(long packed) {
+ return (int) ((packed << 37) >> 37);
+ }
@ -148,9 +154,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param packed The packed value, as computed by {@link Block#getBlockKey(int, int, int)}
+ * @see Block#getBlockKey(int, int, int)
+ * @return The y component from the packed value.
+ * @deprecated see {@link #getBlockKey(int, int, int)}
+ */
+ @Deprecated
+ public static int getBlockKeyY(long packed) {
+ return (int) (packed >>> 54);
+ return (int) (packed >> 54);
+ }
+
+ /**
@ -158,7 +166,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param packed The packed value, as computed by {@link Block#getBlockKey(int, int, int)}
+ * @see Block#getBlockKey(int, int, int)
+ * @return The z component from the packed value.
+ * @deprecated see {@link #getBlockKey(int, int, int)}
+ */
+ @Deprecated
+ public static int getBlockKeyZ(long packed) {
+ return (int) ((packed << 10) >> 37);
+ }