Prevent modified clients from messing with the chunk range

This commit is contained in:
themode 2021-03-09 17:21:43 +01:00
parent 4bb04ba892
commit 51facb9f14

View File

@ -2326,15 +2326,15 @@ public class Player extends LivingEntity implements CommandSender {
* based on which one is the lowest
*/
public int getChunkRange() {
final int serverRange = MinecraftServer.getChunkViewDistance();
final int playerRange = getSettings().viewDistance;
if (playerRange == 0) {
if (playerRange < 1) {
// Didn't receive settings packet yet (is the case on login)
// In this case we send the smallest amount of chunks possible
// Will be updated in PlayerSettings#refresh.
// Non-compliant clients might also be stuck with this view
return 1;
} else {
final int serverRange = MinecraftServer.getChunkViewDistance();
return Math.min(playerRange, serverRange);
}
}