Modding:Items

From Stardew Valley Wiki
Revision as of 03:09, 28 January 2022 by Pathoschild (talk | contribs) (merge Modding:Weapon data into page as-is (main content author: Pathoschild, initial melee weapon field list by Minervamaga, improved melee weapon field descriptions by SentryTV, raw data updated by Metalax))
Jump to navigation Jump to search

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))}`));

Get a list of items

With SMAPI installed, you can run the list_items console command in-game to view/search items and their IDs.

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.

Objects (big craftables)

Big craftables are objects which can be placed in the world and are two tiles tall (instead of one like objects).

They have their data in Data/BigCraftableInformation, their in-game sprites in TileSheets/Craftables, and their code in StardewValley.Object (with the bigCraftable.Value = true flag).

Data format

The big craftables data in Data/BigCraftableInformation consists of an integer→string dictionary with entries like this:

  "19": "Oil Maker/50/-300/Crafting -9/Makes gourmet truffle oil./true/true/0/Oil Maker"

For each entry in the data asset, the key is the item's ParentSheetIndex and the value is a slash-delimited string with these fields:

index field effect
0 name The internal item name (and display name in English).
1 price The gold price when sold by the player.
2 edibility See edibility for object data. Always set to -300 (inedible) for vanilla items.
3 type and category See type and category for object data. Always set to Crafting -9 for vanilla items.
4 description The translated item description shown in-game.
5 outdoors Whether the item can be placed outdoors (true or false).
6 indoors Whether the item can be placed indoors (true or false).
7 fragility How the item is removed by tools. Possible values:
fragility effect
0 Pick up with any tool.
1 Destroyed if hit with an axe, hoe, or pickaxe. Any other tool will pick it up.
2 Indestructible. The item can't be removed once placed.
8 is lamp Whether the item is a lamp and produces light when it's dark. This can be true (mark as lamp) or any other value (ignored).
9 display name The translated display name (in non-English assets only).

Notes

  • Many of the items in the data asset aren't implemented in-game. They may be completely absent from the game, or they may be unused as craftables and instead appear in object data or furniture data.

Furniture

Furniture are decorative items which can be placed in the world, including chairs which the player can sit on.

They have their data in Data/Furniture, their in-game sprites in TileSheets/furniture, and their code in StardewValley.Objects.Furniture.

Data format

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

  "18": "Country Chair/chair/-1/-1/4/750"

For each entry in the data asset, the key is the item's ParentSheetIndex and the value is a slash-delimited string with these fields:

index field effect
0 name The internal item name (and display name in English).
1 type The furniture type. Possible values:
type meaning
0 chair
1 bench
2 couch
3 armchair
4 dresser
5 long table
6 painting
7 lamp
8 decor
9 other
10 bookcase
11 table
12 rug
13 window
14 fireplace
15 bed
16 torch
17 sconce
2 tilesheet size The furniture sprite size on the tilesheet, measured in tiles. This can be <width> <height> (e.g. 1 2), or -1 to use the default size for the type.
3 bounding box size The size of the hitbox when the furniture is placed in-game, measured in tiles. The bounding box will be anchored to the bottom-left corner and extend upwards and rightwards. This can be <width> <height> (e.g. 1 2), or -1 to use the default size for the type.
4 rotations The number of rotations possible (1, 2, or 4).
5 price The price when purchased from a shop.
6 display name The translated furniture name (in non-English data assets only).

Hats

Hats are items that can be equipped in the player's hat slot.

They have their data in Data/Hats, their in-game sprites in Characters/Farmer/hats, and their code in StardewValley.Objects.Hat.

Data format

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

  "5": "Official Cap/Looks like it belonged to a postman or policeman. Either way, it's still very soft and smells okay./false/true"

For each entry in the data asset, the key is the item's ParentSheetIndex and the value is a slash-delimited string with these fields:

index field effect
0 name The internal item name (and display name in English).
1 description The translated item description shown in-game.
2 show real hair Whether to show the player's hairstyle as-is when the hat is worn (true), or change the hairstyle to fit the hat (false).
3 skip hairstyle offset Whether to ignore the current style when positioning the hat (one of true or false). For example, the eye patch sets true since its position isn't affected by the hair, but the butterfly bow sets false to adjust its position on top of your hair.
4 display name The translated item name shown in-game (for non-English assets only).

Hats have a hard-coded category of -95 (Hats.cs::Load)

Weapons

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

Raw data

Weapon sprites are in TileSheets\Weapons.xnb, and weapon data (parsed by the MeleeWeapon constructor) is in Data\Weapons.xnb. The files can be unpacked for editing. Here's the raw data as of 1.5.1 for reference:

Data 
{
  "0": "Rusty Sword/A rusty, dull old sword./2/5/1/0/0/0/3/-1/-1/0/.02/3",
  "1": "Silver Saber/Plated with silver to deter rust./8/15/1/0/1/1/0/50/45/0/.02/3",
  "2": "Dark Sword/It's glowing with vampire energy./30/45/1.5/-10/0/0/0/-1/-1/2/.04/3",
  "3": "Holy Blade/It feels hopeful to wield./18/24/1.2/0/5/0/3/-1/-1/0/.02/3",
  "4": "Galaxy Sword/It's unlike anything you've ever seen./60/80/1/8/0/0/0/-1/-1/0/.02/3",
  "5": "Bone Sword/A very light piece of sharpened bone./20/30/.8/8/5/0/0/74/50/0/.02/3",
  "6": "Iron Edge/A heavy broadsword./12/25/1.2/-4/0/1/3/44/-1/0/.02/3",
  "7": "Templar's Blade/It once belonged to an honorable knight./22/29/1/0/10/1/3/90/50/0/0/3",
  "8": "Obsidian Edge/It's incredibly sharp./30/45/1/-2/0/0/0/121/100/0/.02/3.2",
  "9": "Lava Katana/A powerful blade forged in a pool of churning lava./55/64/1.2/0/0/3/0/-1/-1/2/.015/3.5",
  "10": "Claymore/It's really heavy./20/32/1.3/-8/0/2/3/86/50/0/.02/3",
  "11": "Steel Smallsword/A standard metal blade./4/8/1/4/0/0/0/26/-1/0/.02/3",
  "12": "Wooden Blade/Not bad for a piece of carved wood./3/7/1/0/0/0/0/3/-1/0/.02/3",
  "13": "Insect Head/Not very pleasant to wield./10/20/1/4/9/0/0/-1/-1/0/.04/3",
  "14": "Neptune's Glaive/An heirloom from beyond the Gem Sea./18/35/1.4/-2/6/2/3/-1/-1/0/.02/3",
  "15": "Forest Sword/Made powerful by forest magic./8/18/1/4/5/1/0/-1/-1/0/.02/3",
  "16": "Carving Knife/A small, light blade./1/3/.5/0/0/0/1/18/-1/0/.04/3",
  "17": "Iron Dirk/A common dagger./2/4/.5/0/0/0/1/62/50/0/.03/3",
  "18": "Burglar's Shank/A weapon of choice for the swift and silent./7/12/.5/0/5/0/1/114/100/0/.04/3.5",
  "19": "Shadow Dagger/When you hold the blade to your ear you can hear 1,000 souls shrieking./10/20/.5/0/0/0/1/80/50/0/.04/3",
  "20": "Elf Blade/Only the nimble hands of an elf could craft this./3/5/.5/0/5/0/1/-1/-1/0/.04/3",
  "21": "Crystal Dagger/The blade is made of purified quartz./4/10/1/0/10/0/1/-1/-1/0/.03/4",
  "22": "Wind Spire/A swift little blade./1/5/1/0/0/0/1/-1/-1/0/.02/3.2",
  "23": "Galaxy Dagger/It's unlike anything you've seen./30/40/1/3/0/0/1/-1/-1/0/.02/3",
  "24": "Wood Club/A solid piece of wood, crudely chiseled into a club shape./9/16/1.5/-8/0/0/2/32/-1/0/.02/3",
  "25": "Alex's Bat/The sweet spot is dented from Alex's famous Grand Slam./1/3/1/-8/0/0/2/-1/-1/0/.02/3",
  "26": "Lead Rod/It's incredibly heavy./18/27/1.5/-16/0/0/2/56/50/1/.02/3",
  "27": "Wood Mallet/The solid head packs a punch. Relatively light for a club./15/24/1.3/-4/1/0/2/68/50/0/.02/3",
  "28": "The Slammer/An extremely heavy gavel that'll send foes flying./40/55/1.5/-12/0/0/2/128/100/2/.02/3",
  "29": "Galaxy Hammer/It's made from an ultra-light material you've never seen before./70/90/1/-4/0/0/2/-1/-1/0/.02/3",
  "30": "Sam's Old Guitar/It's seen better days./1/3/1/-6/0/0/2/-1/-1/0/.02/3",
  "31": "Femur/An old, heavy bone caked in centuries of grime./6/11/1.5/-4/0/0/2/10/-1/0/.02/3",
  "32": "Slingshot/Requires stones for ammo./1/3/1/308/0/0/4/-1/-1/0/.02/3",
  "33": "Master Slingshot/Requires stones for ammo./1/3/1/308/0/0/4/-1/-1/0/.02/3",
  "34": "Galaxy Slingshot/It looks really powerful./1/3/1/308/0/0/4/-1/-1/0/.02/3",
  "35": "Elliott's Pencil/Elliott used this to write his book. It's sharp!/1/3/1/308/0/0/1/-1/-1/0/.02/3",
  "36": "Maru's Wrench/A big, metal wrench. It smells like Maru./1/3/1/308/0/0/2/-1/-1/0/.02/3",
  "37": "Harvey's Mallet/It brings back memories of Harvey's clinic./1/3/1/308/0/0/2/-1/-1/0/.02/3",
  "38": "Penny's Fryer/Penny's favorite frying pan. There's some rubbery gunk stuck to the inside./1/3/1/308/0/0/2/-1/-1/0/.02/3",
  "39": "Leah's Whittler/Leah's favorite tool for shaping driftwood./1/3/1/308/0/0/1/-1/-1/0/.02/3",
  "40": "Abby's Planchette/It's made from fine marblewood./1/3/1/308/0/0/1/-1/-1/0/.02/3",
  "41": "Seb's Lost Mace/One of Sebastian's medieval replicas./1/3/1/308/0/0/2/-1/-1/0/.02/3",
  "42": "Haley's Iron/It's searing hot and smells like Haley's hair./1/3/1/308/0/0/0/-1/-1/0/.02/3",
  "43": "Pirate's Sword/It looks like a pirate owned this once./8/14/1/4/0/0/3/40/-1/0/.02/3",
  "44": "Cutlass/A finely crafted blade./9/17/1/4/0/0/0/-1/-1/0/.02/3",
  "45": "Wicked Kris/The blade is made of an iridium alloy./24/30/.5/0/8/0/1/-1/-1/2/.06/3",
  "46": "Kudgel/A brute's companion./27/40/1.6/-10/0/0/2/107/100/0/.02/3.1",
  "47": "Scythe/It can cut grass into hay, if you've built a silo./1/3/1/0/0/0/0/-1/-1/0/.02/3",
  "48": "Yeti Tooth/It's icy cold to the touch./26/42/1/0/0/4/0/-1/-1/0/.02/3.2",
  "49": "Rapier/An elegant blade./15/25/1/4/0/0/0/100/95/2/.02/3",
  "50": "Steel Falchion/Light and powerful./28/46/1/8/5/0/0/142/100/0/.02/3.4",
  "51": "Broken Trident/It came from the sea, but it's still sharp./15/26/.5/0/8/0/1/-1/-1/2/.02/3",
  "52": "Tempered Broadsword/It looks like it could withstand anything./29/44/1.2/-6/0/3/0/135/100/1/.02/3",
  "53": "Golden Scythe/It's more powerful than a normal scythe./13/13/1/0/0/0/0/-1/-1/2/.02/4",
  "54": "Dwarf Sword/It's ancient, but the blade never dulls./65/75/1/4/0/4/0/-1/-1/0/.02/3",
  "55": "Dwarf Hammer/It emits a very faint whirring sound./75/85/1/-8/0/2/2/-1/-1/0/.02/3",
  "56": "Dwarf Dagger/It's ancient, but the blade never dulls./32/38/1/3/0/6/1/-1/-1/0/.03/3",
  "57": "Dragontooth Cutlass/The blade was forged from a magical tooth./75/90/1/0/0/0/0/-1/-1/0/.02/4",
  "58": "Dragontooth Club/This club was crafted from a magical tooth./80/100/1.3/-8/0/0/2/-1/-1/0/.02/4",
  "59": "Dragontooth Shiv/The blade was forged from a magical tooth./40/50/1/0/0/0/1/-1/-1/0/.05/5",
  "60": "Ossified Blade/A large, sharp blade formed from bone./26/42/1.1/-4/0/1/0/142/100/0/.02/3",
  "61": "Iridium Needle/The point is unbelievably sharp, even down to the atomic level./20/35/.5/0/0/0/1/-1/-1/0/.1/7",
  "62": "Infinity Blade/The true form of the Galaxy Sword./80/100/1/8/0/2/0/-1/-1/0/.02/3",
  "63": "Infinity Gavel/The true form of the Galaxy Hammer./100/120/1/-4/0/1/2/-1/-1/0/.02/3",
  "64": "Infinity Dagger/The true form of the Galaxy Dagger./50/70/1/3/0/3/1/-1/-1/0/.06/3"
}

Format

Melee weapons

The weapon data in Data\Weapons.xnb contains fifteen fields for melee weapons: 308/0/0/4/-1/-1/0/.02/3

index example value description
0 Bone Sword name
1 A very light piece of sharpened bone. description
2 20 minimum damage ouput
3 30 maximum damage output
4 .8 knockback (weight) - determines how far the target will get pushed away when hit
5 8 speed - determines how fast the user can attack
6 5 added precision - decreases the chance that a strike will cause no damage
7 0 added defense - affects how much damage the user takes
8 0 type ("0" for stabbing sword, "1" for dagger, "2" for club/hammer, "3" for slashing sword, "4" for slingshot)
9 74 The base mine level which affects the probability of mine container drops.
10 50 The minimum mine level for mine container drops.
11 0 added area of effect
12 .02 critical chance
13 3 critical multiplier
14 display name (non-English files only)

Weapons have a hardcoded category of -98 (Object.weaponCategory).

Slingshot

The slingshot has initial ID 32 in the weapon data, which increases by one for each upgrade level (up to 34 in the weapon data, though only 32 and 33 are obtainable without mods). All weapon fields must be specified in the weapon data to avoid errors, but only these are actually used for slingshots:

index example value description
0 Master Slingshot name
1 Requires stones for ammo. description
9 74 The base mine level which affects the probability of mine container drops.
10 50 The minimum mine level for mine container drops.
14 display name (non-English files only)

Slingshot damage is calculated dynamically regardless of the weapon data.

Mine container drops

When the player breaks a container in the mines, there's a chance it will drop a weapon. Here's how the weapon to drop is chosen[1]:

  1. Match weapons whose minimum mine level (field 10) is less than the current mine level.
  2. From that list, match weapons with a probability check based on the gap between the base mine level (field 9) and current mine level. The probability is a bell curve centered on the base mine level:
    level difference probability
    0 100%
    5 92%
    10 71%
    15 46%
    20 25%
    25 4%
    The difference applies in both directions; for example, two weapons whose base levels are 5 below and 5 above the current level both have a 92% chance. (The probability is calculated with a Gaussian function e-(current mine level - base mine level)2 / (2 * 122).)
  3. Find the weapon with the smallest gap between the current and base mine levels, and add it to the list. (If the item was also selected in step 2, it has two chances to drop.)
  4. From the remaining list of weapons, randomly choose one to drop.

References

  1. See Utility.getUncommonItemForThisMineLevel in the game code.

See also