Skip to main content

Skill Trees

Skills are unlocked by faction players through skill trees. Every playable faction has at least one skill tree (typically one for normal leveling and one for lord leveling), and a tree is made up of skill segments that are wired together into a graph.

Both skill trees and skill segments live in their own dynamic registries and are ordinary datapack files, so they can be added, overridden or removed by any datapack. In the mod they are data generated.

JSON Schemas

Concepts

  • A skill tree (de.teamlapen.faction.api.factions.skills.ISkillTree) defines the tree that is shown as a tab in the skill screen: which faction it belongs to, how it is unlocked, its title and icon, and which skill point pool it draws from.
  • A skill segment (de.teamlapen.faction.api.factions.skills.ISkillSegment) is a single node in that tree. It holds one skill (or a self-exclusive choice between several skills), the segments it descends from (parents), the segments that lock it out (locking_segments) and an optional layout hint (placement).
  • A segment with no parents is a root. Roots are placed at the top of the tree, are granted for free once the tree is unlocked, and are kept when the player resets their skills. A tree may have multiple roots.
  • A segment can be unlocked as soon as any of its parents is unlocked.

Location and Id

RegistryFolder
factionapi:skill_treedata/<namespace>/factionapi/skill_tree/<path>.json
factionapi:skill_segmentdata/<namespace>/factionapi/skill_segment/<path>.json

The id is derived from the file location like any other datapack registry entry: data/vampirism/factionapi/skill_tree/vampire/level.json produces the id vampirism:vampire/level, and data/vampirism/factionapi/skill_segment/vampire/blood_vision.json produces vampirism:vampire/blood_vision.

Use your own <namespace> for new content, or vampirism / factionapi to override built-in entries.

Skill Tree

data/<namespace>/factionapi/skill_tree/<name>.json
{
"faction": "vampirism:vampire",
"unlock_predicate": {
"type_specific": {
"type": "factionapi:player_faction",
"faction": "vampirism:vampire"
}
},
"display": { "id": "vampirism:vampire_book" },
"name": { "translate": "gui.vampirism.skills.level" },
"background": "vampirism:block/dark_stone_bricks",
"name_suffix": "factionapi:default",
"order_after": []
}
FieldRequiredTypeDescription
factionyesResource locationId of the playable faction this tree belongs to (e.g. vampirism:vampire, vampirism:hunter).
unlock_predicateyesEntity predicateChecked against the player to decide whether the tree is unlocked. Re-evaluated when the faction / lord level changes. Use {} for "always unlocked". See Unlock predicate.
displayyesItem stackIcon shown for the tree tab in the skill screen.
nameyesComponentTitle of the tree.
backgroundnoResource locationBackground sprite, resolved to <namespace>:textures/<path>.png. Defaults to the built-in level background.
name_suffixnoSkill tree tag idThe skill-point pool the tree spends from (ISkillTree#skillPointTag). Tag id without #. Defaults to factionapi:default.
order_afternoSkill tree id[]The tree is displayed after all listed trees in the skill screen. Defaults to [].
note

Built-in pools are factionapi:default.

Unlock predicate

unlock_predicate is a full vanilla entity predicate. In practice you use the type_specific field with one of the sub-predicates that Faction API registers:

factionapi:player_faction

Matches the current player against their own faction state.

{
"type_specific": {
"type": "factionapi:player_faction",
"faction": "vampirism:vampire",
"level": 3,
"lord_level": 1
}
}
FieldRequiredTypeDescription
factionnoResource locationIf set, the player must currently be in this faction.
levelnointMinimum faction level.
lord_levelnointMinimum lord level.

factionapi:faction

Same fields as above, but faction accepts any faction (not only playable ones).

Skill Segment

data/<namespace>/factionapi/skill_segment/<name>.json
{
"tree": "vampirism:vampire/level",
"skills": [
"vampirism:vampire_attack_speed",
"vampirism:vampire_speed"
],
"parents": [
"vampirism:vampire/sunscreen"
],
"locking_segments": [],
"placement": {
"type": "after",
"segment": "vampirism:vampire/some_other_segment"
}
}
FieldRequiredTypeDescription
treeyesSkill tree idThe skill tree this segment is part of.
skillsyesResource location[] (non-empty)Skill ids contained in the segment. They are self-exclusive – the player picks exactly one. Use separate segments if multiple choices should be allowed.
parentsnoSkill segment id[]The segments this one descends from. Unlockable as soon as any parent is unlocked. Empty ⇒ this segment is a root. Defaults to [].
locking_segmentsnoSkill segment id[]Once a skill in any listed segment is unlocked, this segment can no longer be unlocked. The relation is stored one way only, so a mutual exclusion must be declared on both segments. Defaults to [].
placementnoPlacementLayout hint that positions this segment on one side of another segment in the same row. Omit to leave positioning to the layout.

Placement

{
"type": "after",
"segment": "vampirism:vampire/finisher"
}
FieldRequiredTypeDescription
typeyesbefore | afterbefore = left of, after = right of the referenced segment.
segmentyesSkill segment idThe segment to position next to. Must be in the same row.

Full example

data/vampirism/factionapi/skill_tree/vampire/lord.json
{
"background": "vampirism:block/dark_stone_bricks",
"display": { "id": "vampirism:vampire_minion_binding" },
"faction": "vampirism:vampire",
"name": { "translate": "gui.vampirism.skills.lord" },
"order_after": [
"vampirism:vampire/level"
],
"unlock_predicate": {
"type_specific": {
"type": "factionapi:player_faction",
"faction": "vampirism:vampire",
"lord_level": 1
}
}
}
data/vampirism/factionapi/skill_segment/vampire/level_root.json
{
"tree": "vampirism:vampire/level",
"skills": [
"vampirism:vampire"
]
}
data/vampirism/factionapi/skill_segment/vampire/attack_or_movement_speed.json
{
"tree": "vampirism:vampire/level",
"parents": [
"vampirism:vampire/sunscreen"
],
"skills": [
"vampirism:vampire_attack_speed",
"vampirism:vampire_speed"
]
}

More generated examples can be found in the mod sources under projects/vampirism/src/generated/resources/data/vampirism/factionapi/skill_tree/ and .../skill_segment/.