API reference / @jsprismarine/worldgen / MaterialRuleData
Class: MaterialRuleData
Defined in: surface/MaterialRule.ts:124
The parsed material_rule and material_condition registries for one data pack stack.
Parsing is lazy and memoized per identifier, the way import('../WorldgenData').WorldgenData handles density functions, and a reference cycle is reported rather than left to overflow the stack at sample time.
Constructors
Constructor
new MaterialRuleData(
source,densityFunction):MaterialRuleData
Defined in: surface/MaterialRule.ts:129
Parameters
source
densityFunction
(reference, path) => DensityFunctionNode
Resolves the density functions an ore_vein rule names.
Returns
MaterialRuleData
Accessors
conditionIds
Get Signature
get conditionIds():
string[]
Defined in: surface/MaterialRule.ts:141
The identifiers of every material condition in the stack.
Returns
string[]
ruleIds
Get Signature
get ruleIds():
string[]
Defined in: surface/MaterialRule.ts:136
The identifiers of every material rule in the stack.
Returns
string[]
Methods
condition()
condition(
reference):MaterialConditionNode
Defined in: surface/MaterialRule.ts:166
Parses a registered material condition, following its references.
Parameters
reference
string
Returns
Throws
When the identifier is missing, or when the references form a cycle.
parseCondition()
parseCondition(
source,path?):MaterialConditionNode
Defined in: surface/MaterialRule.ts:229
Parses one inline material condition document.
Parameters
source
unknown
A document, or a string naming a registered condition.
path?
string = '<material_condition>'
Returns
Throws
When the type is unknown or a field is missing.
parseRule()
parseRule(
source,path?):MaterialRuleNode
Defined in: surface/MaterialRule.ts:184
Parses one inline material rule document.
Parameters
source
unknown
A document, or a string naming a registered rule.
path?
string = '<material_rule>'
Returns
Throws
When the type is unknown or a field is missing. Nothing falls back to a no-op, so a schema change arrives as an error rather than as different terrain.
rule()
rule(
reference):MaterialRuleNode
Defined in: surface/MaterialRule.ts:150
Parses a registered material rule, following its references.
Parameters
reference
string
Returns
Throws
When the identifier is missing, or when the references form a cycle.