模组:果树数据

来自Stardew Valley Wiki
跳到导航 跳到搜索

目录

此页面解释该游戏是如何存储和解析果树数据。

原始数据

果树数据存储在Content\Data\FruitTrees.xnb中, 编辑文件时需进行解包。

以下是1.6.8版本的果树原始数据:

数据 
{
  "628": {
    "PlantableLocationRules": null,
    "DisplayName": "[LocalizedText Strings\\Objects:Cherry_Name]",
    "Seasons": [
      "Spring"
    ],
    "Fruit": [
      {
        "Season": null,
        "Chance": 1.0,
        "Condition": null,
        "Id": "Default",
        "ItemId": "(O)638",
        "RandomItemId": null,
        "MaxItems": null,
        "MinStack": -1,
        "MaxStack": -1,
        "Quality": -1,
        "ObjectInternalName": null,
        "ObjectDisplayName": null,
        "ToolUpgradeLevel": -1,
        "IsRecipe": false,
        "StackModifiers": null,
        "StackModifierMode": "Stack",
        "QualityModifiers": null,
        "QualityModifierMode": "Stack",
        "ModData": null,
        "PerItemCondition": null
      }
    ],
    "Texture": "TileSheets\\fruitTrees",
    "TextureSpriteRow": 0,
    "CustomFields": null
  },
  "629": {
    "PlantableLocationRules": null,
    "DisplayName": "[LocalizedText Strings\\Objects:Apricot_Name]",
    "Seasons": [
      "Spring"
    ],
    "Fruit": [
      {
        "Season": null,
        "Chance": 1.0,
        "Condition": null,
        "Id": "Default",
        "ItemId": "(O)634",
        "RandomItemId": null,
        "MaxItems": null,
        "MinStack": -1,
        "MaxStack": -1,
        "Quality": -1,
        "ObjectInternalName": null,
        "ObjectDisplayName": null,
        "ToolUpgradeLevel": -1,
        "IsRecipe": false,
        "StackModifiers": null,
        "StackModifierMode": "Stack",
        "QualityModifiers": null,
        "QualityModifierMode": "Stack",
        "ModData": null,
        "PerItemCondition": null
      }
    ],
    "Texture": "TileSheets\\fruitTrees",
    "TextureSpriteRow": 1,
    "CustomFields": null
  },
  "630": {
    "PlantableLocationRules": null,
    "DisplayName": "[LocalizedText Strings\\Objects:Orange_Name]",
    "Seasons": [
      "Summer"
    ],
    "Fruit": [
      {
        "Season": null,
        "Chance": 1.0,
        "Condition": null,
        "Id": "Default",
        "ItemId": "(O)635",
        "RandomItemId": null,
        "MaxItems": null,
        "MinStack": -1,
        "MaxStack": -1,
        "Quality": -1,
        "ObjectInternalName": null,
        "ObjectDisplayName": null,
        "ToolUpgradeLevel": -1,
        "IsRecipe": false,
        "StackModifiers": null,
        "StackModifierMode": "Stack",
        "QualityModifiers": null,
        "QualityModifierMode": "Stack",
        "ModData": null,
        "PerItemCondition": null
      }
    ],
    "Texture": "TileSheets\\fruitTrees",
    "TextureSpriteRow": 2,
    "CustomFields": null
  },
  "631": {
    "PlantableLocationRules": null,
    "DisplayName": "[LocalizedText Strings\\Objects:Peach_Name]",
    "Seasons": [
      "Summer"
    ],
    "Fruit": [
      {
        "Season": null,
        "Chance": 1.0,
        "Condition": null,
        "Id": "Default",
        "ItemId": "(O)636",
        "RandomItemId": null,
        "MaxItems": null,
        "MinStack": -1,
        "MaxStack": -1,
        "Quality": -1,
        "ObjectInternalName": null,
        "ObjectDisplayName": null,
        "ToolUpgradeLevel": -1,
        "IsRecipe": false,
        "StackModifiers": null,
        "StackModifierMode": "Stack",
        "QualityModifiers": null,
        "QualityModifierMode": "Stack",
        "ModData": null,
        "PerItemCondition": null
      }
    ],
    "Texture": "TileSheets\\fruitTrees",
    "TextureSpriteRow": 3,
    "CustomFields": null
  },
  "632": {
    "PlantableLocationRules": null,
    "DisplayName": "[LocalizedText Strings\\Objects:Pomegranate_Name]",
    "Seasons": [
      "Fall"
    ],
    "Fruit": [
      {
        "Season": null,
        "Chance": 1.0,
        "Condition": null,
        "Id": "Default",
        "ItemId": "(O)637",
        "RandomItemId": null,
        "MaxItems": null,
        "MinStack": -1,
        "MaxStack": -1,
        "Quality": -1,
        "ObjectInternalName": null,
        "ObjectDisplayName": null,
        "ToolUpgradeLevel": -1,
        "IsRecipe": false,
        "StackModifiers": null,
        "StackModifierMode": "Stack",
        "QualityModifiers": null,
        "QualityModifierMode": "Stack",
        "ModData": null,
        "PerItemCondition": null
      }
    ],
    "Texture": "TileSheets\\fruitTrees",
    "TextureSpriteRow": 4,
    "CustomFields": null
  },
  "633": {
    "PlantableLocationRules": null,
    "DisplayName": "[LocalizedText Strings\\Objects:Apple_Name]",
    "Seasons": [
      "Fall"
    ],
    "Fruit": [
      {
        "Season": null,
        "Chance": 1.0,
        "Condition": null,
        "Id": "Default",
        "ItemId": "(O)613",
        "RandomItemId": null,
        "MaxItems": null,
        "MinStack": -1,
        "MaxStack": -1,
        "Quality": -1,
        "ObjectInternalName": null,
        "ObjectDisplayName": null,
        "ToolUpgradeLevel": -1,
        "IsRecipe": false,
        "StackModifiers": null,
        "StackModifierMode": "Stack",
        "QualityModifiers": null,
        "QualityModifierMode": "Stack",
        "ModData": null,
        "PerItemCondition": null
      }
    ],
    "Texture": "TileSheets\\fruitTrees",
    "TextureSpriteRow": 5,
    "CustomFields": null
  },
  "69": {
    "PlantableLocationRules": null,
    "DisplayName": "[LocalizedText Strings\\Objects:Banana_Name]",
    "Seasons": [
      "Summer"
    ],
    "Fruit": [
      {
        "Season": null,
        "Chance": 1.0,
        "Condition": null,
        "Id": "Default",
        "ItemId": "(O)91",
        "RandomItemId": null,
        "MaxItems": null,
        "MinStack": -1,
        "MaxStack": -1,
        "Quality": -1,
        "ObjectInternalName": null,
        "ObjectDisplayName": null,
        "ToolUpgradeLevel": -1,
        "IsRecipe": false,
        "StackModifiers": null,
        "StackModifierMode": "Stack",
        "QualityModifiers": null,
        "QualityModifierMode": "Stack",
        "ModData": null,
        "PerItemCondition": null
      }
    ],
    "Texture": "TileSheets\\fruitTrees",
    "TextureSpriteRow": 7,
    "CustomFields": null
  },
  "835": {
    "PlantableLocationRules": null,
    "DisplayName": "[LocalizedText Strings\\Objects:Mango_Name]",
    "Seasons": [
      "Summer"
    ],
    "Fruit": [
      {
        "Season": null,
        "Chance": 1.0,
        "Condition": null,
        "Id": "Default",
        "ItemId": "(O)834",
        "RandomItemId": null,
        "MaxItems": null,
        "MinStack": -1,
        "MaxStack": -1,
        "Quality": -1,
        "ObjectInternalName": null,
        "ObjectDisplayName": null,
        "ToolUpgradeLevel": -1,
        "IsRecipe": false,
        "StackModifiers": null,
        "StackModifierMode": "Stack",
        "QualityModifiers": null,
        "QualityModifierMode": "Stack",
        "ModData": null,
        "PerItemCondition": null
      }
    ],
    "Texture": "TileSheets\\fruitTrees",
    "TextureSpriteRow": 8,
    "CustomFields": null
  }
}

