Difference between revisions of "Modding:Items"

From Stardew Valley Wiki
Jump to navigation Jump to search
(add custom items introduction, move categories into generic intro)
(→‎Categories: replace outdated export with a console command to export it anytime)
Line 205: Line 205:
 
|}
 
|}
  
Here's a dump of the vanilla items for each category as of {{version|1.4.3}}:
+
{{collapse|Console commands|content=
{{collapse|Items with numeric categories|content=<syntaxhighlight lang="yaml">
+
With the {{nexus mod|3101|Console Code}} mod installed, you can run this command in the SMAPI console to see a list of objects by category:
-81: Cave Carrot, Chanterelle, Common Mushroom, Daffodil, Dandelion, Hazelnut, Holly, Leek, Morel, Purple Mushroom, Red Mushroom, Sap, Snow Yam, Spring Onion, Wild Horseradish, Winter Root
+
 
-80: Blue Jazz, Crocus, Fairy Rose, Poppy, Summer Spangle, Sunflower, Sweet Pea, Tulip
+
<pre>cs return string.Join(`\n`, Game1.objectInformation.Keys.Select(key => new StardewValley.Object(key, 1)).GroupBy(item => item.Category, item => item.Name).OrderByDescending(p => p.Key).Select(p => $`{p.Key}: {string.Join(`, `, p.OrderBy(name => name))}`));</pre>
-79: Ancient Fruit, Apple, Apricot, Blackberry, Blueberry, Cactus Fruit, Cherry, Coconut, Cranberries, Crystal Fruit, Grape, Hot Pepper, Melon, Orange, Peach, Pomegranate, Rhubarb, Salmonberry, Spice Berry, Starfruit, Strawberry, Wild Plum
+
}}
-75: Amaranth, Artichoke, Beet, Bok Choy, Cauliflower, Corn, Eggplant, Fiddlehead Fern, Garlic, Green Bean, Hops, Kale, Parsnip, Potato, Pumpkin, Radish, Red Cabbage, Tea Leaves, Tomato, Unmilled Rice, Wheat, Yam
 
-74: Acorn, Amaranth Seeds, Ancient Seeds, Apple Sapling, Apricot Sapling, Artichoke Seeds, Bean Starter, Beet Seeds, Blueberry Seeds, Bok Choy Seeds, Cactus Seeds, Cauliflower Seeds, Cherry Sapling, Coffee Bean, Corn Seeds, Cranberry Seeds, Eggplant Seeds, Fairy Seeds, Fall Seeds, Garlic Seeds, Grape Starter, Hops Starter, Jazz Seeds, Kale Seeds, Maple Seed, Melon Seeds, Mixed Seeds, Orange Sapling, Parsnip Seeds, Peach Sapling, Pepper Seeds, Pine Cone, Pomegranate Sapling, Poppy Seeds, Potato Seeds, Pumpkin Seeds, Radish Seeds, Rare Seed, Red Cabbage Seeds, Rhubarb Seeds, Rice Shoot, Spangle Seeds, Spring Seeds, Starfruit Seeds, Strawberry Seeds, Summer Seeds, Sunflower Seeds, Tea Sapling, Tomato Seeds, Tulip Bulb, Wheat Seeds, Winter Seeds, Yam Seeds
 
-28: Bat Wing, Bug Meat, Slime, Solar Essence, Void Essence
 
-27: Maple Syrup, Oak Resin, Pine Tar
 
-26: Aged Roe, Beer, Caviar, Cheese, Cloth, Dinosaur Mayonnaise, Duck Mayonnaise, Goat Cheese, Green Tea, Honey, Jelly, Juice, Mayonnaise, Mead, Pale Ale, Pickles, Truffle Oil, Void Mayonnaise, Wine
 
-24: Brick Floor, Cobblestone Path, Crystal Floor, Crystal Path, Gravel Path, Stepping Stone Path, Stone Floor, Straw Floor, Tea Set, Weathered Floor, Wood Floor, Wood Path
 
-23: Clam, Coral, Nautilus Shell, Rainbow Shell, Roe, Sea Urchin, Squid Ink
 
-22: Barbed Hook, Cork Bobber, Dressed Spinner, Lead Bobber, Spinner, Trap Bobber, Treasure Hunter
 
-21: Bait, Magnet, Wild Bait
 
-20: Broken CD, Broken Glasses, Driftwood, Joja Cola, Rotten Plant, Rotten Plant, Soggy Newspaper, Trash
 
-19: Basic Fertilizer, Basic Retaining Soil, Deluxe Speed-Gro, Quality Fertilizer, Quality Retaining Soil, Speed-Gro, Tree Fertilizer
 
-18: Duck Feather, Rabbit's Foot, Wool
 
-17: Sweet Gem Berry, Truffle
 
-16: Battery Pack, Clay, Fiber, Hardwood, Stone, Wood
 
-15: Coal, Copper Bar, Copper Ore, Gold Bar, Gold Ore, Iridium Bar, Iridium Ore, Iron Bar, Iron Ore, Refined Quartz
 
-12: Aerinite, Alamite, Baryte, Basalt, Bixite, Calcite, Celestine, Dolomite, Esperite, Fairy Stone, Fire Opal, Fluorapatite, Geminite, Ghost Crystal, Granite, Helvite, Hematite, Jagoite, Jamborite, Jasper, Kyanite, Lemon Stone, Limestone, Lunarite, Malachite, Marble, Mudstone, Nekoite, Neptunite, Obsidian, Ocean Stone, Opal, Orpiment, Petrified Slime, Pyrite, Sandstone, Slate, Soapstone, Star Shards, Thunder Egg, Tigerseye
 
-8: Bomb, Cherry Bomb, Dwarvish Translation Guide, Gate, Hardwood Fence, Iridium Sprinkler, Iron Fence, Jack-O-Lantern, Mega Bomb, Quality Sprinkler, Sprinkler, Stone Fence, Wood Fence
 
-7: Algae Soup, Artichoke Dip, Autumn's Bounty, Baked Fish, Bean Hotpot, Blackberry Cobbler, Blueberry Tart, Bread, Bruschetta, Carp Surprise, Cheese Cauliflower, Chocolate Cake, Chowder, Coleslaw, Complete Breakfast, Cookie, Crab Cakes, Cranberry Candy, Cranberry Sauce, Crispy Bass, Dish O' The Sea, Eggplant Parmesan, Escargot, Farmer's Lunch, Fiddlehead Risotto, Fish Stew, Fish Taco, Fried Calamari, Fried Eel, Fried Egg, Fried Mushroom, Fruit Salad, Glazed Yams, Hashbrowns, Ice Cream, Life Elixir, Lobster Bisque, Lucky Lunch, Magic Rock Candy, Maki Roll, Maple Bar, Miner's Treat, Oil of Garlic, Omelet, Pale Broth, Pancakes, Parsnip Soup, Pepper Poppers, Pink Cake, Pizza, Plum Pudding, Poppyseed Muffin, Pumpkin Pie, Pumpkin Soup, Radish Salad, Red Plate, Rhubarb Pie, Rice Pudding, Roasted Hazelnuts, Roots Platter, Salad, Salmon Dinner, Sashimi, Seafoam Pudding, Shrimp Cocktail, Spaghetti, Spicy Eel, Stir Fry, Strange Bun, Stuffing, Super Meal, Survival Burger, Tom Kha Soup, Tortilla, Triple Shot Espresso, Trout Soup, Vegetable Medley
 
-6: Goat Milk, L. Goat Milk, Large Milk, Milk
 
-5: Duck Egg, Egg, Egg, Large Egg, Large Egg, Void Egg
 
-4: Albacore, Anchovy, Angler, Blobfish, Bream, Bullhead, Carp, Catfish, Chub, Cockle, Crab, Crayfish, Crimsonfish, Dorado, Eel, Flounder, Ghostfish, Glacierfish, Halibut, Herring, Ice Pip, Largemouth Bass, Lava Eel, Legend, Lingcod, Lobster, Midnight Carp, Midnight Squid, Mussel, Mutant Carp, Octopus, Oyster, Perch, Periwinkle, Pike, Pufferfish, Rainbow Trout, Red Mullet, Red Snapper, Salmon, Sandfish, Sardine, Scorpion Carp, Sea Cucumber, Shad, Shrimp, Slimejack, Smallmouth Bass, Snail, Spook Fish, Squid, Stonefish, Sturgeon, Sunfish, Super Cucumber, Tiger Trout, Tilapia, Tuna, Void Salmon, Walleye, Woodskip
 
-2: Amethyst, Aquamarine, Diamond, Earth Crystal, Emerald, Fire Quartz, Frozen Tear, Jade, Prismatic Shard, Quartz, Ruby, Topaz
 
</syntaxhighlight>}}
 
  
 
