天赋树数据包配置教程 (pa)

天赋树数据包配置教程 | Talent Tree Datapack Configuration Guide

目录结构 | Directory Structure

1
2
3
4
data/
└── <namespace>/
└── talent_trees/
└── *.json

天赋树 JSON 文件放置在 data/<命名空间>/talent_trees/ 目录下。
可以有多个 JSON 文件,它们会被合并加载。


JSON 格式 | JSON Format

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
"talents": [
{
"id": "talent_id",
"name": "talent.namespace.talent_id.name",
"description": "talent.namespace.talent_id.desc",
"icon": "minecraft:diamond_sword",
"x": 0,
"y": 0,
"isStartingTalent": false,
"prerequisites": ["other_talent_id"],
"itemCost": [
{"item": "minecraft:iron_ingot", "count": 5}
],
"xpLevelCost": 5,
"connections": ["connected_talent_id"],
"attributeModifiers": [
{
"attribute": "minecraft:generic.max_health",
"amount": 4.0,
"operation": "add"
}
],
"effects": [
{
"effect": "minecraft:speed",
"amplifier": 0
}
]
}
]
}

字段说明 | Field Reference

字段 类型 必填 说明
id String ✅ 天赋的唯一 ID(不含命名空间)
name String ✅ 直接文本 或 本地化键名(自动检测)
description String ✅ 直接文本 或 本地化键名(自动检测)
icon String ✅ 图标(见下方格式)
x Integer ✅ 在 GUI 中的 X 坐标(像素)
y Integer ✅ 在 GUI 中的 Y 坐标(像素)
isStartingTalent Boolean ❌ 是否为起始天赋(默认 false)
prerequisites Array ❌ 前置天赋 ID 列表
itemCost Array ❌ 物品消耗列表
xpLevelCost Integer ❌ 经验等级消耗
connections Array ❌ 连接线目标天赋 ID(用于 GUI 绘制)
frameType String ❌ 选择框样式预设(见下方说明)
attributeModifiers Array ❌ 属性加成列表
effects Array ❌ 持续药水效果列表
affixes Array ❌ 特殊词条效果列表 (如 explode_on_death, last_stand)

选择框样式 | Frame Type Presets

可以为每个天赋节点指定不同的选择框样式。

1
2
3
4
5
{
"id": "special_talent",
"frameType": "diamond",
...
}
预设值 尺寸 说明
square 32x32 默认矩形框
circle 32x32 圆形边框
diamond 32x32 菱形边框(45 度旋转)
hexagon 32x32 六边形边框
octagon 32x32 八边形边框
small_square 24x24 小型矩形框
small_circle 24x24 小型圆形边框
small_diamond 24x24 小型菱形边框
small_hexagon 24x24 小型六边形边框
small_octagon 24x24 小型八边形边框

注意:如果不指定 frameType,默认使用 square。


GUI 操作 | GUI Controls

天赋树界面支持以下交互操作:

操作 功能
鼠标左键拖动 平移视图
滚轮向上 放大(最大 2.0x)
滚轮向下 缩小(最小 0.5x)
双击天赋 解锁天赋

提示:缩放会以鼠标位置为中心进行,方便聚焦查看特定区域。

名称和描述 | Name and Description

支持两种格式:

直接文本(推荐)

直接写入显示的文字,不需要创建语言文件:

1
2
"name": "战士之路",
"description": "以强大的战士身份开始你的旅程"

本地化键名

使用带点号的格式,会自动查找语言文件翻译:

1
2
"name": "talent.mymod.warrior.name",
"description": "talent.mymod.warrior.desc"

自动检测规则:如果文本包含 . 符号且不包含颜色代码(§),会被视为本地化键名。

自定义贴图

使用 texture: 前缀:

1
"icon": "texture:playeraffixes:textures/talent/custom.png"

背景设置 | Background Settings

可以在 JSON 根对象中配置天赋树的背景。

