模组:果树数据
跳到导航
跳到搜索
←目录
此页面解释该游戏是如何存储和解析果树数据。
原始数据
果树数据存储在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 | 果树结果的季节。应为季节名称的数组(季节名:spring,summer,fall或winter)。 | ||||||||||||
Fruit | 当果树处于当季时,水果物品将每天添加到对应的果树上。
该字段为包含如下字段的数据模型所组成的列表:
| ||||||||||||
Texture | 游戏的Content文件夹中储存的贴图对应的素材名称。如需要,可使用\(在JSON中需使用\\)来分隔名称区段。例如,原版果树贴图素材名称为TileSheets\fruitTrees。 | ||||||||||||
TextureSpriteRow | 果树在Texture给出的贴图集中的行索引(例如,0代表第一,1代表第二,以此类推)。 | ||||||||||||
PlantableLocationRules | (可选) 决定可以种植该果树的地点(若可用)。会使用第一个匹配的规则。可重写地点检查(例如作物只能种在农场中),但不可重写内建的要求,例如作物需要土壤。
该字段为包含以下字段的数据模型所组成的列表:
| ||||||||||||
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。 - 也可按常规方式给予玩家树苗(例如通过商店或邮件)。