Shoulder Surfing Reloaded

Shoulder Surfing Reloaded

26M Downloads

Incompatible with Iron's Spells 'n Spellbooks mod — proposed fix

EchoEllet opened this issue · 2 comments

commented

Description

I made a simple Minecraft mod that integrates Shoulder Surfing Reloaded with the Iron's Spells 'n Spellbooks mod. I tested it with scroll items, the spellbook, quick cast, and controller mods, and it appears to be working properly.


Mod implementation details

Refer to this section in README.

Issue Details

I’m interested in adding this compatibility directly to either Iron’s Spells 'n Spellbooks or Shoulder Surfing Reloaded so that users won’t need any additional mods to make it work.

See also this comment in #328.

There are many ways to address this issue:

1. Modifying the internal code directly

Modify this mod’s code to check if Shoulder Surfing Reloaded is loaded and if a spell is being cast when camera is decoupled. This could be done using reflection or as a direct dependency. It could also be done using a mixin from third-party mod.

2. Improve the public API before fixing

There are two kinds of keybind actions that need fixing with Shoulder Surfing mod: Continuous and Instant.

Continuous

Mods often have keybinds that trigger continuous actions requiring aiming. Fortunately, there is the ICameraCouplingCallback API provided by this mod, which works pretty well.

It might also be useful to include it as an example.

One example that could use this callback is the Demolition Leap skill from the Epic Fight mod (fixed in Epic-Fight/epicfight#2112).

Instant

There are also other keybinds that trigger a one-time action (not continuous), which require ShoulderSurfingImpl.lookAtCrosshairTarget to be called before the action is triggered:

  • Any instant spell from Iron's Spells 'n Spellbooks The fix in my mod.
  • The Epic Fight attack keybind, which defaults to the same as the vanilla attack key but not necessarily identical. See fix PR

The idea here is that, rather than requiring all mods to depend on Shoulder Surfing’s internal implementations (checking if the mod is loaded, if the perspective is Shoulder Surfing, or if the camera is decoupled), we could try to come up with a solution that only requires information from other mods about the keybind and lets the Shoulder Surfing mod handle it instead—by simply enhancing the current public API. This way, other mods don’t have to deal with Shoulder Surfing internals directly, keeping it minimal, so that Shoulder Surfing remains in charge and there is exactly one place that controls the behavior.

As for the existing API, it seems to be working with mostly vanilla items. Curios support does not always fix the issue (see this comment in #328).

Please let me know which approach you’d prefer. Maybe after that, I could close this issue and open a more focused issue.

Minecraft version

1.21.1

Incompatible mod name

Iron's Spells 'n Spellbooks

Incompatible mod version

1.21.1-3.14.4

Game Logs

N/A

commented

Thank you for the detailed report, much appreciated! Also very nice work on the compatibility integration mod! As for fixing the bug, I would prefer option 2, which you kindly already started with #346.

commented

Fixed by installing this mod: Shoulder Surfing: Iron's Spells Integration