===Define a custom item===
 
===Define a custom item===

Revision as of 01:24, 28 January 2022

Index

This page explains how the game stores and parses item data. This is an advanced guide for mod developers.

Introduction

Overview

Items are divided into several types:

item type data asset texture name summary
Object Data/ObjectInformation Maps/springobjects The default type for items in inventories or placed in the world.
Object (big craftable) Data/BigCraftablesInformation TileSheets/Craftables Craftable items which can be placed in the world and are two tiles tall (instead of one like objects).
Boots Data/Boots item sprite: Maps/springobjects
shoe color: Characters/Farmer/shoeColors
Equippable boots.
Clothing Data/ClothingInformation Characters/Farmer/pants
Characters/Farmer/shirts
Equippable pants and shirts.
Furniture Data/Furniture TileSheets/furniture Decorative furniture items, including chairs which the player can sit on.
Hat Data/Hats Characters/Farmer/hats Equippable hat items.
Tool TileSheets/Tools Tools that can be used by the player.
MeleeWeapon Data/Weapons TileSheets/weapons Weapons that can be used by the player to damage monsters.

The game has two files in its Content folder (which can be unpacked for editing) for each item type:

  • a data asset for the text data for its items (names, descriptions, prices, etc);
  • and a spritesheet for the in-game item icons.

