blushiemagic / MagicStorage

A tModLoader mod for Terraria
MIT License
177 stars 101 forks source link

Items being voided from storage component. #185

Open Renari opened 2 years ago

Renari commented 2 years ago

After breaking the storage heart and moving it from the bottom of a storage component to the right side of the storage component all items inside that storage component are deleted. I was able to kill the server before this saved and was then able to replicate the issue afterwards.

System.InvalidCastException: Unable to cast object of type 'Terraria.GameContent.Tile_Entities.TETeleportationPylon' to type 'MagicStorage.Components.TEStorageUnit'.
   at MagicStorage.NetHelper.ServerReciveSyncStorageUnit(BinaryReader reader, Int32 remoteClient) in MagicStorage\NetHelper.cs:line 97
   at Terraria.ModLoader.ModNet.HandleModPacket(BinaryReader reader, Int32 whoAmI, Int32 length) in tModLoader\Terraria\ModLoader\ModNet.cs:line 429
   at Terraria.MessageBuffer.GetData(Int32 start, Int32 length, Int32& messageType) in tModLoader\Terraria\MessageBuffer.cs:line 3575
   at DMD<Terraria.NetMessage::CheckBytes>(Int32 bufferIndex)
   at Terraria.Netplay.UpdateServerInMainThread() in tModLoader\Terraria\Netplay.cs:line 64
   at Terraria.Main.DoUpdate(GameTime& gameTime) in tModLoader\Terraria\Main.cs:line 12729
   at Terraria.Main.Update(GameTime gameTime) in tModLoader\Terraria\Main.cs:line 12618
   at DMD<Terraria.Main::DedServ_PostModLoad>(Main this, Boolean& reloadMods)
   at Terraria.Main.DedServ() in tModLoader\Terraria\Main.cs:line 4144
   at Terraria.Program.LaunchGame_(Boolean isServer) in tModLoader\Terraria\Program.cs:line 231
   at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs) in tModLoader\Terraria\Program.cs:line 194
   at MonoLaunch.<>c__DisplayClass2_0.<Main>b__0() in tModLoader\Terraria\MonoLaunch.cs:line 65
   at System.Threading.Thread.StartCallback()

https://user-images.githubusercontent.com/1839179/176888851-75b6e74c-d9c6-47c3-b048-8ce96b28c7fb.mp4

ExterminatorX99 commented 2 years ago

Is there a teleport pylon nearby?

Renari commented 2 years ago

There is not, there is only one pylon in the world and it is near the ocean (about as far away as it could possibly be).

ExterminatorX99 commented 2 years ago

Does this happen in single player?

Renari commented 2 years ago

Does not appear to happen in single player.

ExterminatorX99 commented 2 years ago

Does it happen with only Magic Storage enabled?

Renari commented 2 years ago

I was able to replicate it in the same world after turning off all other mods, there were however some drawing issues where almost all tiles were not drawing, including the magic storage blocks (I was able to move it without seeing it though).

ExterminatorX99 commented 2 years ago

Does it happen in a new world with only magic storage? Cheat sheet and hero mod are fine to use

Renari commented 2 years ago

Yes it's reproducible in a world with just magic storage, hero's mod and cheat sheet.

Steps to reproduce:

The stack trace did change, but the result was the same:

System.Collections.Generic.KeyNotFoundException: The given key '0' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at MagicStorage.NetHelper.ServerReciveSyncStorageUnit(BinaryReader reader, Int32 remoteClient) in MagicStorage\NetHelper.cs:line 97
   at Terraria.ModLoader.ModNet.HandleModPacket(BinaryReader reader, Int32 whoAmI, Int32 length) in tModLoader\Terraria\ModLoader\ModNet.cs:line 433
   at Terraria.MessageBuffer.GetData(Int32 start, Int32 length, Int32& messageType) in tModLoader\Terraria\MessageBuffer.cs:line 3575
   at Terraria.NetMessage.CheckBytes(Int32 bufferIndex) in tModLoader\Terraria\NetMessage.cs:line 2202
   at Terraria.Netplay.UpdateServerInMainThread() in tModLoader\Terraria\Netplay.cs:line 64
   at Terraria.Main.DoUpdate(GameTime& gameTime) in tModLoader\Terraria\Main.cs:line 12742
   at Terraria.Main.Update(GameTime gameTime) in tModLoader\Terraria\Main.cs:line 12631
   at Terraria.Main.DedServ_PostModLoad(Boolean& reloadMods) in tModLoader\Terraria\Main.cs:line 4620
   at Terraria.Main.DedServ() in tModLoader\Terraria\Main.cs:line 4156
   at Terraria.Program.LaunchGame_(Boolean isServer) in tModLoader\Terraria\Program.cs:line 236
   at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs) in tModLoader\Terraria\Program.cs:line 195
   at MonoLaunch.<>c__DisplayClass2_0.<Main>b__0() in tModLoader\Terraria\MonoLaunch.cs:line 65
   at System.Threading.Thread.StartCallback()
absoluteAquarian commented 2 years ago

this is so bizarre

the NetHelper.ServerReciveSyncStorageUnit() method only gets used by packets sent using MessageType.SyncStorageUnit... which are only sent from TEStorageUnit.NetReceive()

meaning it should be impossible for the assigned tile entity ID to be sent from a storage unit, but then end up as some other tile entity (or not even in the world in the case for the second stacktrace posted)

Illatior commented 2 years ago

actually just a reboot of the server with the heart of magic storage in a right place 'returns' all of the items back and fixes a problem