Compatibility Guide
There are many aspects of Stardew Fishing that modders need to be aware about when developing compatible fishing-related mods. Firstly, all of the information located on the Datapacks page is relevant to mod developers.
This includes:
- Setting up item tags
- Any custom fish items that have been added to the fishing loot table must be added to the
stardew_fishing:starts_minigameitem tag unless they have been added to theminecraft:fishesitem tag. - Any custom fish items that are not edible must also be added to the
stardew_fishing:inedible_fishesitem tag. This is so that Quality Food will recognize these items as valid candidates for having a quality level applied.
- Any custom fish items that have been added to the fishing loot table must be added to the
- Fish Behavior
- If you want your custom fish items to have unique or at least non-default behavior in the minigame, you can define custom fish behavior for them.
Custom Fishing Rod Items
If your mod adds custom fishing rod items, Stardew Fishing's minigame will work automatically (as long as you don't use a custom fishing hook entity). However, you will not be able to apply Stardew Fishing's bobber items unless you set up compatibility with Tide and/or Aquaculture.
Compat with Tide
With Tide, it is as easy as adding your fishing rod item to the tide:customizable_rods item tag. For more information about making addons for Tide, including custom bobber items, see Tide's wiki page.
Compat with Aquaculture
With Aquaculture, you must have your fishing rod item's class extend AquaFishingRodItem instead of FishingRodItem and supply a Tier in the constructor. However, this will make Aquaculture a required dependency which is why we like Tide more than Aquaculture.
Custom Fishing Hook Entities
Stardew Fishing's minigame is triggered through a mixin on the vanilla FishingHook class, so if you make use of a custom fishing hook entity class, the minigame will not work out of the box. Stardew Fishing includes compat for the custom hook entities from Aquaculture and Nether Depths Upgrade, and Tide includes compatibility for us on their end.
Here is what you need to do to make sure the minigame works properly:
- Your entity must extend
FishingHook - Write the following code in the entity's constructor after timeUntilLured is calculated (either by you or in the call to the super constructor):
- Override the
catchingFish()method and write the following code: - Override and duplicate the
retrive()method and write the following code before posting theItemFishedEvent:// the variable "items" is the List<ItemStack> of fishing loot ServerPlayer player = (ServerPlayer) getPlayerOwner(); if (player != null) { if (items.stream().anyMatch(stack -> stack.is(StardewFishing.STARTS_MINIGAME))) { // at least one item starts the minigame FishingHookLogic.getStoredRewards(this).ifPresent(rewards -> rewards.addAll(items)); if (FishingHookLogic.startStardewMinigame(player)) { // minigame started successfully, don't spawn the items yet return; } } else { // no item starts the minigame, so spawn the items like normal FishingHookLogic.modifyRewards(items, 0, null); player.level().playSound(null, player, SFSoundEvents.PULL_ITEM.get(), SoundSource.PLAYERS, 1.0F, 1.0F); } }
If you run into issues, feel free to make an issue on the GitHub page asking for help!
Attachment Modifier Items
Warning
This system will likely be replaced in the future.
Applying attribute modifiers through a fishing rod item introduces unintended behavior when holding a fishing rod in both the main hand and off hand. The player could receive the buffs from both rods at the same time or avoid taking durability damage on the rod in the off hand. Disabling the buffs when the rod is in the off hand is not an ideal solution because then players could lose their buffs just because they had their rod in their off hand. To solve this, Stardew Valley's bobber items use a system called Attachment Modifier Items.
This system allows items that are attached to fishing rods to only apply their attribute modifiers if they are attached to the dominant fishing rod (the one that will take damage) when the minigame starts.
For mod developers:
- Have your bobber item class extend the interface
AttributeAttachmentItem. - Instead of overriding
IForgeItem#getAttributeModifiers()orItem#getDefaultAttributeModifiers(), override AttributeAttachmentItem#getDefaultAttachmentModifiers()`. - Return a list of attribute modifiers.
For datapack/modpack creators:
- Instead of including an
AttributeModifiersnbt tag, call itAttachmentModifiers.