From 5b1a55973bc38bc780171fe0d077b9ac68dca787 Mon Sep 17 00:00:00 2001 From: Jack Bond-Preston Date: Sat, 4 Feb 2023 12:45:12 +0000 Subject: [PATCH] Revert "fix: work around magic storage locator sync bug" This fix is now part of mainline Magic Storage --- Items/MSVoidBag.cs | 59 ---------------------------------------------- 1 file changed, 59 deletions(-) diff --git a/Items/MSVoidBag.cs b/Items/MSVoidBag.cs index cef04e9..c1d2e56 100644 --- a/Items/MSVoidBag.cs +++ b/Items/MSVoidBag.cs @@ -1,21 +1,15 @@ using MagicStorage.Items; using System; using System.Collections.Generic; -using System.IO; -using System.Linq; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent.Creative; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using Terraria.ModLoader.IO; namespace MagicStorageVoidBag.Items { [ExtendsFromMod("MagicStorage")] public class MSVoidBag : PortableAccess { - [CloneByReference] - internal Dictionary locationsByWorld = new(); public override void SetStaticDefaults() { CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; @@ -30,9 +24,6 @@ namespace MagicStorageVoidBag.Items { Item.useAnimation = 28; Item.useTime = 28; Item.value = Item.sellPrice(gold: 10); - - location = Point16.NegativeOne; - locationsByWorld[Main.worldName] = location; } public override void ModifyTooltips(List lines) { @@ -52,55 +43,5 @@ namespace MagicStorageVoidBag.Items { recipe.AddIngredient(ItemID.VoidLens); recipe.Register(); } - - public override void UpdateInventory(Player player) { - if (!locationsByWorld.ContainsKey(Main.worldName) || location != locationsByWorld[Main.worldName]) { - locationsByWorld[Main.worldName] = location; - if (Main.netMode == NetmodeID.MultiplayerClient) { - int p = Array.IndexOf(Main.player, player); - int i = Array.IndexOf(player.inventory, Item); - if (p >= 0 && i >= 0) { - NetMessage.SendData(MessageID.SyncEquipment, -1, -1, null, p, i, player.inventory[i].prefix); - } - } - } - } - - public override void SaveData(TagCompound tag) { - tag["X"] = location.X; - tag["Y"] = location.Y; - - tag["version"] = SAVE_VERSION; - - tag["locations"] = locationsByWorld - .Select(kvp => new TagCompound() { - ["world"] = kvp.Key, - ["X"] = kvp.Value.X, - ["Y"] = kvp.Value.Y - }) - .ToList(); - } - - public override void LoadData(TagCompound tag) { - if (tag.GetInt("version") < SAVE_VERSION || tag.GetList("locations") is not List locations) { - location = new Point16(tag.GetShort("X"), tag.GetShort("Y")); - locationsByWorld[Main.worldName] = location; - } else { - locationsByWorld = locations.ToDictionary(t => t.GetString("world"), t => new Point16(t.GetShort("X"), t.GetShort("Y"))); - if (locationsByWorld.ContainsKey(Main.worldName)) { - location = locationsByWorld[Main.worldName]; - } - } - } - - public override void NetSend(BinaryWriter writer) { - writer.Write(location.X); - writer.Write(location.Y); - } - - public override void NetReceive(BinaryReader reader) { - location = new Point16(reader.ReadInt16(), reader.ReadInt16()); - locationsByWorld[Main.worldName] = location; - } } }