From c3b52281358bda01d3d080208dbea3d68aa720ea Mon Sep 17 00:00:00 2001 From: DeadVoxelx Date: Wed, 29 Apr 2026 10:28:51 -0400 Subject: [PATCH] Update PlayerChunkMap.cpp --- Minecraft.Client/PlayerChunkMap.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Minecraft.Client/PlayerChunkMap.cpp b/Minecraft.Client/PlayerChunkMap.cpp index ee8afac8..da310248 100644 --- a/Minecraft.Client/PlayerChunkMap.cpp +++ b/Minecraft.Client/PlayerChunkMap.cpp @@ -792,6 +792,14 @@ void PlayerChunkMap::setRadius(int newRadius) int xc = static_cast(player->x) >> 4; int zc = static_cast(player->z) >> 4; + for (auto it = addRequests.begin(); it != addRequests.end(); ) + { + if (it->player == player) + it = addRequests.erase(it); + else + ++it; + } + for (int x = xc - newRadius; x <= xc + newRadius; x++) for (int z = zc - newRadius; z <= zc + newRadius; z++) { @@ -801,6 +809,18 @@ void PlayerChunkMap::setRadius(int newRadius) getChunkAndAddPlayer(x, z, player); } } + + // Remove chunks that are outside the new radius + for (int x = xc - radius; x <= xc + radius; x++) + { + for (int z = zc - radius; z <= zc + radius; z++) + { + if (x < xc - newRadius || x > xc + newRadius || z < zc - newRadius || z > zc + newRadius) + { + getChunkAndRemovePlayer(x, z, player); + } + } + } } }