void ParseMetadata(NbtCompound children)
        {
            NbtCompound metadata = (NbtCompound)children["Metadata"].Value;
            NbtTag      cpeTag;
            LocalPlayer p = game.LocalPlayer;

            if (!metadata.TryGetValue("CPE", out cpeTag))
            {
                return;
            }

            metadata = (NbtCompound)cpeTag.Value;
            if (CheckKey("ClickDistance", 1, metadata))
            {
                p.ReachDistance = (short)curCpeExt["Distance"].Value / 32f;
            }
            if (CheckKey("EnvColors", 1, metadata))
            {
                map.SetSkyColour(GetColour("Sky", Map.DefaultSkyColour));
                map.SetCloudsColour(GetColour("Cloud", Map.DefaultCloudsColour));
                map.SetFogColour(GetColour("Fog", Map.DefaultFogColour));
                map.SetSunlight(GetColour("Sunlight", Map.DefaultSunlight));
                map.SetShadowlight(GetColour("Ambient", Map.DefaultShadowlight));
            }
            if (CheckKey("EnvMapAppearance", 1, metadata))
            {
                if (curCpeExt.ContainsKey("TextureURL"))
                {
                    map.TextureUrl = (string)curCpeExt["TextureURL"].Value;
                }
                byte sidesBlock = (byte)curCpeExt["SideBlock"].Value;
                byte edgeBlock  = (byte)curCpeExt["EdgeBlock"].Value;
                map.SetSidesBlock((Block)sidesBlock);
                map.SetEdgeBlock((Block)edgeBlock);
                map.SetEdgeLevel((short)curCpeExt["SideLevel"].Value);
            }
            if (CheckKey("EnvWeatherType", 1, metadata))
            {
                byte weather = (byte)curCpeExt["WeatherType"].Value;
                map.SetWeather((Weather)weather);
            }

            if (game.AllowCustomBlocks && CheckKey("BlockDefinitions", 1, metadata))
            {
                foreach (var pair in curCpeExt)
                {
                    if (pair.Value.TagId != NbtTagType.Compound)
                    {
                        continue;
                    }
                    if (!Utils.CaselessStarts(pair.Key, "Block"))
                    {
                        continue;
                    }
                    ParseBlockDefinition((NbtCompound)pair.Value.Value);
                }
            }
        }
Esempio n. 2
0
        void ParseMetadata(Dictionary <string, NbtTag> children)
        {
            Dictionary <string, NbtTag> metadata = (Dictionary <string, NbtTag>)children["Metadata"].Value;
            NbtTag      cpeTag;
            LocalPlayer p = game.LocalPlayer;

            if (!metadata.TryGetValue("CPE", out cpeTag))
            {
                return;
            }

            metadata = (Dictionary <string, NbtTag>)cpeTag.Value;
            if (CheckKey("ClickDistance", 1, metadata))
            {
                p.ReachDistance = (short)curCpeExt["Distance"].Value / 32f;
            }
            if (CheckKey("EnvColors", 1, metadata))
            {
                map.SetSkyColour(GetColour("Sky", Map.DefaultSkyColour));
                map.SetCloudsColour(GetColour("Cloud", Map.DefaultCloudsColour));
                map.SetFogColour(GetColour("Fog", Map.DefaultFogColour));
                map.SetSunlight(GetColour("Sunlight", Map.DefaultSunlight));
                map.SetShadowlight(GetColour("Ambient", Map.DefaultShadowlight));
            }
            if (CheckKey("EnvMapAppearance", 1, metadata))
            {
                string url        = (string)curCpeExt["TextureURL"].Value;
                byte   sidesBlock = (byte)curCpeExt["SideBlock"].Value;
                byte   edgeBlock  = (byte)curCpeExt["EdgeBlock"].Value;
                map.SetSidesBlock((Block)sidesBlock);
                map.SetEdgeBlock((Block)edgeBlock);
                map.SetEdgeLevel((short)curCpeExt["SideLevel"].Value);
            }
            if (CheckKey("EnvWeatherType", 1, metadata))
            {
                byte weather = (byte)curCpeExt["WeatherType"].Value;
                map.SetWeather((Weather)weather);
            }
        }