mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Trim
This commit is contained in:
parent
9089bb4cdb
commit
0a689e407e
3 changed files with 21 additions and 27 deletions
|
|
@ -46,7 +46,7 @@ namespace MinecraftClient.Mapping
|
|||
{
|
||||
Tuple<int, int> chunkCoord = new(chunkX, chunkZ);
|
||||
if (value == null)
|
||||
chunks.Remove(chunkCoord, out _);
|
||||
chunks.TryRemove(chunkCoord, out _);
|
||||
else
|
||||
chunks.AddOrUpdate(chunkCoord, value, (_, _) => value);
|
||||
}
|
||||
|
|
@ -83,10 +83,16 @@ namespace MinecraftClient.Mapping
|
|||
/// <param name="loadCompleted">Whether the ChunkColumn has been fully loaded</param>
|
||||
public void StoreChunk(int chunkX, int chunkY, int chunkZ, int chunkColumnSize, Chunk? chunk, bool loadCompleted)
|
||||
{
|
||||
ChunkColumn chunkColumn = chunks.GetOrAdd(new(chunkX, chunkZ), (_) => new(chunkColumnSize));
|
||||
chunkColumn[chunkY] = chunk;
|
||||
if (loadCompleted)
|
||||
chunkColumn.FullyLoaded = true;
|
||||
Tuple<int, int> chunkCoord = new(chunkX, chunkZ);
|
||||
if (chunk == null)
|
||||
chunks.TryRemove(chunkCoord, out _);
|
||||
else
|
||||
{
|
||||
ChunkColumn chunkColumn = chunks.GetOrAdd(chunkCoord, (_) => new(chunkColumnSize));
|
||||
chunkColumn[chunkY] = chunk;
|
||||
if (loadCompleted)
|
||||
chunkColumn.FullyLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -191,12 +191,12 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
y = (int)((locEncoded >> 26) & 0xFFF);
|
||||
z = (int)(locEncoded << 38 >> 38);
|
||||
}
|
||||
if (x >= 33554432)
|
||||
x -= 67108864;
|
||||
if (y >= 2048)
|
||||
y -= 4096;
|
||||
if (z >= 33554432)
|
||||
z -= 67108864;
|
||||
if (x >= 0x02000000) // 33,554,432
|
||||
x -= 0x04000000; // 67,108,864
|
||||
if (y >= 0x00000800) // 2048
|
||||
y -= 0x00001000; // 4096
|
||||
if (z >= 0x02000000) // 33,554,432
|
||||
z -= 0x04000000; // 67,108,864
|
||||
return new Location(x, y, z);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,10 +189,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
Chunk? chunk = ReadBlockStatesField(cache);
|
||||
|
||||
//We have our chunk, save the chunk into the world
|
||||
handler.InvokeOnMainThread(() =>
|
||||
{
|
||||
world.StoreChunk(chunkX, chunkY, chunkZ, chunkColumnSize, chunk, chunkY == lastChunkY);
|
||||
});
|
||||
world.StoreChunk(chunkX, chunkY, chunkZ, chunkColumnSize, chunk, chunkY == lastChunkY);
|
||||
|
||||
// Skip Read Biomes (Type: Paletted Container) - 1.18(1.18.1) and above
|
||||
if (protocolversion >= Protocol18Handler.MC_1_18_1_Version)
|
||||
|
|
@ -364,10 +361,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
|
||||
//We have our chunk, save the chunk into the world
|
||||
handler.InvokeOnMainThread(() =>
|
||||
{
|
||||
world.StoreChunk(chunkX, chunkY, chunkZ, chunkColumnSize, chunk, chunkY == maxChunkY);
|
||||
});
|
||||
world.StoreChunk(chunkX, chunkY, chunkZ, chunkColumnSize, chunk, chunkY == maxChunkY);
|
||||
|
||||
//Pre-1.14 Lighting data
|
||||
if (protocolversion < Protocol18Handler.MC_1_14_Version)
|
||||
|
|
@ -415,10 +409,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
chunk.SetWithoutCheck(blockX, blockY, blockZ, new Block(queue.Dequeue()));
|
||||
|
||||
//We have our chunk, save the chunk into the world
|
||||
handler.InvokeOnMainThread(() =>
|
||||
{
|
||||
world.StoreChunk(chunkX, chunkY, chunkZ, chunkColumnSize, chunk, chunkY == maxChunkY);
|
||||
});
|
||||
world.StoreChunk(chunkX, chunkY, chunkZ, chunkColumnSize, chunk, chunkY == maxChunkY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -497,10 +488,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
for (int blockX = 0; blockX < Chunk.SizeX; blockX++)
|
||||
chunk.SetWithoutCheck(blockX, blockY, blockZ, new Block(blockTypes.Dequeue(), blockMeta.Dequeue()));
|
||||
|
||||
handler.InvokeOnMainThread(() =>
|
||||
{
|
||||
world.StoreChunk(chunkX, chunkY, chunkZ, chunkColumnSize, chunk, chunkY == maxChunkY);
|
||||
});
|
||||
world.StoreChunk(chunkX, chunkY, chunkZ, chunkColumnSize, chunk, chunkY == maxChunkY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue