public override void Load(Item item, TagCompound tag) { if (tag.ContainsKey("AutoReuse")) { item.autoReuse = tag.GetBool("AutoReuse"); } if (tag.ContainsKey("Consumable")) { item.consumable = tag.GetBool("Consumable"); } if (tag.ContainsKey("Potion")) { item.potion = tag.GetBool("Potion"); } if (tag.ContainsKey("Accessory")) { item.accessory = tag.GetBool("Accessory"); } if (tag.ContainsKey("DamageType")) { item.SetDamageType(tag.GetByte("DamageType")); } if (tag.ContainsKey("Damage")) { item.damage = tag.GetInt("Damage"); } if (tag.ContainsKey("KnockBack")) { item.knockBack = tag.GetFloat("KnockBack"); } if (tag.ContainsKey("Crit")) { item.crit = tag.Get <ushort>("Crit"); } if (tag.ContainsKey("Shoot")) { item.shoot = tag.Get <ushort>("Shoot"); } if (tag.ContainsKey("ShootSpeed")) { item.shootSpeed = tag.GetFloat("ShootSpeed"); } if (tag.ContainsKey("CreateTile")) { item.createTile = tag.Get <ushort>("CreateTile"); } if (tag.ContainsKey("TileBoost")) { item.tileBoost = (sbyte)tag.Get <byte>("TileBoost"); } if (tag.ContainsKey("BuffType")) { item.buffType = tag.Get <ushort>("BuffType"); } if (tag.ContainsKey("BuffTime")) { item.buffTime = tag.GetInt("BuffTime"); } if (tag.ContainsKey("HealLife")) { item.healLife = tag.Get <ushort>("HealLife"); } if (tag.ContainsKey("HealMana")) { item.healMana = tag.Get <ushort>("HealMana"); } if (tag.ContainsKey("Axe")) { item.axe = tag.Get <ushort>("Axe"); } if (tag.ContainsKey("Pickaxe")) { item.pick = tag.Get <ushort>("Pickaxe"); } if (tag.ContainsKey("Hammer")) { item.hammer = tag.Get <ushort>("Hammer"); } if (tag.ContainsKey("MaxStack")) { item.maxStack = tag.GetInt("MaxStack"); } if (tag.ContainsKey("UseAnimation")) { item.useAnimation = tag.Get <ushort>("UseAnimation"); } if (tag.ContainsKey("UseTime")) { item.useTime = tag.Get <ushort>("UseTime"); } if (tag.ContainsKey("Defense")) { item.defense = tag.GetInt("Defense"); } if (tag.ContainsKey("FishingPole")) { item.fishingPole = tag.Get <ushort>("FishingPole"); } if (tag.ContainsKey("Scale")) { item.scale = tag.GetFloat("Scale"); } if (tag.ContainsKey("UseStyle")) { item.useStyle = tag.GetByte("UseStyle"); } if (tag.ContainsKey("CostMP")) { item.mana = tag.Get <ushort>("CostMP"); } if (tag.ContainsKey("BuffTypes")) { CustomProperties cItem = item.GetGlobalItem <CustomProperties>(); int[] buffTypes = tag.GetIntArray("BuffTypes"); int[] buffTimes = tag.GetIntArray("BuffTimes"); for (int i = 0; i < cItem.BuffTypes.Length; i++) { cItem.BuffTypes[i] = buffTypes[i]; cItem.BuffTimes[i] = buffTimes[i]; } } }
public override TagCompound Save(Item item) { Item defaultItem = new Item(); defaultItem.SetDefaults(item.type); TagCompound tag = new TagCompound(); if (item.autoReuse != defaultItem.autoReuse) { tag.Add("AutoReuse", item.autoReuse); } if (item.consumable != defaultItem.consumable) { tag.Add("Consumable", item.consumable); } if (item.potion != defaultItem.potion) { tag.Add("Potion", item.potion); } if (item.accessory != defaultItem.accessory) { tag.Add("Accessory", item.accessory); } int damageType = item.DamageType(); if (damageType != defaultItem.DamageType()) { tag.Add("DamageType", (byte)damageType); } if (item.damage != defaultItem.damage) { tag.Add("Damage", item.damage); } if (item.knockBack != defaultItem.knockBack) { tag.Add("KnockBack", item.knockBack); } if (item.crit != defaultItem.crit) { tag.Add("Crit", (ushort)item.crit); } if (item.shoot != defaultItem.shoot) { tag.Add("Shoot", (ushort)item.shoot); } if (item.shootSpeed != defaultItem.shootSpeed) { tag.Add("ShootSpeed", item.shootSpeed); } if (item.createTile != defaultItem.createTile) { tag.Add("CreateTile", (ushort)item.createTile); } if (item.tileBoost != defaultItem.tileBoost) { tag.Add("TileBoost", (byte)(sbyte)item.tileBoost); } if (item.buffType != defaultItem.buffType) { tag.Add("BuffType", (ushort)item.buffType); } if (item.buffTime != defaultItem.buffTime) { tag.Add("BuffTime", item.buffTime); } if (item.healLife != defaultItem.healLife) { tag.Add("HealLife", (ushort)item.healLife); } if (item.healMana != defaultItem.healMana) { tag.Add("HealMana", (ushort)item.healMana); } if (item.axe != defaultItem.axe) { tag.Add("Axe", (ushort)item.axe); } if (item.pick != defaultItem.pick) { tag.Add("Pickaxe", (ushort)item.pick); } if (item.hammer != defaultItem.hammer) { tag.Add("Hammer", (ushort)item.hammer); } if (item.maxStack != defaultItem.maxStack) { tag.Add("MaxStack", item.maxStack); } if (item.useAnimation != defaultItem.useAnimation) { tag.Add("UseAnimation", (ushort)item.useAnimation); } if (item.useTime != defaultItem.useTime) { tag.Add("UseTime", (ushort)item.useTime); } if (item.defense != defaultItem.defense) { tag.Add("Defense", item.defense); } if (item.fishingPole != defaultItem.fishingPole) { tag.Add("FishingPole", (ushort)item.fishingPole); } if (item.scale != defaultItem.scale) { tag.Add("Scale", item.scale); } if (item.useStyle != defaultItem.useStyle) { tag.Add("UseStyle", (byte)item.useStyle); } if (item.mana != defaultItem.mana) { tag.Add("CostMP", (ushort)item.mana); } CustomProperties cItem = item.GetGlobalItem <CustomProperties>(); bool save = false; for (int i = 0; i < cItem.BuffTypes.Length; i++) { if (cItem.BuffTypes[i] != 0 || cItem.BuffTimes[i] != 0) { save = true; break; } } if (save) { tag.Add("BuffTypes", cItem.BuffTypes); tag.Add("BuffTimes", cItem.BuffTimes); } return(tag); }