1
2
3
4
5
6
7
{
"background": "playeraffixes:textures/gui/talent_tree_bg.png",
"backgroundMode": "tile",
"backgroundWidth": 64,
"backgroundHeight": 64,
"talents": [...]
}
字段 类型 默认值 说明
background String playeraffixes:textures/gui/talent_tree_bg.png 背景纹理路径
backgroundMode String stretch 渲染模式:stretch (拉伸), tile (平铺), center (居中)
backgroundWidth Integer 256 背景纹理宽度(用于平铺和居中模式)
backgroundHeight Integer 256 背景纹理高度(用于平铺和居中模式)

起始天赋 | Starting Talents

起始天赋需要设置 isStartingTalent: true。

  • 玩家只能选择一个起始天赋
  • 选择后其他起始天赋将被锁定
  • 起始天赋不需要前置条件
1
2
3
4
5
6
7
8
{
"id": "warrior_start",
"name": "talent.mymod.warrior_start.name",
"isStartingTalent": true,
"x": 0,
"y": 0,
...
}

解锁条件 | Unlock Conditions

前置天赋

1
"prerequisites": ["warrior_start", "strength_boost"]

必须解锁所有列出的前置天赋才能解锁此天赋。

物品消耗

1
2
3
4
"itemCost": [
{"item": "minecraft:diamond", "count": 3},
{"item": "minecraft:gold_ingot", "count": 10}
]

解锁时会从玩家背包中扣除这些物品。

经验消耗

1
"xpLevelCost": 10

解锁时会扣除玩家的经验等级。


连接线 | Connections

connections 字段用于在 GUI 中绘制天赋之间的连接线。

1
2
3
4
{
"id": "strength_boost",
"connections": ["combat_mastery"]
}

注意:连接线只是视觉效果,不影响解锁逻辑。
解锁逻辑由 prerequisites 控制。


天赋效果 | Talent Effects

天赋可以提供永久的属性加成或持续的药水效果。

属性加成 (Attribute Modifiers)

支持修改任何注册的属性(如生命值、速度、攻击力等)。

1
2
3
4
5
6
7
8
9
10
11
12
"attributeModifiers": [
{
"attribute": "minecraft:generic.max_health",
"amount": 4.0,
"operation": "add"
},
{
"attribute": "minecraft:generic.movement_speed",
"amount": 0.1,
"operation": "multiply_base"
}
]

操作类型 (Operation):

  • add: 直接加法(如 +4 生命值)
  • multiply_base: 基于基础值的乘法(如 +10% 速度)
  • multiply_total: 基于最终值的乘法

持续效果 (Potion Effects)

只要天赋解锁,玩家就会获得对应的药水效果。

1
2
3
4
5
6
7
8
9
10
"effects": [
{
"effect": "minecraft:night_vision",
"amplifier": 0
},
{
"effect": "minecraft:regeneration",
"amplifier": 1
}
]
  • effect: 效果 ID
  • amplifier: 等级(0 代表 I 级,1 代表 II 级)

特殊词条 (Affixes)

特殊词条允许触发复杂的逻辑效果。

1
"affixes": ["explode_on_death", "last_stand"]

详细的词条列表和说明请参考:特殊词条指南 (AFFIX_GUIDE.md)


职业联动 (ClassBioArsenal) | Profession Integration

如果安装了 ClassBioArsenal 模组,可以为天赋添加职业要求和基于职业等级的属性缩放。

职业需求 (Profession Requirements)

支持配置多个职业需求,玩家满足其中任意一个即可解锁(OR 逻辑)。

1
2
3
4
5
6
7
8
9
10
"professionRequirements": [
{
"profession": "warrior",
"level": 10
},
{
"profession": "dual_swordsman",
"level": 5
}
]
  • profession: 职业 ID。
  • level: 需要达到的最低等级。

提示:如果只设置一个职业,也可以使用旧版字段(不推荐):
"requiredProfession": "warrior", "requiredProfessionLevel": 10

属性缩放 (Profession Attribute Scale)

天赋提供的属性加成可以根据玩家当前职业的等级进行缩放。

1
"professionAttributeScale": 0.1

计算公式:
最终加成 = 基础加成 * (1 + 职业等级 * professionAttributeScale)

