Пример #1
0
        private static object DeserializeChild(Type type, NbtTag tag)
        {
            if (typeof(NbtTag).IsAssignableFrom(type))
            {
                tag      = (NbtTag)tag.Clone();
                tag.Name = null;
                return(tag);
            }

            var value = GetValueFromTag(tag, type);

            if (value != null)
            {
                return(value);
            }

            if (typeof(IList).IsAssignableFrom(type))
            {
                return(GetList(type, (NbtList)tag));
            }
            else if (typeof(IDictionary).IsAssignableFrom(type))
            {
                return(GetDictionary(type, (NbtCompound)tag));
            }

            value = Activator.CreateInstance(type);

            DeserializeBase(value, type, tag);

            return(value);
        }
Пример #2
0
 public override NbtTag Add(NbtTag item)
 {
     if (item == null)
         throw new ArgumentNullException("item");
     if (item.Parent != null)
         item = item.Clone();
     _list.Add(item);
     item.Parent = this;
     return item;
 }
Пример #3
0
 public override NbtTag Add(string key, NbtTag item)
 {
     if (key == null)
         throw new ArgumentNullException("key");
     if (item == null)
         throw new ArgumentNullException("item");
     if (item.Parent != null)
         item = item.Clone();
     _dict.Add(key, item);
     item._name = key;
     item.Parent = this;
     return item;
 }
Пример #4
0
        private void LoadNbtBlockEntity(NbtTag nbtTag)
        {
            var blockEntityTag = (NbtCompound)nbtTag.Clone();
            int x = blockEntityTag["x"].IntValue;
            int y = blockEntityTag["y"].IntValue;
            int z = blockEntityTag["z"].IntValue;

            var coords = new BlockCoordinates(x, y, z);

            Debug.WriteLine($"Found TileEntity at {x},{y},{z}: {nbtTag["id"].StringValue}");

            BlockEntities.Add(coords, blockEntityTag);
        }
Пример #5
0
 public override NbtTag Insert(int index, NbtTag item)
 {
     if (item == null)
         throw new ArgumentNullException("item");
     if (item.Parent != null)
         item = item.Clone();
     _list.Insert(index, item);
     item.Parent = this;
     return item;
 }
Пример #6
0
 public Item(NbtTag tag)
 {
     this.tag = tag.Clone();
 }
Пример #7
0
 public Item(NbtTag tag)
 {
     this.tag = tag.Clone();
 }