Пример #1
0
        private static List <Palette> ParsePalettes(NbtCompoundTag nbt)
        {
            nbt.TryGetValue("Palette", out var paletteValue);
            var palette = (NbtCompoundTag)paletteValue;

            List <Palette> palettes = new List <Palette>();

            foreach (var item in palette)
            {
                var name = item.Key;
                Dictionary <string, string> properties = new Dictionary <string, string>();
                var propertyPosition = item.Key.IndexOf("[");
                if (propertyPosition != -1)
                {
                    name = item.Key.Substring(0, propertyPosition);
                    var propertyString = item.Key.Substring(propertyPosition + 1);
                    propertyString = propertyString.Remove(propertyString.Length - 1, 1);
                    var propertiesArray = propertyString.Split(',');

                    foreach (var property in propertiesArray)
                    {
                        var pair = property.Split('=');

                        properties.Add(pair[0], pair[1]);
                    }
                }

                var intValue = int.Parse(item.Value.ToString());
                palettes.Add(new Palette {
                    MinecraftId = name, Properties = properties, SchemBlockId = intValue
                });
            }

            return(palettes);
        }
Пример #2
0
        private static List <int> ParseBlockData(NbtCompoundTag nbt)
        {
            nbt.TryGetValue("BlockData", out var blockDataValue);
            var blockDataNBT   = (NbtByteArrayTag)blockDataValue;
            var blockDataBytes = blockDataNBT.Payload;

            var blockData = ParseBlockDataVarInts(blockDataBytes);

            return(blockData.ToList());
        }