Solved on fishing state event bugged

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

FightingPlay

Member
Feb 26, 2017
40
1
0
22
Hay,
I tried using this code but only get this error.

Skript version:

code_language.skript:
on fishing state of caught fish:
    chance of 2.5%:
        give player diamond
        broadcast "%player% found a diamond while fishing!

code_language.skript:
can't understand this event: 'on fishing state of caught fish' (fisher.sk, line 5: on fishing state of caught fish:')

Thanks for help
 
Yeah, having the state in the initial event is borked.

You can do:

code_language.skript:
on fishing:
    if "%fishing state%" is "CAUGHT_FISH":

edit: changed "CAUGHT_ENTITY" to "CAUGHT_FISH"
 
Last edited by a moderator:
Don't use this event please , is full of bugs.

1) It will work if you caught an entity like a player/mob
2) It will work if you caught a random drop

So , there isn't a really good way to check if the player is really fishing or not.
 
Is there a way to get it with something like checking the right click and collecting of a fish?

I have done many testing to work around this , but no one was really 100% efficient.

You can check if the caught fish/entity was in water , but the player can still drop fishes on water and fish them.
You can save the total number of fishes in player's inventory first and after the fishing state , but the player can still calculate the time of fishing state and fish the dropped item.
 
I have done many testing to work around this , but no one was really 100% efficient.

You can check if the caught fish/entity was in water , but the player can still drop fishes on water and fish them.
You can save the total number of fishes in player's inventory first and after the fishing state , but the player can still calculate the time of fishing state and fish the dropped item.

... Does checking if the fishing state is caught fish not work??
 
Yeah that's true , but with the "CAUGHT_FISH" state you can't get the output. (The fish caught) , maybe for what he need it works well , but if you need to check if the player fish a specific fish , it doens't work as it need.
 
Yeah that's true , but with the "CAUGHT_FISH" state you can't get the output. (The fish caught) , maybe for what he need it works well , but if you need to check if the player fish a specific fish , it doens't work as it need.

I mean, you could get the nbt data of the caught entity:

code_language.skript:
on fishing:
    # if the player catches a fish
    "%fishing state%" is "CAUGHT_FISH"
    # gets the item information of the caught fish
    set {_nbt} to tag "Item" of nbt of caught entity
    # gets the last 2 indexes of the dataValue tag
    set {_dataValue} to subtext of "%{_nbt}%" from characters (the first index of ",Damage:" in "%{_nbt}%" + 8) to (the first index of ",Damage:" in "%{_nbt}%" + 9)
    # if there's only 1 digit to the dataValue, remove the s (from it being a short)
    replace all "s" in {_dataValue} with ""
    message "%{_dataValue}%"
[doublepost=1500654991,1500654249][/doublepost]
Hay,
I tried using this code but only get this error.

Skript version:

code_language.skript:
on fishing state of caught fish:
    chance of 2.5%:
        give player diamond
        broadcast "%player% found a diamond while fishing!

code_language.skript:
can't understand this event: 'on fishing state of caught fish' (fisher.sk, line 5: on fishing state of caught fish:')

Thanks for help

To make it look a bit more natural, you can use Skript-mirror to manually set the caught item to a diamond:

code_language.skript:
on script load:
    import "org.bukkit.event.player.PlayerFishEvent"

on "org.bukkit.event.player.PlayerFishEvent" with priority 5:
    if "%event.getState().name()%" is "CAUGHT_FISH":
        chance of 2.5%:
            message "&bSweet, sparkling surprise! That's a diamond!" to event.getPlayer()
            set {_item} to "diamond" parsed as item
            event.getCaught().setItemStack({_item})
 
Status
Not open for further replies.