Implement thread-safe ChatBot API (#1510, #1579)

+ Rework task scheduling in chatbots
+ Switch back terrain processing to tasks
This commit is contained in:
ORelio 2021-05-15 17:36:16 +02:00
parent c1cfaf520d
commit 95d6318350
7 changed files with 517 additions and 461 deletions

View file

@ -423,7 +423,7 @@ namespace MinecraftClient.Protocol.Handlers
int compressedDataSize = dataTypes.ReadNextInt(packetData);
byte[] compressed = dataTypes.ReadData(compressedDataSize, packetData);
byte[] decompressed = ZlibUtils.Decompress(compressed);
new Thread(() => {
new Task(() => {
pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, addBitmap, currentDimension == 0, chunksContinuous, currentDimension, new Queue<byte>(decompressed));
}).Start();
}
@ -449,7 +449,7 @@ namespace MinecraftClient.Protocol.Handlers
else dataTypes.ReadData(1024 * 4, packetData); // Biomes - 1.15 and above
}
int dataSize = dataTypes.ReadNextVarInt(packetData);
new Thread(() => {
new Task(() => {
pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, 0, false, chunksContinuous, currentDimension, packetData);
}).Start();
}