数据格式

Data/FruitTrees 由以下字符串组成:

字段 说明
DisplayName 用于显示树名的模板字符串。不可包含“tree”字样(比如樱桃树的DisplayName为“Cherry”)。此名称可用于某些UI信息,例如“您的DisplayName树昨晚无法生长。”
Seasons 果树结果的季节。应为季节名称的数组(季节名:springsummerfallwinter)。
Fruit 当果树处于当季时,水果物品将每天添加到对应的果树上。

该字段为包含如下字段的数据模型所组成的列表:

字段 效果
公共字段 参见物品生成字段以获取果树物品支持的通用物品字段。

说明:

  • 若设为返回多个物品的物品查询,则会在其中随机选取一个物品。
  • 在无季节地点,例如温室姜岛,季节条件将被自动忽略。
Season (可选) 若设置此字段,则该数据模型仅在树所在地点处于指定季节时适用。在无季节地点,例如温室姜岛,季节条件将被自动忽略。
Chance (可选) 选择此数据模型的概率,为0(不可能)至 1(必然)之间的值。默认为1(100%概率)。
Texture 游戏的Content文件夹中储存的贴图对应的素材名称。如需要,可使用\(在JSON中需使用\\)来分隔名称区段。例如,原版果树贴图素材名称为TileSheets\fruitTrees
TextureSpriteRow 果树在Texture给出的贴图集中的行索引(例如,0代表第一,1代表第二,以此类推)。
PlantableLocationRules (可选) 决定可以种植该果树的地点(若可用)。会使用第一个匹配的规则。可重写地点检查(例如作物只能种在农场中),但不可重写内建的要求,例如作物需要土壤。

