Hex Casting

Hex Casting

6M Downloads

Colorizers do not work on multiplayer servers; work inconsistently in singleplayer

RedRaspberry opened this issue ยท 1 comments

commented

This is a slight duplicate of #241, but after some testing I'm fairly confident I've identified the cause and workarounds and felt it was relevant enough to get it's own issue. Feel free to close if I'm wrong.

Tested on Forge 4.1.84 (Latest at time of writing), with literally just Hexcasting and all required dependencies (which were also latest versions at time of writing).

The overview of the issue is as follows:
When attempting to cast the spell to apply the colorizer to yourself, the mod in theory would do the following: Check your offhand for a colorizer, apply that color, then remove the item from your inventory. Unfortunately, this does not always happen correctly, and I'm fairly sure it's a race condition, although I'm not smart enough to tell you why that's the case.
Here's what happens instead:

  • Mod checks that your offhand contains a colorizer
  • Mod removes 1 colorizer from your inventory (this specifically is important for the workaround!)
  • Mod assigns whatever item is in your offhand to your playerdata related to colorizers

This results in you having minecraft:air as your colorizer (because your offhand is now an empty slot).

The workaround is as follows:
Simply have more than one of the same colorizer in your inventory. (In theory, I guess you could also have a different one, but let's not think about it.)
Why does this work? As far as I know, the minecraft inventory slots work off of a priority system according to the number of the slot, with the offhand being a lower priority than the rest of the inventory (slot 99, i think?). Thus, when the game removes an item from the inventory, it removes one with an earlier priority (ie, anywhere else in the inventory), which leaves the offhand one intact to be written to your playerdata.

I don't know a whole lot about Forge or java, but I did notice that this issue primarily occurs in multiplayer, and very rarely in singleplayer. https://docs.minecraftforge.net/en/1.18.x/concepts/sides/#reaching-across-logical-sides seemed to be relevant though- from what I can tell on the forge docs, race conditions like this are often the result of problems with sidedness- which is what set me out to try and find the root of this issue in the first place, since it worked on singleplayer ~90% of the time and never on multiplayer.

Thank you for making such a cool mod, I'm having lots of fun so far, hopefully this can be fixed!

commented

This has already been fixed as of cf1d65c