Class LoadCondition
java.lang.Object
net.lcc.sollib.api.common.data.runtime.condition.LoadCondition
Any datapack file can be given load conditions, and will only actually be read if they are met.
To do so, simply add a condition field to the file, like so:
- "dependency": Takes an extra mod argument. File will only be loaded if said namespace is running.
- "config": Takes an extra entry argument. File will only be loaded if the corresponding
- "and": Takes a list of conditions in a values field. Yields true only if every sub condition is true.
- "or": Takes a list of conditions in a values field. Yields true if at least one sub condition is true.
For example:
To do so, simply add a condition field to the file, like so:
{
// Here be the rest of your json file
"condition": {
"type": conditiontype
}
}
There currently are 5 types of conditions: - "dependency": Takes an extra mod argument. File will only be loaded if said namespace is running.
- "config": Takes an extra entry argument. File will only be loaded if the corresponding
ConfigEntry evaluates to true.
- "not": Takes another condition in a value field and inverts it. - "and": Takes a list of conditions in a values field. Yields true only if every sub condition is true.
- "or": Takes a list of conditions in a values field. Yields true if at least one sub condition is true.
For example:
{
"message": "Hello World!",
"sollib:load_condition": {
"type": "and",
"values": [
{
"type": "config",
"entry": "sollib/test:test_category.nested.exists"
},
{
"type": "not",
"value: {
"type": "dependency",
"mod": "fabric"
}
}
]
}
}
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanconfigMatches(com.google.gson.JsonObject json) static booleanshouldLoad(com.google.gson.JsonObject condition) static booleanshouldLoad(net.minecraft.resources.ResourceLocation id, net.minecraft.server.packs.PackResources pack, net.minecraft.server.packs.PackType type)
-
Field Details
-
CONFIG
public static final net.minecraft.resources.ResourceLocation CONFIG
-
-
Constructor Details
-
LoadCondition
public LoadCondition()
-
-
Method Details
-
configMatches
public static boolean configMatches(com.google.gson.JsonObject json) -
shouldLoad
public static boolean shouldLoad(net.minecraft.resources.ResourceLocation id, net.minecraft.server.packs.PackResources pack, net.minecraft.server.packs.PackType type) -
shouldLoad
public static boolean shouldLoad(com.google.gson.JsonObject condition)
-