Class ResourceConditions

java.lang.Object
net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditions

public final class ResourceConditions extends Object
Contains default resource conditions and the condition registry.
  • Field Details

    • CONDITIONS_KEY

      public static final String CONDITIONS_KEY
      The JSON key for resource conditions, "fabric:load_conditions".
      See Also:
  • Method Details

    • register

      public static void register(ResourceConditionType<?> condition)
      Registers condition.
      Parameters:
      condition - the condition to register
      Throws:
      IllegalArgumentException - if condition is already registered
    • getConditionType

      public static ResourceConditionType<?> getConditionType(Identifier id)
      Returns:
      the condition with ID id, or null if there is no such condition
    • alwaysTrue

      public static ResourceCondition alwaysTrue()
      A condition that always passes. Has ID fabric:true.
    • not

      public static ResourceCondition not(ResourceCondition condition)
      A condition that passes if condition does not pass. Has ID fabric:not and takes one field, value, which is a resource condition.
    • and

      public static ResourceCondition and(ResourceCondition... conditions)
      A condition that passes if each of the conditions passes. Has ID fabric:and and takes one field, values, which is a list of resource conditions. If there are no conditions to check, it always passes.
    • or

      public static ResourceCondition or(ResourceCondition... conditions)
      A condition that passes if any of the conditions passes. Has ID fabric:or and takes one field, values, which is a list of resource conditions. If there are no conditions to check, it always fails.
    • allModsLoaded

      public static ResourceCondition allModsLoaded(String... modIds)
      A condition that passes if each of the specified modIds are loaded. Has ID all_mods_loaded and takes one field, values, which is a list of strings indicating mod IDs. If there are no IDs to check, it always passes.
    • anyModsLoaded

      public static ResourceCondition anyModsLoaded(String... modIds)
      A condition that passes if any of the specified modIds are loaded. Has ID any_mods_loaded and takes one field, values, which is a list of strings indicating mod IDs. If there are no IDs to check, it always fails.
    • tagsPopulated

      @SafeVarargs public static <T> ResourceCondition tagsPopulated(TagKey<T>... tags)
      A condition that passes if each of the tags exist. This does not check if those tags have any entries. Has ID tags_populated and takes two fields: registry, which is the ID of the registry the tag is for, and values, which is a list of the tag IDs to check. If there are no IDs to check, it always passes, including in cases where a nonexistent registry is specified.
      Type Parameters:
      T - the type of the tag values
      Implementation Note:
      Because tags are loaded after loot tables (and predicates/item modifiers), these resources do not support this condition. In those cases, this condition logs a warning and always fails.
    • tagsPopulated

      @SafeVarargs public static <T> ResourceCondition tagsPopulated(RegistryKey<? extends Registry<T>> registry, TagKey<T>... tags)
      Type Parameters:
      T - the type of the tag values
      See Also:
    • featuresEnabled

      public static ResourceCondition featuresEnabled(Identifier... features)
      A condition that passes if each of the features are enabled. Has ID features_enabled and takes one field, features, which is a list of the feature IDs. If there are no IDs to check, it always passes. If an unknown feature is specified, it always fails.
    • featuresEnabled

      public static ResourceCondition featuresEnabled(FeatureFlag... features)
      See Also:
    • registryContains

      @SafeVarargs public static <T> ResourceCondition registryContains(RegistryKey<T>... entries)
      A condition that passes if each of the entries exist. The entries may be from static or dynamic registries. Has ID registry_contains and takes two fields: registry, which is the ID of the registry, and values, which is a list of IDs to check. If there are no IDs to check, it always passes, including in cases where a nonexistent registry is specified.
      Type Parameters:
      T - the type of the tag values
    • registryContains

      public static <T> ResourceCondition registryContains(RegistryKey<? extends Registry<T>> registry, Identifier... entries)
      Type Parameters:
      T - the type of the tag values
      See Also: