public bool Check(List <LanguageItem> list) { switch (Type) { default: return(false); case LangItemType.Sign: Sign s = Original as Sign; if ((s.Line1 == "\"\"" || s.Line1 == "{\"text\":\"\"}" || s.Line1 == "null" || s.Line1.Replace(" ", "") == "{\"extra\":[\"\"],\"text\":\"\"}") && (s.Line2 == "\"\"" || s.Line2 == "{\"text\":\"\"}" || s.Line2 == "null" || s.Line2.Replace(" ", "") == "{\"extra\":[\"\"],\"text\":\"\"}") && (s.Line3 == "\"\"" || s.Line3 == "{\"text\":\"\"}" || s.Line3 == "null" || s.Line3.Replace(" ", "") == "{\"extra\":[\"\"],\"text\":\"\"}") && (s.Line4 == "\"\"" || s.Line4 == "{\"text\":\"\"}" || s.Line4 == "null" || s.Line4.Replace(" ", "") == "{\"extra\":[\"\"],\"text\":\"\"}")) { return(false); } foreach (LanguageItem item in list) { if (item.Type == LangItemType.Sign) { Sign si = item.Original as Sign; if (si.Line1 == s.Line1 && si.Line2 == s.Line2 && si.Line3 == s.Line3 && si.Line4 == s.Line4) { item.Info += ";" + Info; return(false); } } } return(true); case LangItemType.Container: Container c = Original as Container; if (c.CustomName != "" || c.Lock != "" || c.Items.Count != 0) { return(true); } else { return(false); } case LangItemType.Entity: Entity e = Original as Entity; if (e.CustomName != "" || e.Equipments[0] != null || e.Equipments[1] != null || e.Equipments[2] != null || e.Equipments[3] != null || e.Equipments[4] != null || e.Equipments[5] != null) { foreach (LanguageItem item in list) { if (item.Type == LangItemType.Entity) { if (e.CompareWith(item.Original as Entity)) { return(false); } } } return(true); } else { return(false); } case LangItemType.MobSpawner: Entity e1 = Original as Entity; if (e1.CustomName != "" || e1.Equipments[0] != null || e1.Equipments[1] != null || e1.Equipments[2] != null || e1.Equipments[3] != null || e1.Equipments[4] != null || e1.Equipments[5] != null) { foreach (LanguageItem i in list) { if (i.Type != LangItemType.MobSpawner) { continue; } if (e1.CompareWith(i.Original as Entity)) { i.Info += ";" + Info; i.Name += ";" + Name; return(false); } } } else { return(false); } return(true); } }
public LanguageItem(TagNodeCompound tag, LangItemType type) { Type = type; if (type == LangItemType.CommandBlock) { Original = tag["Command"].ToTagString().Data; } else if (type == LangItemType.Sign) { Info = tag["x"].ToTagInt().Data + "," + tag["y"].ToTagInt().Data + "," + tag["z"].ToTagInt().Data; Original = new Sign { Line1 = tag["Text1"].ToTagString().Data, Line2 = tag["Text2"].ToTagString().Data, Line3 = tag["Text3"].ToTagString().Data, Line4 = tag["Text4"].ToTagString().Data }; } else if (type == LangItemType.Container) { Name = tag["id"].ToTagString().Data; Info = tag["x"].ToTagInt().Data + "," + tag["y"].ToTagInt().Data + "," + tag["z"].ToTagInt().Data; Container c = new Container(); if (tag.ContainsKey("CustomName")) { string str = tag["CustomName"].ToTagString().Data; if (Name == "Control" || Name == "minecraft:command_block") { if (str != "" && str != "@") { c.CustomName = Name; } } else if (str != "") { c.CustomName = str; } } if (tag.ContainsKey("Lock") && tag["Lock"].ToTagString().Data != "") { c.Lock = tag["Lock"].ToTagString().Data; } if (tag.Keys.Contains("RecordItem") && tag["RecordItem"].ToTagCompound().ContainsKey("tag")) { TagNodeCompound tag1 = tag["RecordItem"].ToTagCompound()["tag"].ToTagCompound(); Item i = new Item(tag1); if (i.Check()) { c.Items.Add(i); } } if (tag.ContainsKey("Items") && tag["Items"].IsCastableTo(TagType.TAG_LIST)) { foreach (TagNodeCompound tags in tag["Items"].ToTagList()) { if (tags["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(tags); if (i.Check()) { c.Items.Add(i); } } else { Item i = new Item(tags); if (i.Check()) { c.Items.Add(i); } } } } Original = c; } else if (type == LangItemType.Entity) { Name = tag["id"].ToTagString().Data; Entity e = new Entity(); if (tag.ContainsKey("CustomName")) { e.CustomName = tag["CustomName"].ToTagString().Data; } if (Name.ToLower().Contains("item")) { if (tag.ContainsKey("Item")) { Item item = new Item(tag["Item"].ToTagCompound()); if (item.Check()) { e.Equipments[0] = item; } } } else { if (tag.ContainsKey("HandItems") || tag.ContainsKey("ArmorItems")) { TagNodeList HandItems = tag["HandItems"].ToTagList(); TagNodeList ArmorItems = tag["ArmorItems"].ToTagList(); try { if (HandItems[0].ToTagCompound().ContainsKey("id") && HandItems[0].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(HandItems[0].ToTagCompound()); if (i.Check()) { e.Equipments[0] = i; } } else { Item i = new Item(HandItems[0].ToTagCompound()); if (i.Check()) { e.Equipments[0] = i; } } } catch { } try { if (HandItems[1].ToTagCompound().ContainsKey("id") && HandItems[1].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(HandItems[1].ToTagCompound()); if (i.Check()) { e.Equipments[1] = i; } } else { Item i = new Item(HandItems[1].ToTagCompound()); if (i.Check()) { e.Equipments[1] = i; } } } catch { } try { if (ArmorItems[3].ToTagCompound().ContainsKey("id") && ArmorItems[3].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(ArmorItems[3].ToTagCompound()); if (i.Check()) { e.Equipments[2] = i; } } else { Item i = new Item(ArmorItems[3].ToTagCompound()); if (i.Check()) { e.Equipments[2] = i; } } } catch { } try { if (ArmorItems[2].ToTagCompound().ContainsKey("id") && ArmorItems[2].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(ArmorItems[2].ToTagCompound()); if (i.Check()) { e.Equipments[3] = i; } } else { Item i = new Item(ArmorItems[2].ToTagCompound()); if (i.Check()) { e.Equipments[3] = i; } } } catch { } try { if (ArmorItems[1].ToTagCompound().ContainsKey("id") && ArmorItems[1].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(ArmorItems[1].ToTagCompound()); if (i.Check()) { e.Equipments[4] = i; } } else { Item i = new Item(ArmorItems[1].ToTagCompound()); if (i.Check()) { e.Equipments[4] = i; } } } catch { } try { if (ArmorItems[0].ToTagCompound().ContainsKey("id") && ArmorItems[0].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(ArmorItems[0].ToTagCompound()); if (i.Check()) { e.Equipments[5] = i; } } else { Item i = new Item(ArmorItems[0].ToTagCompound()); if (i.Check()) { e.Equipments[5] = i; } } } catch { } } else if (tag.ContainsKey("Equipment")) { TagNodeList Equipment = tag["Equipment"].ToTagList(); if (Equipment[0].ToTagCompound().ContainsKey("id") && Equipment[0].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(Equipment[0].ToTagCompound()); if (i.Check()) { e.Equipments[0] = i; } } else { Item i = new Item(Equipment[0].ToTagCompound()); if (i.Check()) { e.Equipments[0] = i; } } if (Equipment[4].ToTagCompound().ContainsKey("id") && Equipment[4].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(Equipment[4].ToTagCompound()); if (i.Check()) { e.Equipments[2] = i; } } else { Item i = new Item(Equipment[4].ToTagCompound()); if (i.Check()) { e.Equipments[2] = i; } } if (Equipment[3].ToTagCompound().ContainsKey("id") && Equipment[3].ToTagCompound().ContainsKey("id") && Equipment[3].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(Equipment[3].ToTagCompound()); if (i.Check()) { e.Equipments[3] = i; } } else { Item i = new Item(Equipment[3].ToTagCompound()); if (i.Check()) { e.Equipments[3] = i; } } if (Equipment[2].ToTagCompound().ContainsKey("id") && Equipment[2].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(Equipment[2].ToTagCompound()); if (i.Check()) { e.Equipments[4] = i; } } else { Item i = new Item(Equipment[2].ToTagCompound()); if (i.Check()) { e.Equipments[4] = i; } } if (Equipment[1].ToTagCompound().ContainsKey("id") && Equipment[1].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(Equipment[1].ToTagCompound()); if (i.Check()) { e.Equipments[5] = i; } } else { Item i = new Item(Equipment[1].ToTagCompound()); if (i.Check()) { e.Equipments[5] = i; } } Item hand = new Item(Equipment[0].ToTagCompound()); Item armor1 = new Item(Equipment[4].ToTagCompound()); Item armor2 = new Item(Equipment[3].ToTagCompound()); Item armor3 = new Item(Equipment[2].ToTagCompound()); Item armor4 = new Item(Equipment[1].ToTagCompound()); if (hand.Check()) { e.Equipments[0] = hand; } if (armor1.Check()) { e.Equipments[2] = armor1; } if (armor2.Check()) { e.Equipments[3] = armor2; } if (armor3.Check()) { e.Equipments[4] = armor3; } if (armor4.Check()) { e.Equipments[5] = armor4; } } } Original = e; } else if (type == LangItemType.MobSpawner) { Info = tag["x"].ToTagInt().Data + "," + tag["y"].ToTagInt().Data + "," + tag["z"].ToTagInt().Data; Name = tag["SpawnData"].ToTagCompound()["id"].ToTagString().Data; Original = new LanguageItem(tag["SpawnData"].ToTagCompound(), LangItemType.Entity).Original; } }