Tutorial: How to make a fishing rod have a custom effect

Started by myxical on

Topic category: User side tutorials

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Tutorial: How to make a fishing rod have a custom effect
Tue, 08/08/2023 - 18:01 (edited)

I won't explain how to make a fishing rod TOOL here, but if you're using MCreator for some time then you should have absolutely no problem with making a new fishing rod tool.

Here's the tutorial (note that this code is optimized for multiple custom fishing rods):

First, there is a tag called "forge:tools/fishing_rods". Make sure to add all your custom fishing rods in this tag.
Then, make a procedure with a global trigger "Player fishes item", then create a itemstack variable, which we'll call just "variable" here for simplicity. This variable will be used to check what fishing rod the player is holding.
Now build this code:

if: Item in MAIN-hand of event/target entity tagged in item tags as "forge:tools/fishing_rods"
do: Set variable to: Item in MAIN-hand of event/target entity
else if: AND: NOT Item in MAIN-hand of event/target entity tagged in item tags as "forge:tools/fishing_rods"
                      Item in OFF-hand of event/target entity tagged in item tags as "forge:tools/fishing_rods"
do: Set variable to: Item in OFF-hand of event/target entity

Explanation: Basically, if the player is holding a fishing rod in their main-hand, then set the variable as the item in main-hand (the fishing rod). However if the player is holding a fishing rod in their off-hand, also check if the player is not holding a fishing rod in their main-hand, and then set the variable.
Normally when you hold 2 fishing rods, only the main-hand one is casted. So this code prevents custom effects from occouring when holding the fishing rod in off-hand but not using it, while still having it work when if off-hand with no fishing rod in main-hand. I hope this this sounds understandable lol

Next, make code like: "if Get variable = your custom fishing rod" for each custom fishing rod you have and put your custom effect there. If you want to replace the item you get for fishing, you can use the "Cancel event that triggered global trigger" block and spawn an item on the player and give XP (in vanilla you get 1-6).

But I don't know how to actually make it so the item gets fished up from the position the fishing bobber and thrown towards you. I think it's still possible though, there's a plugin called Procedure Fiesta which has a "Get fishing bobber of player Entity" block, but doing the item throw is too technical for me and if you're better at coding then you might be able to do it the proper way :P

Now, because we're using a forge tag, this should be compatible with fishing rods from other mods, unless they weren't included in the tag, in that case this is a bug with that mod which should be reported.

That was a lot of typing. And effort lol. Alright guys, catch you later!

Edited by myxical on Tue, 08/08/2023 - 18:01