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

FishHook - add method to retrieve #12310

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ShaneBeee
Copy link
Contributor

@ShaneBeee ShaneBeee commented Mar 17, 2025

This PR aims to add a method to retrieve the current fish hook casted by a player.
I've seen this asked for many times, so I think its my time to add this.

Looking for some feedback on a few things:

  1. Javadocs = I think I described things well? But always looking for feedback. Especially with the return value
  2. Using CraftItemStack.asNMSCopy() = I chose this method to prevent actually damaging the original ItemStack, allowing the dev to do the damage themselves, they may or may not want this.
    Opinions here would be appreciated. Should it be a copy? Should it be the original?
    Another option could be nixing the ItemStack all together, and internally handle it (grab based on slot chosen), maybe a boolean like shouldDamage, where could then decide to use copy/original.
    Actually nevermind nixing the itemstack, maybe the dev wants to pass thru some super powerful fishing rod. Ohhh the possibilities.
    This could go so many different ways, so feedback would be nice :)

@ShaneBeee ShaneBeee requested a review from a team as a code owner March 17, 2025 17:01
Copy link
Contributor

@notTamion notTamion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't allow plugins to pass in an itemstack at all. instead we should get the itemstack thats in the provided hand and ensure its a fishing rod. i am not sure whether calling this method with a stack other than a rod will cause any internal problems however i think it might cause some issues for plugins expecting the PlayerFishEvent to always be called with a rod

@ShaneBeee
Copy link
Contributor Author

We shouldn't allow plugins to pass in an itemstack at all. instead we should get the itemstack thats in the provided hand and ensure its a fishing rod. i am not sure whether calling this method with a stack other than a rod will cause any internal problems however i think it might cause some issues for plugins expecting the PlayerFishEvent to always be called with a rod

I can definitely change it, since it seems to be consensus.

for the record:

i am not sure whether calling this method with a stack other than a rod will cause any internal problems

The passed ItemStack appears to be only used for criteria triggers and for the loot table. (Although not sure what it does exactly in the loot table)

however i think it might cause some issues for plugins expecting the PlayerFishEvent to always be called with a rod

The event doesn't use this itemstack, it appears to grab straight from the slot of the player.

I guess at the end of the day its pretty useless to allow passing in another itemstack, ill change it.

@ShaneBeee
Copy link
Contributor Author

Update, I have removed the ItemStack from the method, and now retrieving it from the player based on the provided slot.
Also added a check to make sure the player is actually holding a fishing rod

@ShaneBeee ShaneBeee requested a review from notTamion March 24, 2025 00:07
@kennytv kennytv added type: feature Request for a new Feature. scope: api labels Mar 24, 2025
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: Changes required
Development

Successfully merging this pull request may close these issues.

4 participants