Coding Help Adding one fish to Beach location overwrites fish spawn pool

bapey

Newcomer
Hello! I would like some help creating a small mod that adds one fish to the game as a starting point! I've been using Content Patcher as I think that's all I'll need to complete this. I've used Ridgeside Village and the in-game XNBs to formulate my JSONs. Furthermore, I've been able to spawn in the item I added, but I crash when I attempt to fish it from the location I've added it to! I can fish up normal fish & trash from the Beach, but I'm assuming it is crashing when it reaches my fish. I've included raw versions of these files below so no one has to download them.

The error code is as follows:
Code:
[game] An error occurred in the base update loop: FormatException: Input string was not in a correct format.
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
   at StardewValley.Menus.BobberBar..ctor(String whichFish, Single fishSize, Boolean treasure, List`1 bobbers, String setFlagOnCatch, Boolean isBossFish, String baitID, Boolean goldenTreasure) in D:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Menus\BobberBar.cs:line 105
   at StardewValley.Tools.FishingRod.startMinigameEndFunction(Item fish) in D:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Tools\FishingRod.cs:line 751
   at StardewValley.TemporaryAnimatedSprite.unload() in D:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\TemporaryAnimatedSprite.cs:line 1029
   at StardewValley.TemporaryAnimatedSprite.update(GameTime time) in D:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\TemporaryAnimatedSprite.cs:line 1182
   at StardewValley.Game1.UpdateOther(GameTime time) in D:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 6732
   at StardewValley.Game1._update(GameTime gameTime) in D:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 4093
   at StardewValley.Game1.Update(GameTime gameTime) in D:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 3199
   at StardewModdingAPI.Framework.SCore.OnPlayerInstanceUpdating(SGame instance, GameTime gameTime, Action runUpdate) in SMAPI\Framework\SCore.cs:line 1082
These are the JSONs I've created for this:

manifest.json:
JSON:
{
    "Name": "Custom Fish Reimplemented by Bapey",
    "Author": "Bapey",
    "Description": "Reimplements fish from older mods.",
    "Version": "1.0.0",
    "UniqueID": "Bapey.CustomFishReimplemented",
    "UpdateKeys": ["Nexus:???"],
    "ContentPackFor": {
        "UniqueID": "Pathoschild.ContentPatcher"
    }
}
content.json:
JSON:
{
    "Format": "2.0.0",
    "Changes": [
        {
            "LogName": "Include Fish Data",
            "Action": "Include",
            "FromFile": "data/Aquarium.json, data/fish.json, data/fishpond.json"
        },
        {
            "LogName": "Include Object Data",
            "Action": "Include",
            "FromFile": "data/Objects.json"
        }
    ]
}
fish.json
(I've also tried a much smaller fish.json similar to Ridgeside Village):
JSON:
{
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/Fish",
            "Entries": {
                "Bapey.CustomFishReimplemented_InvertedClownFish": "Inverted Clownfish/15/sinker/2.7/6.7/600 2600/spring summer fall winter/both/683 .4/1/.2/.3/0/false"
            }
        },
        {
            "Action": "EditData",
            "Target": "Data/Locations",
            "Fields": {
                "Beach": {
                    "Fish": [
                        {
                            "ItemId": "Bapey.CustomFishReimplemented_InvertedClownFish",
                            "Condition": "SEASON Here spring summer fall winter"
                        }
                    ]
                }
            }
        }
    ]
}
Larger fish.json:
JSON:
{
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/Fish",
            "Entries": {
                "Bapey.CustomFishReimplemented_InvertedClownFish": "Inverted Clownfish/15/sinker/2.7/6.7/600 2600/spring summer fall winter/both/683 .4/1/.2/.3/0/false"
            }
        },
        {
            "Action": "EditData",
            "Target": "Data/Locations",
            "Fields": {
                "Beach": {
                    "Fish": [
                        {
                            "Id": "Bapey.CustomFishReimplemented_InvertedClownFish",
                            "ItemId": "Bapey.CustomFishReimplemented_InvertedClownFish",
                            "RandomItemId": null,
                            "MaxItems": null,
                            "MinStack": -1,
                            "MaxStack": -1,
                            "Quality": -1,
                            "ObjectInternalName": null,
                            "ObjectDisplayName": null,
                            "ToolUpgradeLevel": -1,
                            "IsRecipe": false,
                            "StackModifiers": null,
                            "StackModifierMode": 0,
                            "QualityModifiers": null,
                            "QualityModifierMode": 0,
                            "ModData": null,
                            "PerItemCondition": null,
                            "Condition": "LOCATION_SEASON Here spring summer fall winter",
                            "CatchLimit": -1,
                            "Chance": 1,
                            "Season": null,
                            "FishAreaId": null,
                            "BobberPosition": null,
                            "PlayerPosition": null,
                            "MinFishingLevel": 0,
                            "MinDistanceFromShore": 0,
                            "MaxDistanceFromShore": -1,
                            "ApplyDailyLuck": false,
                            "CuriosityLureBuff": -1,
                            "IsBossFish": false,
                            "SetFlagOnCatch": null,
                            "RequireMagicBait": false,
                            "Precedence": 0,
                            "IgnoreFishDataRequirements": false,
                            "CanBeInherited": true,
                            "ChanceModifiers": null,
                            "ChanceModifierMode": 0,
                            "ChanceBoostPerLuckLevel": 0,
                            "UseFishCaughtSeededRandom": false
                        }
                    ]
                }
            }
        }
    ]
}
fishponds.json:
JSON:
{
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/FishPondData",
            "Entries": {
                "Inverted Clownfish": {
                    "RequiredTags": [
                        "item_inverted_clownfish"
                    ],
                    "Precedence": 0,
                    "SpawnTime": -1,
                    "ProducedItems": [
                        {
                            "RequiredPopulation": 10,
                            "Chance": 0.40,
                            "ItemID": 390,
                            "MinQuantity": 3,
                            "MaxQuantity": 4
                        },
                        {
                            "RequiredPopulation": 6,
                            "Chance": 0.45,
                            "ItemID": 390,
                            "MinQuantity": 2,
                            "MaxQuantity": 4
                        },
                        {
                            "RequiredPopulation": 3,
                            "Chance": 0.50,
                            "ItemID": 390,
                            "MinQuantity": 1,
                            "MaxQuantity": 2
                        },
                        {
                            "RequiredPopulation": 0,
                            "Chance": 0.70,
                            "ItemID": 390,
                            "MinQuantity": 1,
                            "MaxQuantity": 2
                        }
                    ],
                    "PopulationGates": {
                        "2": [
                            "390 2"
                        ],
                        "4": [
                            "390 2"
                        ],
                        "8": [
                            "390 2"
                        ]
                    }
                }
            }
        }
    ]
}
aquarium.json:
JSON:
{
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/AquariumFish",
            "Entries": {
                "Bapey.CustomFishReimplemented_InvertedClownFish": "1/fish"
            }
        },
        {
            "Action": "Load",
            "Target": "assets/testClownFish",
            "FromFile": "assets/testClownFish.png"
        }
    ]
}
Any help or pointers would be greatly appreciated! I would like to stray away from external libraries or other dependencies for now. Thank you again, have a wonderful day.
 

bapey

Newcomer
Hey all! Back again. Doing some testing for my fish mod, again just one fish. It seems to overwrite the entire spawn pool (except for trash) whenever I patch the fish into the game! I'm just adding it to an entry in the beach location data. The fish works as an item, in fishponds, in aquariums, and can be caught. The only issue is no other fish can be caught at the beach location. These files were made mirroring both game code, and some other mods that add fish to the game like Ridgeside Village and Stardew Valley Expanded.

Here's my updated code

Objects.json:
JSON:
{
    "Changes": [
        {
            "LogName": "Load Marine Male Lyretail Anthias",
            "Action": "Load",
            "Target": "Mods\\Bapey.CustomFishReimplemented\\Objects\\MarineMaleLyretailAnthias",
            "FromFile": "Assets/Marine Male Lyretail Anthias.png"
        },
        {
            "LogName": "Objects Data",
            "Action": "EditData",
            "Target": "Data/Objects",
            "Entries": {
                "Bapey.CustomFishReimplemented_MarineMaleLyretailAnthias": {
                    "Name": "Marine Male Lyretail Anthias",
                    "DisplayName": "Marine Male Lyretail Anthias",
                    "Description": "A striking reef fish that lives in large groups.",
                    "Type": "Fish",
                    "Category": -4,
                    "Price": 200,
                    "Texture": "Mods\\Bapey.CustomFishReimplemented\\Objects\\MarineMaleLyretailAnthias",
                    "Edibility": 8,
                    "ExcludeFromFishingCollection": false,
                    "ExcludeFromShippingCollection": true,
                    "ExcludeFromRandomSale": true,
                    "ContextTags": [
                        "color_red",
                        "fish_marine_male_lyretail_anthias",
                        "alexs_fish",
                        "fish_ocean"
                    ]
                }
            }
        }
    ]
}
fish.json:
JSON:
{
    "Changes": [
        {
            "Action": "EditData",
            "Target": "Data/Fish",
            "Entries": {
                "Bapey.CustomFishReimplemented_MarineMaleLyretailAnthias": "Marine Male Lyretail Anthias/10/dart/4/8/600 1200/spring summer/sunny/689 .35 680 .1/1/.2/.1/0/true"
            }
        },
        {
            "Action": "EditData",
            "Target": "Data/Locations",
            "Fields": {
                "Beach": {
                    "Fish":[
                        {
                            "Id": "Bapey.CustomFishReimplemented_MarineMaleLyretailAnthias",
                            "ItemId": "Bapey.CustomFishReimplemented_MarineMaleLyretailAnthias",
                            "RandomItemId": null,
                            "MaxItems": null,
                            "MinStack": -1,
                            "MaxStack": -1,
                            "Quality": -1,
                            "ObjectInternalName": null,
                            "ObjectDisplayName": null,
                            "ToolUpgradeLevel": -1,
                            "IsRecipe": false,
                            "StackModifiers": null,
                            "StackModifierMode": 0,
                            "QualityModifiers": null,
                            "QualityModifierMode": 0,
                            "ModData": null,
                            "PerItemCondition": null,
                            "Condition": "LOCATION_SEASON Here spring summer",
                            "Chance": 1,
                            "Season": null,
                            "FishAreaId": null,
                            "BobberPosition": null,
                            "PlayerPosition": null,
                            "MinFishingLevel": 0,
                            "MinDistanceFromShore": 0,
                            "MaxDistanceFromShore": -1,
                            "ApplyDailyLuck": false,
                            "CuriosityLureBuff": -1,
                            "CatchLimit": -1,
                            "IsBossFish": false,
                            "SetFlagOnCatch": null,
                            "RequireMagicBait": false,
                            "Precedence": 0,
                            "IgnoreFishDataRequirements": false,
                            "CanBeInherited": true,
                            "ChanceModifiers": null,
                            "ChanceModifierMode": 0,
                            "ChanceBoostPerLuckLevel": 0,
                            "UseFishCaughtSeededRandom": false
                        }
                    ]
                }
            }
        }
    ]
}
 
Last edited:

bapey

Newcomer
I think the issue is that the content patcher is changing the beach's fish to just the one added fish. It says in the documentation that the EditData action can add, edit, or delete entries, so where is my formatting can I make this an append as opposed to a replace?
 

bapey

Newcomer
Solved!!! Thank you Stardew Valley Expanded, to append rather than replace in Content Patcher, the following is used:

JSON:
{
            "Action": "EditData",
            "Target": "Data/Locations",
            "TargetField": [
                "Beach",
                "Fish"
            ],
            "Entries":{
                "Id": "Bapey.CustomFishReimplemented_MarineMaleLyretailAnthias",
                "ItemId": "Bapey.CustomFishReimplemented_MarineMaleLyretailAnthias",
                "Condition": "LOCATION_SEASON Here spring summer"
            }
        }
 
Top