例如:基础攻击力 +5,职业等级 10,缩放 0.1。
最终攻击力加成 = 5 * (1 + 10 * 0.1) = 10

注意:缩放效果仅对 attributeModifiers 中的加成生效。


坐标系统 | Coordinate System

  • 坐标 (0, 0) 是天赋树的左上角
  • X 向右增加,Y 向下增加
  • 每个天赋占用 32x32 像素
  • 建议天赋之间间隔至少 50-80 像素
1
2
3
4
5
6
7
示例布局:
(0,0) (80,0) (160,0)
●---------●---------●
|
|
(0,80)
●

完整示例 | Complete Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{
"talents": [
{
"id": "warrior_start",
"name": "talent.mymod.warrior_start.name",
"description": "talent.mymod.warrior_start.desc",
"icon": "minecraft:iron_sword",
"x": 0,
"y": 0,
"isStartingTalent": true,
"connections": ["strength_boost"]
},
{
"id": "mage_start",
"name": "talent.mymod.mage_start.name",
"description": "talent.mymod.mage_start.desc",
"icon": "minecraft:book",
"x": 160,
"y": 0,
"isStartingTalent": true,
"connections": ["magic_power"]
},
{
"id": "strength_boost",
"name": "talent.mymod.strength_boost.name",
"description": "talent.mymod.strength_boost.desc",
"icon": "minecraft:diamond_sword",
"x": 0,
"y": 80,
"prerequisites": ["playeraffixes:warrior_start"],
"xpLevelCost": 5,
"itemCost": [{"item": "minecraft:iron_ingot", "count": 10}],
"connections": ["combat_mastery"]
},
{
"id": "magic_power",
"name": "talent.mymod.magic_power.name",
"description": "talent.mymod.magic_power.desc",
"icon": "minecraft:enchanted_book",
"x": 160,
"y": 80,
"prerequisites": ["playeraffixes:mage_start"],
"xpLevelCost": 5,
"connections": ["combat_mastery"]
},
{
"id": "combat_mastery",
"name": "talent.mymod.combat_mastery.name",
"description": "talent.mymod.combat_mastery.desc",
"icon": "minecraft:netherite_sword",
"x": 80,
"y": 160,
"prerequisites": ["playeraffixes:strength_boost", "playeraffixes:magic_power"],
"xpLevelCost": 10,
"itemCost": [{"item": "minecraft:diamond", "count": 5}]
}
]
}

本地化 | Localization

在语言文件中添加对应的翻译:

assets/mymod/lang/en_us.json:

1
2
3
4
{
"talent.mymod.warrior_start.name": "Path of the Warrior",
"talent.mymod.warrior_start.desc": "Start your journey as a warrior."
}

assets/mymod/lang/zh_cn.json:

1
2
3
4
{
"talent.mymod.warrior_start.name": "战士之路",
"talent.mymod.warrior_start.desc": "以战士身份开始你的旅程。"
}

管理员命令 | Admin Commands

命令 说明
/talent unlock <玩家> <天赋ID> 直接解锁天赋(无视条件)
/talent reset <玩家> 重置玩家所有天赋
/talent reload 热重载天赋数据包

示例:

1
2
3
/talent unlock @p playeraffixes:warrior_start
/talent reset Steve
/talent reload

命令需要 OP 权限等级 2 或更高。


热重载 | Hot Reload

修改数据包后,使用以下命令重载:

1
/talent reload

这将:

  1. 重新加载所有天赋配置
  2. 同步到所有在线玩家
  3. 保留玩家已解锁的天赋

注意:如果删除了玩家已解锁的天赋 ID,该记录仍会保留在存档中。

Icon喜欢这篇作品的话,奖励一下我吧~
💗感谢你的喜欢与支持!
致谢名单
本作品由 JoBackRer 于 2026-01-21 18:04:10 发布
作品地址:天赋树数据包配置教程 (pa)
除特别声明外,本站作品均采用 CC BY-NC-SA 4.0 许可协议,转载请注明来自 JoBackRer の blog
Logo