public void Insert(int index, TagBase tag) { if (tag == null) { return; } tag._parent = this; _tagList.Insert(index, tag); }
public TagList(TagList original) : base(original.Name) { _listTagType = original.ListType; for (int i = 0; i < original.Value.Count; i++) { TagBase _bs = original.Value[i].Clone(); _bs._parent = this; Add(_bs); } }
public static void WriteNamedTag(TagBase tag, NBTBinaryWriter bw) { byte tagId = (byte)tag.TagType; bw.Write(tagId); if (tagId != 0) { bw.Write(tag.Name); tag.WriteBinary(bw); } }
internal override void ReadBinary(NBTBinaryReader br) { _tagList.Clear(); _listTagType = (TagType)br.ReadByte(); int count = br.ReadInt32(); _tagList = new List <TagBase>(); for (int i = 0; i < count; i++) { TagBase nbt = TagBase.CreateNewTag(_listTagType, null); nbt._parent = this; nbt.ReadBinary(br); _tagList.Add(nbt); } }
public static TagBase ReadNamedTag(NBTBinaryReader br) { byte type = br.ReadByte(); if (type == 0) { return(new TagEnd()); } else { string n = br.ReadString(); TagBase nbt = CreateNewTag((TagType)type, n); nbt.ReadBinary(br); return(nbt); } }
public string GetPath() { string result = ""; TagBase tag = this; while (true) { if (tag != null && tag._parent != null) { result = "/" + tag._parent.Name + result; tag = tag._parent; } else { break; } } return(result); }
public bool Rename(string newName) { if (_parent != null) { TagCompound compound = _parent as TagCompound; if (compound != null && !compound.ContainsKey(newName)) { TagBase tag = this; tag._name = newName; compound.Add(newName, tag); compound.Remove(Name); return(true); } TagList tagList = _parent as TagList; if (tagList != null) { _name = newName; return(true); } } return(false); }
public void Remove(TagBase tag) { _tagList.Remove(tag); }
public void Add(TagBase tag) { tag._parent = this; _tagList.Add(tag); }