sisby-folk / switchy

A minecraft mod that allows switching between presets of player data (social profiles, rpg characters, etc) in a completetly modular way.
https://modrinth.com/mod/switchy
GNU Lesser General Public License v3.0
13 stars 8 forks source link

Apoli Powers Granted via /power Command Lag Behind Profile Changes #78

Open Ballisticannon opened 5 months ago

Ballisticannon commented 5 months ago

This is a bit of an odd issue, with somewhat complex behavior, but I've done enough fiddling to pin down a pattern, and hopefully it can be reproduced. Excuse the long read, this is gonna take a while.

For reference on the environment in which this bug seems to occur: I'm working with a custom Fabric modpack. The pack runs on Minecraft ver. 1.19.2, Fabric mod loader ver. 0.15.7, and it includes the most recent compatible versions of Origins (ver. 1.7.1), Tinker's Statures (ver. 1.1.0+1.19), and Switchy (ver. 2.9.0+1.19). In addition, Switchy's plugins for Inventory (ver. 1.8.2+1.19) and Teleport (ver. 1.2.5+1.19.2) are also present, as well as Fabric Tailor (ver. 2.0.1), though these last three seem to be unrelated to the issue. The bug behaves identically in single- and multi-player (multiplayer tests took place on a personally-hosted server, running the same modlist). In all tests, config/switchy/apoli.toml has "switchCommandPowers" set to "true", and "exceptionPowerIds" set to an empty array. Furthermore, all modules listed in config/switchy/config.toml are set to "ALLOWED" (except Fabric Tailor, which is set to "ALWAYS_ALLOWED"). The settings in config/switchy/pehkui.toml have no apparent effect on this behavior, and all other configs for the mods previously mentioned were left unchanged.

As for the issue itself: Essentially, when swapping between Switchy profiles, certain powers that have been granted via Apoli's /power grant command will seem to lag behind, and only have their effects kick in on the next profile the player changes to, even if that next profile isn't meant to have the power. It's a bit hard to explain the details without an example, so here's one from my own testing:

It took some time, but through this and other tests, I've boiled this strange behavior down to a set of rules which it follows reliably.

  1. Each power that can be granted by the /power grant command falls into one of two categories: Those that switch out properly as expected, and those that lag behind (which I'll just call "laggards" for short).
  2. Swapping to a profile which has been given a laggard power via Apoli command (such that the laggard's only source is apoli:command) will register the player as owning the laggard, but will not apply the laggard's gameplay effects (unless the laggard is also owned by other means, or if the player is swapping in from a profile which also owned the laggard via command).
  3. Swapping from a profile which has been given a laggard power via Apoli command (even if the laggard is sourced from _apolicommand in addition to other sources, such as an origin layer) will apply the laggard's gameplay effects for the profile the player has swapped into, but will not register the player as owning the laggard (unless the second profile also owns the laggard via command).
  4. Certain actions can "reboot" a specific player's powers, clearing out any laggard effects that shouldn't be active and properly applying the effects of any laggards which should be active. These actions don't stop laggards from misbehaving in the long term, but they will fix any issues that are happening at the moment when they occur. Ways to "reboot" a player's power list include exiting and re-opening a world in singleplayer, logging out of and back into a multiplayer server, giving the player a new power via command, removing one of the player's currently-owned powers via command, and changing the player's origin or stature.
  5. Whether or not a specific power is a laggard is seemingly locked on a per-power basis, independent from any environmental factors that I've been able to test. As examples, _origins:sprintjump and origins:climbing always behave as laggards no matter what, and origins:fragile and all of the size-related powers from Tinker's Statures are never laggards. As of yet, each and every power I've tested has either always been a laggard in every situation, or never been a laggard in any situation. As for what makes a given power a laggard and what makes one work as expected, though, I can't yet tell.

From what I can discern, the powers are being saved to their respective switchy accounts properly, it's just the activation and deactivation of powers when switching between accounts that goes wrong. Maybe it's something along the lines of Switchy's Apoli module feeding some of the powers into the system at a time when Apoli isn't ready to implement the effects, and it just slaps them into some sort of buffer for later - I don't know all that's going on under the hood, but that's the best guess I've got.

Whatever the case may be: If I can provide any other information which might be useful, just let me know. This mod's been great to me, and a wonderful aid for some close friends of mine, and I'd be happy to do whatever I can to help. Best regards, and thank you all for your time.