Skip to content

Commit

Permalink
feat: remove useless operation in HashUtils.hashChunkXYZ
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Oct 23, 2024
1 parent 80c3cf2 commit eb850be
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions api/src/main/java/org/allaymc/api/utils/HashUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,8 @@ public int hashChunkXYZ(int x, int y, int z) {
Preconditions.checkArgument(x >= 0 && x <= 15);
Preconditions.checkArgument(y >= -8388608 && y <= 8388607);
Preconditions.checkArgument(z >= 0 && z <= 15);
//Make sure x and z are in the range of 0-15
x &= 0xF; //4 bits
z &= 0xF; //4 bits
//Use the int type to store the result
int result = 0;
//Place x in the top 4 digits
result |= (x << 28);
//Place y in the middle 24 bits
result |= ((y + 8388608) & 0xFFFFFF) << 4;
//Place z in the lowest 4 digits
result |= z;
return result;
// Place x in the top 4 digits, y in the middle 24 bits, z in the lowest 4 digits
return (x << 28) | (((y + 8388608) & 0xFFFFFF) << 4) | z;
}

/**
Expand Down

0 comments on commit eb850be

Please sign in to comment.