-
Notifications
You must be signed in to change notification settings - Fork 0
JSON Structure
Caltinor edited this page Apr 18, 2021
·
3 revisions
The basic JSON components of all the requirement files consists of each item/block regsitryKey as a base node. Under each node are required two keys:
-
"summative"
which determines if passing requirements add up (true
) or only use the highest (false
) -
"values"
which is an array of elements. each element is it's own unique evaluation
{
"examplemod:exampleitem": {
"summative": false,
"values": [
{
"type": "id",
"keys": ["nbt_key"],
"predicates": [
{
"operator": "EQUALS",
"comparator": 0,
"value": { "mining": 10, "smithing": 5 }
}
]
},
{
"type": "compound",
"keys": ["compound_key"],
"sub_references": [{
"type": "id",
"key": "nbt_key",
"predicates": [
{
"operator": "GREATER_THAN",
"comparator": 9,
"value": { "mining": 10, "smithing": 5 }
}
]
}]
},
{
"type": "list",
"keys": ["list_key"],
"index": 0,
"sub_references": [{
"type": "id",
"key": "subobject_key_or_item_value",
"predicates": [
{
"operator": "EXISTS",
"value": { "mining": 10, "smithing": 5 }
}
]
}]
}
]
}
}
Values consist of base elements which consist of the following required components:
-
"type"
with acceptable values ofid
,compound
, andlist
. -
"keys"
a string list which refers to the NBT compound keys corresponding to the item
Depending on the type, certain additional keys are required:
- for
id
"predicates": [{}]
which defines how the value is to be evaluated
- for
list
"index"
which points to a specific position in the list or, if-1
is used, scans all elements
- for
compound
andlist
"sub_references": [{}]
contains another base element that describes what is contained in the compound or list. This is how nested structures can be isolated in your JSON
The predicate key has two required keys "operator"
, "value"
, and one conditional key "comparator"
- Options for
"operator"
include
"EQUALS"
,"GREATER_THAN"
,"LESS_THAN"
,"GREATER_THAN_OR_EQUAL"
,"LESS_THAN_OR_EQUAL"
,"EXISTS"
-
"value": {}
which is PMMO's default values structure eg{ "mining": 5 }
-
"comparator"
is the value which is being compared to the value from the NBT key. for example if the operator wereLESS_THAN
and the key were fordamage
and the comparator were 10, the values in thevalue
key would only apply when the damage value was less than 10."comparator"
is conditional in that is is required for all butEXISTS
. this operator returns true if the key in the JSON exists in the NBT at the nested location specified.
There may be cases where a compound is the sub_reference type of a list. when this occurs, there are no keys.
- use
""
as the"key"
in list sub_references of typecompound
the json req_break_nbt
has one difference from the other jsons. Under the registryKey node but before the summative
and values
keys are two required keys item
and tile
. See below for basic structure
{
"examplemod:exampleblock": {
"item": {
"summative": false,
"values": []
},
"tile": {
"summative": false,
"values": []
}
}
}