Tutorial: Making a New Crop

From The Stardew Modding Wiki
Jump to navigation Jump to search

Making a new crop is easy with Category:Json Assets (JA), but involves a few more steps than some other beginner mods. However, don't be intimidated by the length of this tutorial! It's only long so as to explain each step clearly so that anyone - even someone with no programming experience - can easily follow along.

Future Infobox info: CopperSun, April 21 2021

Getting Started[edit | edit source | hide | hide all]

You may notice that parts of this tutorial will overlap with Tutorial: Adding a Recipe. That's because both use Json Assets and both generate an object. As you do more and more with a framework it becomes easier and easier to see how to create new and exciting mods with just a few key changes.

  1. Install SMAPI if you haven't already.
  2. Install Category:Json Assets.
  3. Get Notepad++, Visual Studio, or another text editing program designed for reading code. (You'll be using it for Json files.)
  4. Look over the official documentation for Json Assets crops.
    1. It's okay if you don't understand this documentation yet. Think of it as a dictionary or reference guide where you can look up different options as you need them.

Finding Examples[edit | edit source | hide]

If there is one kind of mod it's easy to find examples of, it's new crops!

  1. My favorite example of a new crop is Lucky Clover, which adds just one crop and does it well.
  2. To see some of the fun things you can do with crops, like creating a plant that grows iridium, check out Fantasy Crops.
  3. 6480's Giant Crops shows how to add giant crops for pretty much anything.
  4. Joja Seeds was literally made to write this tutorial. :)

Setting Up Your Folders[edit | edit source | hide]

You're going to need a very specific folder set up to make your crops work. Follow these steps exactly.

  1. Go into your Stardew Valley\Mods folder and create a new folder for your new mod. Name it whatever you want your crop mod to be called. Let's assume it's "Crop Test."
  2. Inside your new mod folder, create a new file and name it "manifest.json."
  3. Also inside your new mod folder, create two more folders. Name one "Crops" and one "Objects"
  4. Proper folder structure for creating a crop called "Purple Parsnip" for a mod called "Crop Test"
    Inside Crops, create yet another folder. This folder should be the name of your crop. Let's assume your crop will be "Purple Parsnip."
  5. Inside Stardew Valley\Mods\Crop Test\Crops\Purple Parsnip, create a file called "crop.json"
  6. Go back to your Objects folder and create another, separate "Purple Parsnip" folder. In this folder, create a file called "object.json"
  7. If you got it all right, it should look like the image to the right.

Making a Manifest[edit | edit source | hide]

{
   "Name": "Your mod name",
   "Author": "Your user name",
   "Version": "1.0.0",
   "Description": "Short description of your mod.",
   "UniqueID": "YourName.YourModName",
   "UpdateKeys": [],
   "ContentPackFor": {
      "UniqueID": "spacechase0.JsonAssets",
   }
}
  1. In manifest.json, copy-paste the above text exactly. Don't forget the opening and closing braces!
  2. Change the details to be appropriate for your mod. The most important thing here is that we specify this is a contact pack for spacechase0.JsonAssets.
  3. For more details about how a Manifest for Json Assets works, see Adding a Recipe.

Making the Object Your Crop Produces[edit | edit source | hide]

