Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix forge interactions #3844

Merged
merged 8 commits into from Apr 21, 2023
Merged

Conversation

Yeregorix
Copy link
Member

@Yeregorix Yeregorix commented Apr 15, 2023

This PR fixes several issues with Forge interactions:

  1. PlayerInteractEvent.RightClickBlock was never fired.
  2. onItemUseFirst and doesSneakBypassUse were never called.
  3. Before firing InteractItemEvent.Primary we must ensure a block or an entity is not reachable to ensure it's indeed an item interaction. The reach was invalid, ignoring both ForgeMod#REACH_DISTANCE attribute and the gamemode.

For 1. , the approach here is different from what gabizou did in #3711. Instead of creating a custom EventContextKey to compensate the fact the Sponge event doesn't contain as much information as the Forge event. I decided to first create the Forge event first, then create the Sponge event from it. Also, I've made a few modifications to the dual bus system because I need to read the result of both events to properly support Forge PlayerInteractEvent#setCancellationResult.

All other interactions seem to be working properly but are not using the dual bus.

@Yeregorix Yeregorix merged commit a4ad38b into SpongePowered:api-8 Apr 21, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants