Skip to content

Json Data Types

Smartin-b edited this page Apr 28, 2024 · 11 revisions

Json Data Types

This page covers a bunch of default data types used in our jsons and covers what they do

Properties

  • Properties are responsible for providing modules with effects, statistics, and other attributes.
  • The API includes an extensive selection of properties.
  • Full list of included properties can be found here.
  • Addons can register their properties if so desired. It is adviced for addons to use ModID_property name to avoid collisions
    They need to register like seen in the RegistryInventory
  • Each property has its own way of handling JSON components, witch can be viewed in their Java class

Complex Numbers

  • complex numbers allow for resolving of complex math equations like sin or log
  • allows for referncing of material related stats via [material.JSONKEY]

Resolvers:

collect

  • allows for subvarients of add,max,min,average
  • the variant can all be followed by any other resolver
  • Example [collect.max.material.durability]

material

  • "[material.someStat]"
  • reference a defined stat in a material, if a stat is not defined defaults to 0
  • you can see Materials for more info

module

  • "[module.someStat]"
  • reference a defined stat in a module, if a stat is not defined defaults to 0
  • module stats are defined via ModuleStatsProperty

module-material / material-module

  • [module-material.durability] [material-module.durability]
  • this will try to first use the first option, and if no specific stat was set will fallback to the second

count

  • [count.module] -> total number of modules on the item
  • [count.submodules] -> total number of submodules on the item
  • [count.unique_materials] -> total number of different materials used on the item
  • [count.root_material_matches] -> total number of material used on the whole item matching the current first module with a material
  • [count.material_matches] -> total number of material used on the whole item matching the current modules material

Conditions

Conditions allow in a simple way to create complex conditions for certain things to apply

A common use is that ANY json loaded by truly modular supports loading conditions the key "load_condition"://actual condition object can be used in any json, this can make files conditional on other mods

Default Structure

{
    "type": "condition_type"
}

Types

true

This condition is always True no matter what

not

This condition negates a subcondition
Example:

{
	"type": "not",
	"condition": {
		"type": "true"
	}
}

and

This condition has the sub element "conditions" witch are a list of any number of conditions. if ALL are true this is conisdered true
Example:

{
	"type": "and",
	"conditions": [
		{
			"type": "not",
			"condition": {
				"type": "true"
			}
		},
		{
			"type": "true"
		}
	]
}

or

This condition has the sub element "conditions" witch are a list of any number of conditions. if at least one is true this is conisdered true
Example:

{
	"type": "or",
	"conditions": [
		{
			"type": "not",
			"condition": {
				"type": "true"
			}
		},
		{
			"type": "true"
		}
	]
}

Module Specific Conditions

These conditions only are able to return true if used in relation to modules

parent

Parent Conditions shift the Condition Context to the parent module if applicable, if no parent module is there this is considered false
Example:

{
	"type": "parent",
	"condition": {
		"type": "not",
		"condition": {
			"type": "true"
		}
	}
}

child

Child Conditions shift the Condition Context to the child module if applicable, if no child module is there this is considered false
It is tested on all children and as long as one does return true this is considered true
Example:

{
	"type": "child",
	"condition": {
		"type": "not",
		"condition": {
			"type": "true"
		}
	}
}

otherModule

This Condition shifts the context to all modules on the Item, if the subCondition is true for at least one module this is considered true
Example:

{
	"type": "otherModule",
	"condition": {
		"type": "not",
		"condition": {
			"type": "true"
		}
	}
}

module

This Condition tests if the current module has a certain ID, it is best used with some of the conditions above
Example:

{
	"type": "module",  
	"module": "blade_sword"  
}

material

This Condition tests if the current module has a certain material, it is best used with some of the conditions above
Example:

{
	"type": "material",
	"material": "iron"
}

material count

This Condition tests if the current iteme has a certain amount of modules with a certain material Example:

{
	"type": "material_count",
	"material": "iron",
        "count":5
}

tag

This Condition tests if the current module has a certain tag, module-tags are used to simply identify groups of related modules like blades or handles
Example:

{
	"type": "tag",
	"tag": "blade"
}

Other Types

advancement

This Condition tests if the current assosiated Player has a certain advancement
to find the correct Ids the /advancement command is very usefull
Example:

{
	"type": "advancement",
	"advancement": "minecraft:story/enter_the_nether"
}

Item in Inventory

This Condition tests if the current assosiated Player has a amount of items of that type in their inventory Example:

{
	"type": "item_in_inventory",
	"item": "minecraft:dirt",
        "count": 5
}

mod_loaded

This Condition tests another mod is loaded. this is usually used as a loadCondition for optional jsons
as mod the mod ID of the other mod is used
Example:

{
	"type": "mod_loaded",
	"mod": "bettercombat"
}
Clone this wiki locally