blushiemagic / MagicStorage

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

Crafting Terminal doesn't work in multiplayer #20

Closed chvolkmann closed 7 years ago

chvolkmann commented 7 years ago

The Crafting Terminal doesn't seem to work in multiplayer.

I pick an item, click the "Craft" button afterwards, nothing happens. The server console prints the following error message:

Error on message Terraria.MessageBuffer

This feature does however work in singleplayer.

I'm running the latest version of MagicStorage (v0.4.0.2) with tModLoader v0.10.0.2 and Terraria v1.3.5.2. Additional mods are:

...although I don't suspect them to cause this issue.

RunicPixels commented 7 years ago

Can confirm the same happening to me. Also running magic storage 0.4.0.2 and tModLoader 0.10.0.2. All of the above listed mods as well.

blushiemagic commented 7 years ago

Does the error have any more details, or is it only that one line?

chvolkmann commented 7 years ago

Nope, that's all information the console spits out

Reprisal35 commented 7 years ago

Having the same issue. Works just fine in single player, doesnt work in multiple player. Throwing the same message as Freemanium. Running the following Mods on tModLoader 0.10.0.1 and Terraria 1.3.5.2.

Infinoid commented 7 years ago

I can reproduce this in a new (clean) world without any other mods enabled.

Terraria Server v1.3.5.2 - tModLoader v0.10.1 MagicStorage 0.4.2

The Storage Heart works great, in both single-player and multi-player. The Storage Crafting Interface opens and looks normal in both single-player and multi-player. But in multi-player, the "Craft" button doesn't actually craft anything. It makes the crafting noise, but no crafting happens... the new item doesn't appear and the ingredients aren't subtracted. This happens regardless of whether the recipe required a crafting station. It seems to happen for mana crystals, iron bars, everything.

[I also posted on the forum about this. Apologies for the redundancy.]

AssassinsKeeper commented 7 years ago

I'm getting it as well. The storage itself works fine, but like everyone else here says it's 1 line, no other errors show up in any logs. It was working just fine for probably about a week, but only a few hours after we went into Hardmode and it's broken.

Terraria Server v1.3.5.2 - tModloader v0,10.1 w/ MagicStorage 0.4.2

vcepela commented 7 years ago

real exception is:

System.NullReferenceException: Object reference not set to an instance of an object
  at Terraria.GameContent.UI.Elements.UIText.InternalSetText (System.Object text, System.Single textScale, System.Boolean large) [0x0002b] in <3e6851c102b24f3c9b5479ac02ec4b1e>:0
  at Terraria.GameContent.UI.Elements.UIText..ctor (System.String text, System.Single textScale, System.Boolean large) [0x00071] in <3e6851c102b24f3c9b5479ac02ec4b1e>:0
  at MagicStorage.CraftingGUI..cctor () [0x000fb] in <0fc9a6de5748445e9737694c16bb02e9>:0

that is getting called from List<Item> items = CraftingGUI.DoCraft(heart, toWithdraw, result); in NetHelper.ReceiveCraftRequest().

CraftingGUI fails to initialize static UIText() because DynamicSpriteFont.MeasureString thats used in its constructor returns null when running on dedicated server (tested on Linux).

Quick fix was to move static constructors of UIText() to static method CraftingGUI.Initialize() for those two variables:

private static UIText capacityText;
private static UIText reqObjText2;
Mr-Rixa commented 7 years ago

Quick fix was to ...

Now if I only knew how to do that and build it 😅

Ok I got it built and crafting works on server for now so ain't complaining. 👍

ahjsrhj commented 7 years ago

Ok I got it built and crafting works on server for now so ain't complaining. 👍

@Mr-Rixa Can you share this mod? thanks a lot

Mr-Rixa commented 7 years ago

@ahjsrhj Well I have very limited knowledge of coding and it was a bit hit and miss. You'll take all responsibility of what might happen if you do this. I recommend taking a manual backup of your world before doing this. (so far I've had no problems 😅)

  1. You'll need to put this source into Mod Sources folder (windows location: %userprofile%\Documents\My Games\Terraria\ModLoader\Mod Sources ) note: it might not exist, you probably need to make the folder!
  2. make sure the extracted folder is called MagicStorage ( Mod Sources\MagicStorage )
  3. File you'll be editing is CraftingGUI.cs
  4. after editing go in-game mod sources menu and hit build+reload.
line code
change 80 private static UIText capacityText;
change 92 private static UIText reqObjText2;

and then add this after line 312

// hacky test fix that didn't lag
if (reqObjText2 == null)
{
    reqObjText2 = new UIText(Language.GetText("LegacyInterface.22"));
}
if (capacityText == null)
{
    capacityText = new UIText(Language.GetText("LegacyInterface.22"));
}

Like I stated earlier this was a bit hit and miss and if anybody has a better or more elegant way to fix it please correct my horrible hacky ways 😅

ahjsrhj commented 7 years ago

@Mr-Rixa Thank you very much!

chvolkmann commented 7 years ago

@Mr-Rixa If you feel like it, you can even issue a pull request, so others can quickly import your changes.