+ WorldChunk worldChunk = ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) as WorldChunk;
+
+ if (worldChunk == null || worldChunk.BlockEntities == null)
+ {
+ #if DEBUG
+ Logger.VerboseDebug("WORLD chunk: null or empty X{0} Y{1} Z{2} !", key.X, targetChunkY, key.Y);
+ #endif
+ nullChunkCount++;
+ continue;
+ }
+
+ if (worldChunk.IsPacked())
+ {
+ #if DEBUG
+ Logger.VerboseDebug("WORLD chunk: Compressed: X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);
+ #endif
+ worldChunk.Unpack( );//RESEARCH: Thread Unsafe?
+ }
+
+ /*************** Chunk Entities Scanning *********************/
+ if (worldChunk.BlockEntities != null && worldChunk.BlockEntities.Count > 0)
+ {
+ #if DEBUG
+ Logger.VerboseDebug("Scan pos.({0}) for BlockEntities# {1}", key, worldChunk.BlockEntities.Count);
+ #endif
+
+ foreach (var blockEnt in worldChunk.BlockEntities)
+ {
+ if (blockEnt.Key != null && blockEnt.Value != null && blockEnt.Value.Block != null && BlockID_Designators.ContainsKey(blockEnt.Value.Block.BlockId))
+ {
+ var designator = BlockID_Designators[blockEnt.Value.Block.BlockId];
+ designator?.SpecialAction(ClientAPI, POIs, blockEnt.Value.Pos.Copy(), blockEnt.Value.Block);
+ }
+ }
+ }
+
+ /********************* Chunk/Column BLOCKs scanning ****************/
+ //Heightmap, Stats, block tally
+
+ int X_index, Y_index, Z_index;
+
+ //First Chance fail-safe;
+ if (worldChunk.Blocks == null || worldChunk.Blocks.Length <= 0) {
+ #if DEBUG
+ Logger.VerboseDebug("WORLD chunk; Missing block DATA⁈ X{0} Y{1} Z{2} ⁈", key.X, targetChunkY, key.Y);
+ #endif
+ nullChunkCount++;
+ continue;
+ }
+
+ chunkMeta.ColumnPresense[targetChunkY] = true;
+ chunkTally++;
+ for (Y_index = 0; Y_index < chunkSize; Y_index++)
+ {
+ for (Z_index = 0; Z_index < chunkSize; Z_index++)
+ {
+ for (X_index = 0; X_index < chunkSize; X_index++)
+ {
+ var indicie = MapUtil.Index3d(X_index, Y_index, Z_index, chunkSize, chunkSize);
+
+ //'Last' Chance fail-safe;
+ if (worldChunk.Blocks == null || worldChunk.Blocks.Length <= 0) {
+ #if DEBUG
+ Logger.VerboseDebug("Processing Block: Missing block DATA⁈ X{0} Y{1} Z{2} ⁈", X_index, Y_index, Z_index);
+ #endif
+ nullChunkCount++;
+ goto loop_bustout;
+ }
+
+ int aBlockId = worldChunk.Blocks[indicie];
+
+ if (aBlockId == 0 || AiryIdCodes.ContainsKey(aBlockId)) {//Airy blocks,,,
+ chunkMeta.AirBlocks++;
+ continue;
+ }
+
+ if (RockIdCodes.ContainsKey(aBlockId)) {
+ if (chunkMeta.RockRatio.ContainsKey(aBlockId))
+ chunkMeta.RockRatio[aBlockId]++;
+ else
+ chunkMeta.RockRatio.Add(aBlockId, 1);
+ }
+
+ chunkMeta.NonAirBlocks++;
+
+ ushort localHeight = ( ushort )(Y_index + (targetChunkY * chunkSize));
+ //Heightmap - Need to ignore Grass & Snow
+ if (localHeight > chunkMeta.HeightMap[X_index, Z_index])
+ {
+ chunkMeta.HeightMap[X_index, Z_index] = localHeight;
+ if (localHeight > chunkMeta.YMax) chunkMeta.YMax = localHeight;
+ }
+ }
+ }
+ }
+ loop_bustout:;