Next we're going to focus on what the player will harvest from your crop. You don't necessarily have to do this step next, but it's convenient so it's the order we'll use.
{
  "Name": "Purple Parsnip",
  "Description": "A parsnip that is a beautiful shade of purple.",
  "Category": "Vegetable",
  
  "Edibility": 10,
  "EdibleIsDrink": false,

  "EdibleBuffs": {
    	"Farming": 0,
    	"Fishing": 0,
    	"Mining": 0,
    	"Luck": 0,
    	"Foraging": 0,
    	"MaxStamina": 0,
    	"MagnetRadius": 0,
    	"Speed": 0,
    	"Defense": 0,
    	"Attack": 0,
    	"Duration": 0,
  },
  
  "Price": 35,
  
  "IsColored": false,
  "Recipe": null,
  
  "GiftTastes": 
		{
		"Love": [ "Pam", "Abigail", ],
		"Like": [ "Sophia", ],
		"Neutral": [  ],
		"Dislike": [ "Clint", ],
		"Hate": [ "George",  ],	
		},
   
  "ContextTags": 
        [
		    "color_purple",
		    "dye_medium",
        ],
}
If you followed the tutorial for Adding a Recipe, you'll see a lot of similarities between the code there and here. That's because both a recipe and a harvested crop item are objects so they have many of the same options. I'll be skipping over some of the code because of this, so please reference the previous tutorial if there is a line you aren't sure about.
  1. "Name": "Purple Parsnip",
    1. This line is crucial not just because it's where we name our object, but because this name is how Json Assets, Smapi, and Stardew Valley will all refer to this object. If another mod or the original game also contains an object called "Purple Parsnip" there will be an error and Smapi will fail to load.
    2. There isn't really a good way to know if a crop is already "taken" except by downloading literally every other crop mod out there. That's not feasible for most people, so it's best to list out the names of the crops you're adding on your mod page on Nexus or ModDrop and also to try for names that aren't likely to already be in use. There are so many crops now, though, that even unusual plants have already been made!
    3. When in doubt, it's your mod and the worst that happens is its incompatible with some other mod. No big deal; players can just delete one folder or the other. (hopefully the other :D ) It's just something to watch out for.
  2. "Category": "Vegetable",
    1. Something fun about crops in Stardew Valley is they don't have to grow fruit, vegetables, or flowers. No, they can grow anything you can dream up and put in the game!
    2. We're going to make our purple parsnip a vegetable, but you can get a list of all the categories available from the official documentation. Feel free to grow "Junk," "Syrup," "Egg," or anything else you like.
  3. "Edibility": 10,
    1. As discussed in the recipe tutorial, edibility is kind of weird. You can see the official wiki for the math, but generally just put a low number for the player to regain a lower amount of health and energy and a higher number for higher health and energy.
  4. "EdibleBuffs":
    1. These are very boring parsnips, despite their beautiful hue, so they won't give the player any buffs for eating them.
  5. "Price": 35,
    1. Selling these parsnips to Pierre or via the shipping bin will give the player 35g for a basic parsnip.
  6. "IsColored": false,
    1. Our parsnips come in just one color, purple. To see an example of creating flowers that can have multiple colors, see Mizu's Flowers.
  7. "Recipe": null,
    1. This is not a recipe, and we will not be specifying ingredients or anything.
  8. "GiftTastes":
    1. Any NPC we do not specify in this array will default to how they feel about the category of our object or, if they don't care about the category one way or the other, neutral.
    2. A lot of NPCs like vegetables, so most NPCs will like our purple parsnips. Vince and Jas, however, dislike vegetables as a category and will dislike our crop's produce.
    3. Notice the inclusion of Stardew Valley Expanded's Sophia. You can put in any NPCs from other mods you like. If Smapi detects that those NPCs are installed, it will assign the gift taste accordingly. If the NPC is not installed, Smapi will just ignore it. This is very handy for mod compatibility. Just make sure to get the NPC's name exactly right!
  9. "ContextTags":
    1. An object can have any number of context tags. Stardew Valley uses these for a variety of purposes. You don't need to put them on your produce, but there's nothing stopping you either.
    2. You can see a list of the tags in the game for existing objects on the official wiki.
  10. And that's your code for object.json! Now we'll make our parsnip.

Illustrating the Object Your Crop Produces[edit | edit source | hide]

