3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +01:00

Add static chunkKey method in ChunkPosition

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-11-06 20:17:42 +10:00
Ursprung 2881fb18e0
Commit 58ca2024e1

Datei anzeigen

@ -28,12 +28,12 @@ public final class ChunkPosition {
private final int chunkX;
private final int chunkZ;
public ChunkPosition(int chunkX, int chunkZ) {
public ChunkPosition(final int chunkX, final int chunkZ) {
this.chunkX = chunkX;
this.chunkZ = chunkZ;
}
public ChunkPosition(long chunkKey) {
public ChunkPosition(final long chunkKey) {
this.chunkX = (int) chunkKey;
this.chunkZ = (int) (chunkKey >> 32);
}
@ -46,15 +46,31 @@ public final class ChunkPosition {
return chunkZ;
}
/**
* Returns a long key for this chunk position.
*
* @return the chunk key
*/
public long chunkKey() {
return chunkKey(chunkX, chunkZ);
}
/**
* Returns a long key for the given chunk coordinates.
*
* @param chunkX the chunk X coordinate
* @param chunkZ the chunk Z coordinate
* @return the chunk key
*/
public static long chunkKey(final int chunkX, final int chunkZ) {
return (long) chunkX & 0xffffffffL | ((long) chunkZ & 0xffffffffL) << 32;
}
@Override
public boolean equals(Object o) {
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ChunkPosition that = (ChunkPosition) o;
final ChunkPosition that = (ChunkPosition) o;
return chunkX == that.chunkX && chunkZ == that.chunkZ;
}