-
Notifications
You must be signed in to change notification settings - Fork 0
How the JSONs Work
Minecraft's NBT structure is very similar to JSON. Because of that, NBT can be structured however the user wants/needs it to be. Because of this variability, we have to account for that in this mod's jsons. The process of building this mod's jsons is a process of mirroring the NBT. We have to tell the mod "This is the value I want to use for my requirements and here's how to get to that value". For example, let's assume I want to give a combat 5 requirement if the item has "material": "diamond"
. What would be nice is something simple like
{
"somemod:sword": {
"key": "material",
"value": "diamond",
"reqs": { "combat": 5 }
}
}
and let's assume we have the following nbt on our "somemod:sword"
{
sword_blade: {
material:"diamond",
damage:0b
},
sword_handle: {
material:"diamond",
damage:5b
}
}
Which material
tag do we want to use? the blade or the handle? Because we need to specify, we need to tell this mod "First, get the compound with the key "sword_blade", then inside that compound get the key "material", and if its value equals "diamond", the reqs are "combat 5"". Our valid json would then look like
{
"somemod:sword": {
"summative": false,
"values": [
{
"type": "compound",
"keys": ["sword_blade"],
"sub_references": [
{
"type": "id",
"keys": ["material"],
"predicates": [
{
"operator": "EQUALS",
"comparator": "diamond",
"value": { "combat": 5}
}
]
}
]
}
]
}
}
You can read more about what each of those elements means HERE
As long as the JSON accurately reflects the NBT, this mod will know what you are looking for. In non-technical terms it's like you have the JSON on one sheet in front of you and the NBT on another. As you read the json and see "compound "sword_blade"" and look in the NBT's base tag for a compound by that name. Then if you find it, you go to the sub_reference
in the json to see where to look next. You see you are supposed to find your destination (because id
) as a key called "material" and see if any of the predicates match. in our example we have only one which wants to see if the value of "material" equals "diamond", which if true means the item has the requirement of 5 combat skill.
each of those keys in our json is plural and also a JsonArray. This means you can input multiple values into each of them and the Json reader will repeat all subsequent actions for each of them. This only works if the structure of both keys is the same. an example of this is the SlientGear template, where the left and right heads are nested in the same place and both are id
types. Use this to minimize the size of your Jsons whenever possible.