Each item has a ParentSheetIndex field which is its position in the item type's spritesheet, starting at 0 in the top-left and incrementing by one as you move across and then down. For example, hat #0 is the first sprite in Characters/Farmer/hats. The ParentSheetIndex is also used to identify the item itself; since spritesheet indexes aren't unique (e.g. there's both a hat #10 and object #10), code needs to check the type too like item is Weapon weapon && weapon.ParentSheetIndex == 4.

See the sections below for details on each item type.

Categories

Each item also has a category (represented by a negative integer). In code, you can get an item's category value from item.Category, and its translated name from item.getCategoryName(). Here are the valid categories:

value internal constant English translation
-2 Object.GemCategory Mineral
-4 Object.FishCategory Fish
-5 Object.EggCategory Animal Product
-6 Object.MilkCategory Animal Product
-7 Object.CookingCategory Cooking
-8 Object.CraftingCategory Crafting
-9 Object.BigCraftableCategory
-12 Object.mineralsCategory Mineral
-14 Object.meatCategory Animal Product
-15 Object.metalResources Resource
-16 Object.buildingResources Resource
-17 Object.sellAtPierres
-18 Object.sellAtPierresAndMarnies Animal Product
-19 Object.fertilizerCategory Fertilizer
-20 Object.junkCategory Trash
-21 Object.baitCategory Bait
-22 Object.tackleCategory Fishing Tackle
-23 sellAtFishShopCategory
-24 Object.furnitureCategory Decor
-25 Object.ingredientsCategory Cooking
-26 Object.artisanGoodsCategory Artisan Goods
-27 Object.syrupCategory Artisan Goods
-28 Object.monsterLootCategory Monster Loot
-29 Object.equipmentCategory
-74 Object.SeedsCategory Seed
-75 Object.VegetableCategory Vegetable
-79 Object.FruitsCategory Fruit
-80 Object.flowersCategory Flower
-81 Object.GreensCategory Forage
-95 Object.hatCategory
-96 Object.ringCategory
-98 Object.weaponCategory
-99 Object.toolCategory
Console commands 
With the Console Code mod installed, you can run this command in the SMAPI console to see a list of objects by category:
cs return string.Join(`\n`, Game1.objectInformation.Keys.Select(key => new StardewValley.Object(key, 1)).GroupBy(item => item.Category, item => item.Name).OrderByDescending(p => p.Key).Select(p => $`{p.Key}: {string.Join(`, `, p.OrderBy(name => name))}`));

Define a custom item

Every item must be assigned a unique ParentSheetIndex within its type, and that index must fit within the item type's spritesheet.

Adding custom items to the data assets and spritesheets directly is not recommended, since it's very easy to conflict with other mods or cause game errors. Instead you should create a content pack for Json Assets, which coordinates dynamic item ID assignment so multiple custom item mods can work together.

Objects

Objects are the default type for items in inventories or placed in the world.

They have their data in Data/ObjectInformation, their icon sprites in Maps/springobjects, and their code in StardewValley.Object. See a table of sprites and their corresponding indexes.

Data format

The object data in Data/ObjectInformation consists of an integer→string dictionary with entries like this:

  "18": "Daffodil/30/0/Basic -81/Daffodil/A traditional spring flower that makes a nice gift."

For each entry in the data asset, the key is the item's ParentSheetIndex and the value is a slash-delimited string with the fields listed below. Fields 0–5 are used by rings and most other objects; fields 6–11 are only used for food buffs. The objects with keys 516–534 (Ring.ringLowerIndexRange through Ring.ringUpperIndexRange) and 801 (wedding ring) are hardcoded as rings.

index field effect
all objects
0 name The internal item name (and display name in English).
1 price The gold price of the item when sold by the player.
2 edibility A numeric value that determines how much health (edibility × 2.5) and energy (edibility × 1.125) is restored. An item with an edibility of -300 can't be eaten.

This is ignored for rings.

3 type and category
  • For a ring: the value Ring. Rings have a hardcoded category of -96 (Object.ringCategory).
  • For other objects: the item's type (string) and category (negative integer), separated by a space like Fish -4.
4 display name The translated item name.
5 description The translated item description.
food & drink only
6 miscellaneous
  • For a food or drink item, set this to food or drink respectively. This enables the remaining fields, and changes which animation/sound is played when the player consumes the item. Any other value is ignored.
  • For a geode item (535, 536, 537, or 749) is broken, a space-delimited list of object IDs. There's a roughly 50% chance that the geode item will drop one of these items (the other drops are hardcoded).
7 buffs The bonuses to apply to the player's attribute when the item is consumed. This consists of a space-delimited list of these numbers:
index buff
0 farming
1 fishing
2 mining
3 unused
4 luck
5 foraging
6 unused
7 max energy
8 magnetism
9 speed
10 defense
11 attack
8 buff duration How long the buffs provided by the previous field last. This is converted into in-game minutes using the formula (duration × 0.7) / 60. The buff duration number shown in-game will always be one second less than the calculated value.

Notes

  • Items that have a number in the "Crafting" field show buggy information in-game (e.g., Bean Hotpot prior to version 1.4). Items that have a number in the "Attack" field display the Attack icon and a number, but no description. It's unclear how these buffs work (if at all).
  • Named buffs (like Oil of Garlic, Life Elixir, or Tipsy) are implemented in code and can't be set in the food buff fields.
  • The spritesheet and data have items that can't normally be found in the player inventory (like twigs and lumber), and some sprites have no corresponding item data. There are also multiple entries for weeds and stone corresponding to different sprites, but the player can only normally obtain one stone item (index 390) and no weeds items.