Jump to content

Modding:Hats: Difference between revisions

From Stardew Valley Wiki
imported>Margotbean
create page with raw data
 
imported>VulpesLucida
m zh link
 
(21 intermediate revisions by 7 users not shown)
Line 1: Line 1:
← [[Modding:Index|Index]]
← [[Modding:Items|Items]]


This page explains how the game stores and parses object data. This is an advanced guide for mod developers.
This page explains how the game stores and parses hat-type item data. For items in general, see [[Modding:Items]].


==Raw data==
==Overview==
Objects are stored in <tt>Content\Data\Hats.xnb</tt>, which can be [[Modding:Creating an XNB mod#unpacking|unpacked using XNB Extract]]. Here's the raw data (as of v1.2) for reference:
Hats are items that can be equipped in the player's [[hats|hat]] slot. These change the player sprite.


<source lang="yaml">
They have [[Modding:Items#Item types|item type]] <code>(H)</code> (or <code>ItemRegistry.type_hat</code> in C# code), their data in <samp>Data/Hats</samp>, their in-game sprites in <samp>Characters/Farmer/hats</samp> by default, and their code in <samp>StardewValley.Objects.Hat</samp>.
    0: "Cowboy Hat/The leather is old and cracked, but surprisingly supple. It smells musty./false/true" #!String
 
    1: "Bowler Hat/Made from smooth felt./false/true" #!String
==Data format==
    2: "Top Hat/A gentleman's classic./false/true" #!String
The hat data in <samp>Data/Hats</samp> consists of a string → string lookup, where...
    3: "Sombrero/A festively decorated hat made from woven straw./false/true" #!String
* The key is the [[Modding:Common data field types#Item ID|unqualified item ID]].
    4: "Straw Hat/Light and cool, it's a farmer's delight./false/true" #!String
* The value is a slash-delimited strings with the fields listed below.
    5: "Official Cap/Looks like it belonged to a postman or policeman. Either way, it's still very soft and smells okay./false/true" #!String
 
    6: "Blue Bonnet/Harken back to simpler times with this prairie bonnet./false/true" #!String
{| class="wikitable"
    7: "Plum Chapeau/Looks alright./false/true" #!String
|-
    8: "Skeleton Mask/The red eyes are glowing mysteriously./true/true" #!String
! index
    9: "Goblin Mask/Freak out the neighborhood with this creepy mask. Rubber ear joints for effect./true/true" #!String
! field
    10: "Chicken Mask/You'll be sure to get thim grinning with this one./true/true" #!String
! effect
    11: "Earmuffs/Keep your ears toasty. Lined with artisanal velvet from Castle Village./true/false" #!String
|-
    12: "Delicate Bow/Little pink jewels glisten as you examine it./true/false" #!String
| 0
    13: "Tropiclip/It's shaped like a little palm tree./true/false" #!String
| name
    14: "Butterfly Bow/This one is very soft./true/false" #!String
| The internal item name.
    15: "Hunter's Cap/The wool lining should stay warm deep into the forest./false/true" #!String
|-
    16: "Trucker Hat/Mesh in the back to keep your head cool./false/true" #!String
| 1
    17: "Sailor's Cap/It's fresh and starchy./false/true" #!String
| description
    18: "Good Ol' Cap/A floppy old topper with a creased bill. Looks like it's been through a lot./false/true" #!String
| The translated item description shown in-game.
    19: "Fedora/A city-slicker's standard./false/true" #!String
|-
    20: "Cool Cap/It looks really faded, but it used to be a vibrant blue./false/true" #!String
| 2
    21: "Lucky Bow/The middle is made of solid gold./true/false" #!String
| show real hair
    22: "Polka Bow/This one's sure to be turn heads./true/false" #!String
| 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>).
    23: "Gnome's Cap/This gnome had a very large head./false/true" #!String
|-
    24: "Eye Patch/You can't tell if it's real or just from a costume shop./true/true" #!String
| 3
    25: "Santa Hat/Celebrate the magical season./false/true" #!String
| skip hairstyle offset
    26: "Tiara/This one has a big amethyst encircled by gold./true/true" #!String
| 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.
    27: "Hard Hat/Keep your dome in one piece./false/true" #!String
|-
    28: "Sou'wester/The shape helps to keep sailors dry during storms./false/true" #!String
| 4
    29: "Daisy/A fresh spring daisy to put in your hair./true/false" #!String
| tags
    30: "Watermelon Band/The color scheme was inspired by the beloved summer melon./true/false" #!String
| 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.
    31: "Mouse Ears/Made from synthetic fibers./true/true" #!String
|-
    32: "Cat Ears/Whiskers included./true/true" #!String
| 5
    33: "Cowgal Hat/The band is studded with fake diamonds./false/true" #!String
| display name
    34: "Cowpoke Hat/For dairy experts./false/true" #!String
| The translated item name shown in-game.
    35: "Archer's Cap/Fashionable whether you're an archer or not./false/true" #!String
|-
    36: "Panda Hat/A lovely panda hat./false/true" #!String
| 6
</source>
| 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 hardcoded category of -95 (see <samp>HatDataDefinition.GetData</samp> in the game code).
 
==See also==
* [[Modding:Items]] for item data in general
 
[[Category:Modding]]
 
[[zh:模组:帽子]]

Latest revision as of 07:55, 28 December 2024

← Items

This page explains how the game stores and parses hat-type item data. For items in general, see Modding:Items.

Overview

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

They have item type (H) (or ItemRegistry.type_hat in C# code), their data in Data/Hats, their in-game sprites in Characters/Farmer/hats by default, and their code in StardewValley.Objects.Hat.

Data format

The hat data in Data/Hats consists of a string → string lookup, where...

  • The key is the unqualified item ID.
  • The value is a slash-delimited strings with the fields listed below.
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 hardcoded category of -95 (see HatDataDefinition.GetData in the game code).

See also