Пример #1
0
        public override void HandleMcpeLevelChunk(McpeLevelChunk message)
        {
            var coord      = new ChunkCoordinates(message.chunkX, message.chunkZ);
            int chunkCount = (int)message.subChunkCount;

            byte[] data = message.chunkData;

            Client.Chunks.GetOrAdd(coord, _ =>
            {
                ChunkColumn chunk = null;
                try
                {
                    chunk = ClientUtils.DecodeChunkColumn(chunkCount, data, BlockPalette, _internalStates);
                    if (chunk != null)
                    {
                        chunk.X = coord.X;
                        chunk.Z = coord.Z;
                        chunk.RecalcHeight();
                    }
                }
                catch (Exception e)
                {
                    Log.Error($"Reading chunk {coord}", e);
                }

                return(chunk);
            });
        }
Пример #2
0
        public override void HandleMcpeLevelChunk(McpeLevelChunk message)
        {
            // TODO doesn't work anymore I guess
            if (Client.IsEmulator)
            {
                return;
            }

            if (message.cacheEnabled)
            {
                var hits = new ulong[message.blobHashes.Length];

                for (int i = 0; i < message.blobHashes.Length; i++)
                {
                    ulong hash = message.blobHashes[i];
                    hits[i] = hash;
                    Log.Debug($"Got hashes for {message.chunkX}, {message.chunkZ}, {hash}");
                }

                var status = McpeClientCacheBlobStatus.CreateObject();
                status.hashHits = hits;
                Client.SendPacket(status);
            }
            else
            {
                Client.Chunks.GetOrAdd(new ChunkCoordinates(message.chunkX, message.chunkZ), coordinates =>
                {
                    Log.Debug($"Chunk X={message.chunkX}, Z={message.chunkZ}, size={message.chunkData.Length}, Count={Client.Chunks.Count}");

                    ChunkColumn chunk = null;
                    try
                    {
                        chunk = ClientUtils.DecodeChunkColumn((int)message.subChunkCount, message.chunkData);
                        if (chunk != null)
                        {
                            chunk.X = coordinates.X;
                            chunk.Z = coordinates.Z;
                            chunk.RecalcHeight();
                            Log.DebugFormat("Chunk X={0}, Z={1}", chunk.X, chunk.Z);
                            foreach (KeyValuePair <BlockCoordinates, NbtCompound> blockEntity in chunk.BlockEntities)
                            {
                                Log.Debug($"Blockentity: {blockEntity.Value}");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error("Reading chunk", e);
                    }

                    return(chunk);
                });
            }
        }
Пример #3
0
        private void RenderChunk(ChunkColumn chunk)
        {
            _renderedChunks.Add(new ChunkCoordinates(chunk.x, chunk.z));
            chunk.RecalcHeight();

            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    var meta = GetColumnMeta(chunk, x, z);
                    Map.UpdateBlockColumn(meta);
                }
            }
        }
Пример #4
0
        public override void HandleMcpeLevelChunk(McpeLevelChunk message)
        {
            if (!Client._chunks.ContainsKey(new Tuple <int, int>(message.chunkX, message.chunkZ)))
            {
                //Log.Debug($"Chunk X={message.chunkX}, Z={message.chunkZ}, size={message.chunkData.Length}, Count={Client._chunks.Count}");

                try
                {
                    ChunkColumn chunk = ClientUtils.DecodeChunkColumn((int)message.subChunkCount, message.chunkData, _blockPallet, _internalStates);
                    if (chunk != null)
                    {
                        chunk.x = message.chunkX;
                        chunk.z = message.chunkZ;
                        chunk.RecalcHeight();
                        Client._chunks.TryAdd(new Tuple <int, int>(message.chunkX, message.chunkZ), chunk);
                        //Log.Debug($"Added parsed bedrock chunk X={chunk.x}, Z={chunk.z}");
                    }
                }
                catch (Exception e)
                {
                    Log.Error("Reading chunk", e);
                }
            }
        }
Пример #5
0
        public override void HandleMcpeLevelChunk(McpeLevelChunk message)
        {
            // TODO doesn't work anymore I guess
            if (Client.IsEmulator)
            {
                return;
            }

            Client.Chunks.GetOrAdd(new ChunkCoordinates(message.chunkX, message.chunkZ), coordinates =>
            {
                Log.Debug($"Chunk X={message.chunkX}, Z={message.chunkZ}, size={message.chunkData.Length}, Count={Client.Chunks.Count}");

                ChunkColumn chunk = null;
                try
                {
                    chunk = ClientUtils.DecodeChunkColumn((int)message.subChunkCount, message.chunkData);
                    if (chunk != null)
                    {
                        chunk.X = coordinates.X;
                        chunk.Z = coordinates.Z;
                        chunk.RecalcHeight();
                        Log.DebugFormat("Chunk X={0}, Z={1}", chunk.X, chunk.Z);
                        foreach (KeyValuePair <BlockCoordinates, NbtCompound> blockEntity in chunk.BlockEntities)
                        {
                            Log.Debug($"Blockentity: {blockEntity.Value}");
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Error("Reading chunk", e);
                }

                return(chunk);
            });
        }