Beispiel #1
0
        public static int GetBlockIdByName(string blockName)
        {
            blockName = blockName.ToLowerInvariant().Replace("_", "").Replace("minecraft:", "");

            if (NameToId.ContainsKey(blockName))
            {
                return(NameToId[blockName]);
            }

            return(0);
        }
Beispiel #2
0
        public static short GetItemIdByName(string itemName)
        {
            itemName = itemName.ToLowerInvariant();
            itemName = itemName.Replace("_", "");

            if (NameToId.ContainsKey(itemName))
            {
                return(NameToId[itemName]);
            }

            return((short)BlockFactory.GetBlockIdByName(itemName));
        }
Beispiel #3
0
        public static Block GetBlockByName(string blockName)
        {
            if (string.IsNullOrEmpty(blockName))
            {
                return(null);
            }

            blockName = blockName.ToLowerInvariant().Replace("_", "").Replace("minecraft:", "");

            if (NameToId.ContainsKey(blockName))
            {
                return(GetBlockById(NameToId[blockName]));
            }

            return(null);
        }
Beispiel #4
0
        public RotMGData()
        {
            if (Items == null)
            {
                Items = new Dictionary <short, string>();
            }
            if (Soulbound == null)
            {
                Soulbound = new Dictionary <short, bool>();
            }
            if (NameToId == null)
            {
                NameToId = new Dictionary <string, short>();
            }

            XElement root = XElement.Load("data/items.xml");

            foreach (XElement elem in root.Elements("Object"))
            {
                string name = elem.Attribute("id").Value;
                string tier = String.Empty;
                if (elem.Element("Tier") != null)
                {
                    tier = "T" + elem.Element("Tier").Value;
                }
                short itemId = (short)Utils.FromString(elem.Attribute("type").Value);
                if (!Soulbound.ContainsKey(itemId))
                {
                    Soulbound.Add(itemId, elem.Element("Soulbound") != null);
                }
                if (!Items.ContainsKey(itemId))
                {
                    Items.Add(itemId, tier == String.Empty ? name : tier + " " + name);
                }
                if (!NameToId.ContainsKey(name))
                {
                    NameToId.Add(name, itemId);
                }
            }

            LoadingComplete = true;
        }