Jump to content

Modding:Hats: Difference between revisions

From Stardew Valley Wiki
imported>Pathoschild
m Pathoschild moved page Modding:Hat data to Modding:Hats: update for newer naming convention & prepare to unsplit page
imported>Pathoschild
Line 1: Line 1:
#REDIRECT [[Modding:Items]]
← [[Modding:Items|Items]]
 
==Hats==
Hats are items that can be equipped in the player's [[hats|hat]] slot.
 
They have their data in <samp>Data/Hats</samp>, their in-game sprites in <samp>Characters/Farmer/hats</samp>, and their code in <samp>StardewValley.Objects.Hat</samp>.
 
===Data format===
The hat data in <samp>Data/Hats</samp> consists of an integer→string dictionary with entries like this:
 
<syntaxhighlight lang="json">
  "5": "Official Cap/Looks like it belonged to a postman or policeman. Either way, it's still very soft and smells okay./false/true"
</syntaxhighlight>
 
Hats from the base game use the hat's <samp>ParentSheetIndex</samp> as its item ID.
For each entry in the data asset, the key is the hat's item ID, and the value is a slash-delimited string with these fields:
 
{| class="wikitable"
|-
! index
! field
! effect
|-
| 0
| name
| The internal item name.
|-
| 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 (<samp>true</samp>), change the hairstyle to fit the hat (<samp>false</samp>), or hide their hair completely (<samp>hide</samp>).
|-
| 3
| skip hairstyle offset
| Whether to ignore the current style when positioning the hat (one of <samp>true</samp> or <samp>false</samp>). For example, the [[Eye Patch|eye patch]] sets <samp>true</samp> since its position isn't affected by the hair, but the [[Butterfly Bow|butterfly bow]] sets <samp>false</samp> to adjust its position on top of your hair.
|-
| 4
| tags
| A space-separated list of "tags". These are separate from context tags, and used to contain miscellaneous information. Currently, the only tag used by the game is <samp>Prismatic</samp>, which marks a hat as prismatic and causes it to cycle through colors.
|-
| 5
| display name
| The translated item name shown in-game.
|-
| 6
| sprite index
| The index in the hat spritesheet used to display this hat (see field 7 for the texture layout).
|-
| 7
| texture name
| The name of the game texture to use for the hat. If empty, the game will use the default hat sheet <samp>Characters/Farmer/hats</samp>.
 
Each hat in the texture should have a 20x80 pixel area, consisting of four 20x20 hat sprites from top to bottom: facing down, right, left, and up. The texture can have any width and height that's evenly divisible by 20 and 80 respectively.
|}
 
Hats have a hard-coded category of -95 (<samp>HatDataDefinition.cs::GetData</samp>)
 
[[Category:Modding]]

Revision as of 17:23, 15 December 2024

← Items

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"

Hats from the base game use the hat's ParentSheetIndex as its item ID. For each entry in the data asset, the key is the hat's item ID, and the value is a slash-delimited string with these fields:

index field effect
0 name The internal item name.
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), change the hairstyle to fit the hat (false), or hide their hair completely (hide).
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 tags A space-separated list of "tags". These are separate from context tags, and used to contain miscellaneous information. Currently, the only tag used by the game is Prismatic, which marks a hat as prismatic and causes it to cycle through colors.
5 display name The translated item name shown in-game.
6 sprite index The index in the hat spritesheet used to display this hat (see field 7 for the texture layout).
7 texture name The name of the game texture to use for the hat. If empty, the game will use the default hat sheet Characters/Farmer/hats.

Each hat in the texture should have a 20x80 pixel area, consisting of four 20x20 hat sprites from top to bottom: facing down, right, left, and up. The texture can have any width and height that's evenly divisible by 20 and 80 respectively.

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