该字段为包含以下字段的数据模型所组成的列表:

字段 效果
Id 当前列表中该规则所对应地点的唯一字符串ID
Result 若当前列表中该规则被选中,则该字段指示树苗是否可以种植在当前地点。可能的取值为:
  • Default:如果正常情况下当前地点允许种植树苗,则可以种植。该取值能够停止检查后续规则。若不可种植,会显示自定义的DeniedMessage.
  • Allow:强制允许树苗种在当前地点,无论正常情况下当前地点是否允许种植。
  • Deny: 强制禁止树苗种在当前地点,无论正常情况下当前地点是否允许种植。
Condition (可选) 指示该规则是否可用的游戏状态查询。默认为true。
PlantedIn (可选) 当前规则适用的种植环境。可能的取值为Ground(直接种在地上)、GardenPot(种在花盆里)或Any。默认为Any

注意:虽然上述可能的取值中列出了花盆选项,但实际上不可将树苗种在花盆中。

DeniedMessage (可选) 一个模板字符串。若此规则禁止种植树苗,则显示此信息。亦可取值为null显示默认信息。当ResultDefault也适用。
CustomFields 该规则的自定义字段

例如,如下内容包添加了一个自定义果树,包括自定义树苗和水果:

{
    "Format": "2.3.0",
    "Changes": [
        // add fruit + sapling items
        // note: sapling must have an edibility under 0 (usually -300) to be plantable
        {
            "Action": "EditData",
            "Target": "Data/Objects",
            "Entries": {
                "{{ModId}}_Pufferfruit": {
                    "Name": "{{ModId}}_Pufferfruit", // best practice to match the ID, since it's sometimes used as an alternate ID
                    "DisplayName": "Pufferfruit",
                    "Description": "An example fruit item.",
                    "Type": "Basic",
                    "Category": -6,
                    "Price": 1200,

                    "Texture": "Mods/{{ModId}}/Objects",
                    "SpriteIndex": 0
                },
                "{{ModId}}_Puffersapling": {
                    "Name": "{{ModId}}_Puffersapling",
                    "DisplayName": "Puffersapling",
                    "Description": "An example tree sapling.",
                    "Type": "Basic",
                    "Category": -74,
                    "Price": 1200,

                    "Texture": "Mods/{{ModId}}/Objects",
                    "SpriteIndex": 1
                }
            }
        },

        // add fruit tree
        {
            "Action": "EditData",
            "Target": "Data/FruitTrees",
            "Entries": {
                "{{ModId}}_Puffersapling": {
                    "DisplayName": "Pufferfruit",
                    "Seasons": [ "spring" ],
                    "Fruit": [
                        {
                            "Id": "E{{ModId}}_Pufferfruit",
                            "ItemId": "{{ModId}}_Pufferfruit"
                        }
                    ],
                    "Texture": "Mods/{{ModId}}/FruitTrees",
                    "TextureSpriteRow": 0
                }
            }
        },

        // add images
        {
            "Action": "Load",
            "Target": "Mods/{{ModId}}/FruitTrees, Mods/{{ModId}}/Objects",
            "FromFile": "assets/{{TargetWithoutPath}}.png" // assets/FruitTrees.png, assets/Objects.png
        },
    ]
}

然后,果树就可以通过树苗种植,树苗可以按正常方式(例如通过商店)给予玩家。

水果物品

对于C# 模组,fruitsOnTree 字段(果树上水果的数量) 被替换为fruit (水果的列表).

生成果树

自定义果树可以用如下方法添加到游戏:

  • 当地点被创建时就在地块上直接生成。这通过如下地块属性实现:SpawnTree: fruit <tree ID> [growth stage on location created] [growth stage on day-update regrowth]。 必须添加在Paths层,且应在paths地块表中索引为34。
  • 也可按常规方式给予玩家树苗(例如通过商店或邮件)。