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); }
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; }
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; }
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); }
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; }
public Item(NbtTag tag) { this.tag = tag.Clone(); }