Skip to content

Commit 25954fa

Browse files
committed
feat: sort chunks
1 parent b60324a commit 25954fa

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎src/main/java/xyz/webmc/wlib/api/util/WorldUtil.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,18 @@ public static List<Chunk> getPlayerLoadedChunks(final Player plr) {
145145
}
146146
}
147147

148+
ret.sort((a, b) -> {
149+
final int ax = a.getX() - cx;
150+
final int az = a.getZ() - cz;
151+
final int bx = b.getX() - cx;
152+
final int bz = b.getZ() - cz;
153+
154+
return Integer.compare(
155+
ax * ax + az * az,
156+
bx * bx + bz * bz
157+
);
158+
});
159+
148160
return ret;
149161
}
150162

0 commit comments

Comments
 (0)