public static int GetBlockIdByName(string blockName) { blockName = blockName.ToLowerInvariant().Replace("_", "").Replace("minecraft:", ""); if (NameToId.ContainsKey(blockName)) { return(NameToId[blockName]); } return(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)); }
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); }
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; }