The easiest way to make a new crop is to copy an old one. We're going to take a regular parsnip and just paint it purple. :)

  1. Open up the art program of your choice and make a new 16x16 pixel transparent png.
    1. It doesn't matter what program you use, but it does matter that the program support transparency. Aesprite is popular for sprite work and Photoshop and Gimp are the other main programs people use due to availability.
  2. Your lovely purple parsnip as an object.json and object.png.
    Either unpack the game files (quick and easy) and open up Stardew Valley\Content (unpacked)\Maps\springobjects.png or else just rely on your own artistic merits to draw a parsnip. I have few artistic merits, so I'll be copying the parsnip in springobjects.png into my 16x16 square.
    1. All objects, not just ones related to spring, are in that springobjects.png. Why? Ask ConcernedApe. ¯\_(ツ)_/¯
  3. Color over your copied parsnip to make it purple. (Or whatever you want; I'm not going to come over to your house and judge.)
  4. When you're done, save your 16x16 transparent png as "object.png" inside Stardew Valley\Mods\Crop Test\Objects\Purple Parsnip.
  5. You should now have both an object.json and an object.png telling Json Assets exactly what a purple parsnip is and looks like. If you wanted, you could stop here and add this to the game, but we want to grow our purple parsnips so next up is making the actual crop.
  6. So pretty: A purple parsnip.

Creating Your Crop[edit | edit source | hide]

Now we're going to create the seeds and plant that grow purple parsnips.
{
    "Name": "Purple Parsnip",
    "Product": "Purple Parsnip",
    "SeedName": "Purple Parsnip Seeds",
	
    "SeedDescription": "Plant in spring for a lovely purple veggie. Takes 4 days to mature.",
	
    "Type": "Vegetable",

    "Seasons": ["spring", ],
    "Phases": [ 1, 1, 1, 1 ],
    "RegrowthPhase": -1,
    "HarvestWithScythe": false,
    "TrellisCrop": false,
    "Colors": null,
	
    "Bonus": {
        "MinimumPerHarvest": 1,
        "MaximumPerHarvest": 1,
        "MaxIncreasePerFarmLevel": 0,
        "ExtraChance": 0.0,
    },
		
	"SeedPurchaseFrom": "Pierre",
    "SeedPurchasePrice": 20,
	"SeedSellPrice": 10,
}
  1. Open up crop.json in Stardew Valley\Mods\Crop Test\Crops\Purple Parsnip and paste in the code above exactly. Don't forget the opening and closing braces!
  2. "Name": "Purple Parsnip",
    1. This is the name of the crop. The crop is the plant that grows from the seeds and produces an object. It will almost always (but not always-always!) be named the same thing as what it produces. An exception would be something like "Iridium Plant" with product "Iridium."
  3. "Product": "Purple Parsnip",
    1. This is what our crop produces, the Purple Parsnip we made in the section before this one.
  4. "SeedName": "Purple Parsnip Seeds",
    1. Unsurprisingly, this is the name of the seeds for our crop. It doesn't have to say "seeds." For example, if you were making a daffodil crop you could call it "Daffodil Bulbs."
  5. "SeedDescription": "Plant in spring for a lovely purple veggie. Takes 4 days to mature.",
    1. This is the description that the player will see when they mouse over or select the seeds. It's generally a good idea to specify the season, how many days it takes to grow, and if more crops will grow after the first harvest.
  6. "Type": "Vegetable",
    1. The same as the type we used for our object.json.
  7. "Seasons": ["spring", ],
    1. What season(s) our crop will grow in. To have more than one season, just add to the array like this: [ "spring", "summer", ]
  8. "Phases": [ 1, 1, 1, 1 ],
    1. This is probably the trickiest line in the whole thing, and it's still not too complicated. Here's the text from the JA documentation: Determines how long each phase lasts. Crops can have 2-5 phases, and the numbers in phases refer to how many days a plant spends in that phase.
      1. However, ignore the part in the documentation that claims you should include the regrowth phase here. That is outdated and incorrect. Regrowth goes on the next line.
    2. What we're going to do is just look at the wiki page for parsnip seeds and blatantly copy. :) See where it says "Stages" and then "1 day | 1 day | 1 day | 1 day"? That's where we're getting our "1, 1, 1, 1" from.
    3. If we were copying the bean starter, we'd use "1, 1, 1, 3, 4"
    4. After you've made a couple crops and watched them grow, this part will feel much more intuitive.
    5. The first stage is seeds and is actually the first two 16-pixel spaces in your crop.png (more on this later).
  9. "RegrowthPhase": -1,
    1. Our purple parsnips do not regrow so we set this to -1.
    2. When you decide to start making more exciting crops, including crops that regrow, read the JA Crop documentation and look at examples. Again, it's pretty intuitive once you've already made a couple.
    3. Note - due to the way JA is set up, your crop can be colored or it can have a regrowth phase, but not both.
  10. "HarvestWithScythe": false,
    1. Our purple parsnips are not harvested with a scythe.
  11. "TrellisCrop": false,
    1. This is not a trellis crop, which means the player is free to run through it (unlike grapes).
  12. "Colors": null,
    1. Our parsnips come in just one color, purple.
  13. "Bonus": {
    1. This section determines if you get "extra" parsnips upon harvest, and if so how many and how likely it is.
  14. "MinimumPerHarvest": 1,
    1. You get at least one purple parsnip upon harvest...
  15. "MaximumPerHarvest": 1,
    1. And only one purple parsnip upon harvest.
  16. "MaxIncreasePerFarmLevel": 0,
    1. Do not increase the number of parsnips that can be harvested based on farmer level. (This was incorrectly in the JA documentation as giving farming experience, but will actually cause you harvest about a jillion potatoes if you set it to, say, 20 with an extra chance of .2)
  17. "ExtraChance": 0.0,
    1. There is absolutely no chance of getting an extra purple parsnip during harvest.
    2. Use a decimal if you do want a chance. 0.2 is 20%, 0.75 is 75%, etc.
    3. Chance might be affected by luck - can anyone confirm?
  18. "SeedPurchaseFrom": "Pierre",
    1. The seeds for our crop can be purchased from Pierre. Other options can be found in the documentation. Pierre is also the default.
  19. "SeedPurchasePrice": 20,
    1. A pack of seeds will cost a very reasonable 20g.
    2. If you are selling your seeds via Category:Shop Tile Framework, you will need to price them individually in STF as STF does not currently recognize JA's seed purchase price field.
  20. "SeedSellPrice": 10,
    1. We can sell a pack of seeds for 10g.

Setting up Localization Options[edit | edit source | hide]

  1. If you'd like to make your mod compatible with translations (recommended!), add the following to your object.json file:
    	  "NameLocalization": {
        // "es": "",
        // "ko": "",
        // "de": "",
        // "fr": "",
        // "hu": "",
        // "it": "",
        // "ja": "",
        // "pt": ""
        // "ru": "",
        // "tr": "",
        // "zh": ""
      },
      "DescriptionLocalization": {
        // "es": "",
        // "ko": "",
        // "de": "",
        // "fr": "",
        // "hu": "",
        // "it": "",
        // "ja": "",
        // "pt": ""
        // "ru": "",
        // "tr": "",
        // "zh": ""
      }
    
  2. The languages are:
    1. ES: Spanish (Español)
    2. KO: Korean (한국어)
    3. DE: German (Deutsch)
    4. FR: French (Français)
    5. HU: Hungarian (Magyar)
    6. IT: Italian (Italiano)
    7. JA: Japanese (日本語)
    8. PT: Portuguese (Português)
    9. RU: Russian (русский)
    10. TR: Turkish (Türkçe)
    11. ZH: Chinese
  3. You can use hyphenated codes to distinguish between different dialects: for example, pt-BR refers to Brazilian Portuguese and zh-CN refers to Simplified Chinese.
  4. Remove the // for any languages you want to add and put the name and description inside the quotes. For example, here is a JA item that adds a Japanese translation:
    "NameLocalization": {
        // "es": "",
        // "ko": "",
        // "de": "",
        // "fr": "",
        // "hu": "",
        // "it": "",
         "ja": "スズキ",
        // "pt": ""
        // "ru": "",
        // "tr": "",
        // "zh": ""
      },
      "DescriptionLocalization": {
        // "es": "",
        // "ko": "",
        // "de": "",
        // "fr": "",
        // "hu": "",
        // "it": "",
         "ja": "スズキを 釣り上げた! 鈴木…じゃなくて、鱸なのね!",
        // "pt": ""
        // "ru": "",
        // "tr": "",
        // "zh": ""
      }
    
  5. Save crop.json and take a break! You're done with the code for your crop! Now it's just time to finish off the art.

Illustrating Your Seeds[edit | edit source | hide]

Illustrating your seeds is just like illustrating your object. You need a 16x16 transparent png, and can either draw your own seeds or copy from good old springobjects.png. Name your png "seeds.png" and save it in the same folder as crop.json when you're done.

Illustrating Your Crop[edit | edit source | hide]

It's the final step! Now we're going to illustrate our crop, and here is where I particularly recommend copying from the original files or, better yet, copying from both the original files and someone else's crop mod to get the placement right.

  1. A template for making your crop. Use it to make sure your crops are properly centered.
    Make a new 128x32 pixel transparent png.
  2. Assuming you unpacked the game data, open up Stardew Valley\Content (unpacked)\TileSheets\crops.png.
  3. Carefully copy the parsnip crop pictures into your new png.
    1. Each stage occupies a space that is 16 pixels wide and 32 pixels high.
    2. The first two 16x32 spaces are both the first seed/"just planted" stage, so count them as one stage together.
      1. The reason there are two is to make it look more "natural" when the seeds are planted by having more variety.
      2. You'll also notice when your crops are growing that they may be mirrored and/or moved up or down a pixel or two. Again, this is to keep everything from looking too regimented and perfect.
        crop.json, crop.png, and seeds.png in the Purple Parsnip folder in our Crops folder, all ready to grow.
    3. Since our parsnips have just four stages and do not regrow, we will have empty space in the last 32 pixels.
  4. Recolor the growing parsnip to look however you like.
  5. When you're done, save your 128x32 transparent png as "crop.png"
  6. That's it! Assuming you formatted everything correctly, your crop mod is ready for a spin! Load up Smapi, stop by Pierre's, and buy some lovely Purple Parsnip Seeds to plant. :)

What's Next?[edit | edit source | hide]

Now that you've made one crop, why not make more? Try out one with a regrowth stage, or create a crop that grows a useful item like bait (maybe a venus flytrap?). You can even get really creative with additional frameworks like Multi-Yield Crops. Just make sure to have fun. :)

PS: Interesting in writing a tutorial for this wiki? We'd love to have you! No qualifications are needed. Just create a new page, call it "Tutorial: Doing a Thing" (name as appropriate), and start sharing your knowledge. :)