Skip to content

Commit

Permalink
Use modern java for Chunk::areNeighborsLoaded
Browse files Browse the repository at this point in the history
  • Loading branch information
iamnoksio authored Aug 13, 2024
1 parent 5ee2755 commit fad0be5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions nPaper-Server/src/main/java/net/minecraft/server/Chunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ public ChunkMap getChunkMap(boolean groundUpContinuous, int primaryBitMask, int
private int neighbors = 0x1 << 12;

public boolean areNeighborsLoaded(final int radius) {
switch(radius) {
case 2:
return this.neighbors == Integer.MAX_VALUE >> 6;
case 1:
return switch(radius) {
case 2 -> this.neighbors == Integer.MAX_VALUE >> 6;
case 1 -> {
final byte offset = 12;
final int mask =
// x z offset x z offset x z offset
( 0x1 << (1 * 5 + 1 + 12) ) | ( 0x1 << (0 * 5 + 1 + 12) ) | ( 0x1 << (-1 * 5 + 1 + 12) ) |
( 0x1 << (1 * 5 + 0 + 12) ) | ( 0x1 << (0 * 5 + 0 + 12) ) | ( 0x1 << (-1 * 5 + 0 + 12) ) |
( 0x1 << (1 * 5 + -1 + 12) ) | ( 0x1 << (0 * 5 + -1 + 12) ) | ( 0x1 << (-1 * 5 + -1 + 12) );
return (this.neighbors & mask) == mask;
default:
throw new UnsupportedOperationException(String.valueOf(radius));
( 0x1 << (1 * 5 + 1 + offset) ) | ( 0x1 << (0 * 5 + 1 + offset) ) | ( 0x1 << (-1 * 5 + 1 + offset) ) |
( 0x1 << (1 * 5 + 0 + offset) ) | ( 0x1 << (0 * 5 + 0 + offset) ) | ( 0x1 << (-1 * 5 + 0 + offset) ) |
( 0x1 << (1 * 5 + -1 + offset) ) | ( 0x1 << (0 * 5 + -1 + offset) ) | ( 0x1 << (-1 * 5 + -1 + offset) );
yield (this.neighbors & mask) == mask;
}
default -> throw new UnsupportedOperationException(String.valueOf(radius));
}
}

Expand Down

0 comments on commit fad0be5

Please sign in to comment.