java.lang.Object
net.lcc.sollib.api.common.data.runtime.condition.LoadCondition

public class LoadCondition extends Object
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:
 {
   // 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
    Modifier and Type
    Field
    Description
    static final net.minecraft.resources.ResourceLocation
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    configMatches(com.google.gson.JsonObject json)
     
    static boolean
    shouldLoad(com.google.gson.JsonObject condition)
     
    static boolean
    shouldLoad(net.minecraft.resources.ResourceLocation id, net.minecraft.server.packs.PackResources pack, net.minecraft.server.packs.PackType type)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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)