-
Notifications
You must be signed in to change notification settings - Fork 39
JSON Format
This page is formatted by first showing three examples of some attribute jsons, followed by an in-depth explanation of what each tag means and what everything does.
The following show examples of different attributes and how they're implemented using json.
{
"type": "GAME",
"uuid": "396c3a15-6329-45c0-ba55-11beb5c2210e",
"defaultValue": 0.0,
"minValue": 0.0,
"maxValue": 2147483647.0,
"translationKey": "attribute.name.playerex.constitution",
"properties": {
"weight": 0.8,
"minroll": 1.0,
"maxroll": 10.0
},
"functions": [
{
"attribute": "minecraft:generic.max_health",
"type": "FLAT",
"multiplier": 1.0
},
{
"attribute": "minecraft:generic.knockback_resistance",
"type": "DIMINISHING",
"multiplier": 0.01
},
{
"attribute": "playerex:magic_resistance",
"type": "DIMINISHING",
"multiplier": 0.01
}
]
}
{
"type": "GAME",
"uuid": "a17e6fc4-4128-46f7-854b-22ea2f16da0d",
"defaultValue": 0.0,
"minValue": 0.0,
"maxValue": 1.0,
"translationKey": "attribute.name.playerex.evasion",
"properties": {
"percent": 100.0,
"weight": 0.3,
"minroll": 0.01,
"maxroll": 0.25
},
"functions": []
}
{
"type": "DATA",
"uuid": "7f7d3cd2-d91a-40bd-b19c-053edc27424e",
"defaultValue": 0.0,
"minValue": 0.0,
"maxValue": 2147483647.0,
"translationKey": "attribute.name.playerex.skillpoints",
"properties": {},
"functions": []
}
A player attribute json file contains the following tags: type, uuid, defaultValue, minValue, maxValue, translationKey, properties and functions.
This describes the functionality of the attribute by defining the attribute in one of two categories: DATA
and GAME
. Attributes of the GAME
type are added to the player as player attributes and can have modifiers applied. Attributes of the DATA
type, on the other hand, are not added to the player and cannot have modifiers applied - they exist as data storage and are not meant for in game functionality (to be specific, they turn the attribute into just a double
variable provided by Cardinal Components, so it's a quick way to add an efficient data storage). Most of the time you will want your attribute to be of the GAME
type (e.g. max health).
This is the attributes unique id and, obviously, must be unique to that attribute. It is used for internal logic and modifiers.
This is the starting value of the attribute that the player spawns in with (i.e. max health is 20 by default). By editing this value you can edit the initial value of the attribute.
The minimum value the attribute can have. No matter what the attribute's value will not go below this.
The maximum value the attribute can have. No matter what the attribute's value will not go above this. It is important to note here that it is not advisable to thoughtlessly set the maximum value of every attribute to some arbitrary number like 9999999999, for reasons that will become clear later on.
This is a pointer that refers to a language key representing the reader-friendly attribute name. For example, attribute.name.generic.max_health
points to Max Health
. This may allow you to modify the attributes name more easily.
This is a set of key-value pairs (implemented as a HashMap) that allows developers to attach custom information to attributes. By default, PlayerEx implements five properties that can be used: weight
, minroll
, maxroll
, percent
and multiplier
. See Attribute Properties for information on how to use these.
This is perhaps the most useful tag; it allows you to influence the value of other attributes depending on how the value of this attribute is modified. See Attribute Functions for information on how to use these.