Architectury API (Fabric/Forge/NeoForge)

Architectury API (Fabric/Forge/NeoForge)

158M Downloads

Conflict with Mouse Tweaks due to DelegateScreen wrapping

YaLTeR opened this issue ยท 3 comments

commented

Hi, I'm the developer of Mouse Tweaks. I recently added a Fabric version and just got a bug report that Mouse Tweaks doesn't work when Architectury is loaded.

The way Mouse Tweaks currently works is it subscribes to every Screen's mouse events (with its own mixin for the dragging as there's no hook in Fabric for this), and checks in the callbacks if it can handle the screen that it gets. In particular, the check succeeds if screen instanceof AbstractContainerScreen.

Now this is what I'm seeing in the log upon holding and releasing my mouse with Architectury loaded:

[15:49:03] [Render thread/INFO]: [STDOUT]: [Mouse Tweaks] You have just opened a class_476.
[15:49:03] [Render thread/INFO]: [STDOUT]: [Mouse Tweaks] Handler: GuiContainerHandler; Mouse Tweaks is enabled; wheel tweak is enabled.
[15:49:04] [Render thread/INFO]: [STDOUT]: [Mouse Tweaks] You have just opened a DelegateScreen.
[15:49:04] [Render thread/INFO]: [STDOUT]: [Mouse Tweaks] No valid handler found; Mouse Tweaks is disabled.
[15:49:05] [Render thread/INFO]: [STDOUT]: [Mouse Tweaks] You have just opened a class_476.
[15:49:05] [Render thread/INFO]: [STDOUT]: [Mouse Tweaks] Handler: GuiContainerHandler; Mouse Tweaks is enabled; wheel tweak is enabled.

So Mouse Tweaks does recognize the screen initially, but for the duration of mouse hold and drag the events get delivered to a DelegateScreen which Mouse Tweaks does not recognize. I haven't checked yet but it might be specifically the drag handler that does this.

This seems like something Architectury does:

How should we fix this, should Architectury adjust the behavior somehow, or is there a workaround I can add to Mouse Tweaks?

Thanks.

commented

Perhaps Architectury could change the mouse dragged hook to behave the same as clicked/released? I suspect that should resolve the conflict.

commented

I'm trying to do this and the problem I see is that the original vanilla mouse drag lambda doesn't store the return value of mouseDragged() making it non-trivial to return early, i.e. before running the POST callback.

(on a related note, I also noticed that Architectury erroneously calls the PRE callback twice instead of PRE and POST)

commented

I added a workaround to Mouse Tweaks for now that retrieves DelegateScreen.parent via reflection but I can't say I'm very happy with that solution.