mirror of
https://github.com/Brettflan/WorldBorder.git
synced 2024-11-26 12:05:26 +01:00
fix for longstanding issue of chunks which didn't exist in a region file still being unnecessarily wiped by the Trim process, also adding to the reported number of individual trimmed chunks. Now chunks which were already nonexistent aren't "trimmed" for no reason and the reported number of individual trimmed chunks is exactly correct.
This commit is contained in:
parent
0a827e69e8
commit
893701637a
@ -275,23 +275,30 @@ public class WorldTrimTask implements Runnable
|
||||
int offsetX = CoordXZ.regionToChunk(regionX);
|
||||
int offsetZ = CoordXZ.regionToChunk(regionZ);
|
||||
long wipePos = 0;
|
||||
int chunkCount = 0;
|
||||
|
||||
try
|
||||
{
|
||||
RandomAccessFile unChunk = new RandomAccessFile(regionFile, "rwd");
|
||||
for (CoordXZ wipe : trimChunks)
|
||||
{ // wipe this extraneous chunk's pointer... note that this method isn't perfect since the actual chunk data is left orphaned,
|
||||
{
|
||||
// if the chunk pointer is empty (chunk doesn't technically exist), no need to wipe the already empty pointer
|
||||
if (!worldData.doesChunkExist(wipe.x, wipe.z))
|
||||
continue;
|
||||
|
||||
// wipe this extraneous chunk's pointer... note that this method isn't perfect since the actual chunk data is left orphaned,
|
||||
// but Minecraft will overwrite the orphaned data sector if/when another chunk is created in the region, so it's not so bad
|
||||
wipePos = 4 * ((wipe.x - offsetX) + ((wipe.z - offsetZ) * 32));
|
||||
unChunk.seek(wipePos);
|
||||
unChunk.writeInt(0);
|
||||
chunkCount++;
|
||||
}
|
||||
unChunk.close();
|
||||
|
||||
// if DynMap is installed, re-render the trimmed chunks ... disabled since it's not currently working, oh well
|
||||
// DynMapFeatures.renderChunks(world.getName(), trimChunks);
|
||||
|
||||
reportTrimmedChunks += trimChunks.size();
|
||||
reportTrimmedChunks += chunkCount;
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user