private void CreateData(byte data) { Material mat = MaterialHelper.GetMaterial(type); if (mat == default(Material)) { this.data = new MaterialData(type, data); } else { this.data = mat.GetNewData(data); } }
public static ItemStack Deserialize(Dictionary <string, object> args) { Material type = MaterialHelper.GetMaterial((string)args["type"]); short damage = 0; int amount = 1; if (args.ContainsKey("damage")) { damage = (short)((int)args["damage"]); } if (args.ContainsKey("amount")) { amount = (int)args["amount"]; } ItemStack result = new ItemStack(type, amount, damage); if (args.ContainsKey("enchantments")) { object raw = args["enchantments"]; var ints = raw as Dictionary <string, int>; if (ints != null) { Dictionary <string, int> map = ints; foreach (var entry in map) { Enchantment enchantment = Enchantment.GetByName(entry.Key); if (enchantment != null) { result.AddUnsafeEnchantment(enchantment, entry.Value); } } } } else if (args.ContainsKey("meta")) { object raw = args["meta"]; var itemMeta = raw as IItemMeta; if (itemMeta != null) { result.ItemMeta = itemMeta; } } return(result); }
public override string ToString() { return(MaterialHelper.GetMaterial(TypeId).ToString() + (IsStem() ? "{STEM}" : GetPaintedFaces().ToString())); }