Skip to content

Add FishHookStateChangeEvent to detect fishing hook state transitions.#12165

Merged
notTamion merged 6 commits into
PaperMC:mainfrom
NamiUni:feat-fishing-hook-state-change-event
May 15, 2025
Merged

Add FishHookStateChangeEvent to detect fishing hook state transitions.#12165
notTamion merged 6 commits into
PaperMC:mainfrom
NamiUni:feat-fishing-hook-state-change-event

Conversation

@NamiUni
Copy link
Copy Markdown
Contributor

@NamiUni NamiUni commented Feb 23, 2025

Currently, PlayerFishEvent is not triggered when a FishHook changes its state. This means that if you want to track state transitions, you have to monitor them using a scheduler, which is inefficient. To address this, I have implemented FishHookStateChangeEvent.

  • This event is useful when you want to send messages, titles, or sounds to players based on fishing hook state transitions.
  • Canceling the transition to HookState.BOBBING prevents Minecraft#FishingHook#catchingFish from executing.
  • Be cautious when handling this event, as canceling it will not prevent the state transition from being re-evaluated in the next tick. If the conditions are still met, the event will be instantiated and called repeatedly. (This behavior is documented in the Javadoc.) Reverted due to spamming of events and desync with the client side.

For consistency, this event is mostly copied from PufferFishStateChangeEvent. However, I feel that "State Transition" might be a more appropriate term than "State Change."

@NamiUni NamiUni requested a review from a team as a code owner February 23, 2025 06:36
@NamiUni
Copy link
Copy Markdown
Contributor Author

NamiUni commented Feb 28, 2025

After re-testing, I confirmed that everything works perfectly. If nothing has been overlooked, then this should be complete👍

hookeventtest.mp4

@github-project-automation github-project-automation Bot moved this from Awaiting review to Awaiting final testing in Paper PR Queue Feb 28, 2025
@Warriorrrr Warriorrrr added type: feature Request for a new Feature. scope: api labels Mar 17, 2025
@notTamion notTamion force-pushed the feat-fishing-hook-state-change-event branch from 721dbc0 to 5484cdf Compare May 15, 2025 18:13
@notTamion notTamion merged commit d683970 into PaperMC:main May 15, 2025
@github-project-automation github-project-automation Bot moved this from Awaiting final testing to Merged in Paper PR Queue May 15, 2025
@NamiUni
Copy link
Copy Markdown
Contributor Author

NamiUni commented May 17, 2025

Hi notTamion!
Sorry for leaving the pull request unattended for a while. I just noticed that you updated and merged it—thank you so much for taking care of it! I really appreciate your help and the time you took to make those edits.

@NamiUni NamiUni deleted the feat-fishing-hook-state-change-event branch May 17, 2025 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: api type: feature Request for a new Feature.

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

5 participants