예제 #1
0
        public static bool ContainerTranslator(TagNodeCompound Target, List <LanguageItem> Source)
        {
            LanguageItem target = null; bool flag = false;

            foreach (LanguageItem c in Source)
            {
                if (c.Info == Target["x"].ToTagInt().Data + "," + Target["y"].ToTagInt().Data + "," + Target["z"].ToTagInt().Data)
                {
                    target = c; break;
                }
            }
            if (target == null)
            {
                return(false);
            }
            Container o = target.Original as Container;
            Container t = target.Translated as Container;

            if (Target.ContainsKey("RecordItem"))
            {
                return(ItemTranslator(Target["RecordItem"].ToTagCompound(), o.Items[0], t.Items[0]));
            }
            else
            {
                TagNodeList Items = Target["Items"].ToTagList();
                foreach (TagNode item in Items)
                {
                    for (int i = 0; i < o.Items.Count; i++)
                    {
                        if (ItemTranslator(item.ToTagCompound(), o.Items[i], t.Items[i]))
                        {
                            flag = true; goto Next;
                        }
                    }
                }
Next:
                if (Target.ContainsKey("CustomName") && t.CustomName != "")
                {
                    Target["CustomName"] = new TagNodeString(t.CustomName); flag = true;
                }
                if (Target.ContainsKey("Lock") && t.Lock != "")
                {
                    Target["Lock"] = new TagNodeString(t.Lock); flag = true;
                }
            }
            return(flag);
        }
예제 #2
0
        public static bool CommandBlockTranslator(TagNodeCompound Target, List <LanguageItem> Source)
        {
            string cmd = Target["Command"].ToTagString().Data;
            string c   = cmd.Split(' ')[0].Replace("/", "");

            if (c == "me" || c == "title" || c == "tellraw" || c == "say")
            {
                LanguageItem languageItem = null;
                foreach (LanguageItem item in Source)
                {
                    if (cmd == item.Original as string)
                    {
                        languageItem = item; break;
                    }
                }
                if (languageItem != null && languageItem.Translated as string != "")
                {
                    Target["Command"] = new TagNodeString(languageItem.Translated as string);
                    return(true);
                }
            }
            return(false);
        }
예제 #3
0
        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;
            }
        }