Class ResourceConditions
java.lang.Object
net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditions
Contains default resource conditions and the condition registry.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceConditionallModsLoaded(String... modIds) A condition that passes if each of the specifiedmodIdsare loaded.static ResourceConditionA condition that always passes.static ResourceConditionand(ResourceCondition... conditions) A condition that passes if each of theconditionspasses.static ResourceConditionanyModsLoaded(String... modIds) A condition that passes if any of the specifiedmodIdsare loaded.static ResourceConditionfeaturesEnabled(FeatureFlag... features) static ResourceConditionfeaturesEnabled(Identifier... features) A condition that passes if each of thefeaturesare enabled.static ResourceConditionType<?> static ResourceConditionnot(ResourceCondition condition) A condition that passes ifconditiondoes not pass.static ResourceConditionor(ResourceCondition... conditions) A condition that passes if any of theconditionspasses.static voidregister(ResourceConditionType<?> condition) Registerscondition.static <T> ResourceConditionregistryContains(RegistryKey<? extends Registry<T>> registry, Identifier... entries) static <T> ResourceConditionregistryContains(RegistryKey<T>... entries) A condition that passes if each of theentriesexist.static <T> ResourceConditiontagsPopulated(RegistryKey<? extends Registry<T>> registry, TagKey<T>... tags) static <T> ResourceConditiontagsPopulated(TagKey<T>... tags) A condition that passes if each of thetagsexist.
-
Field Details
-
CONDITIONS_KEY
The JSON key for resource conditions, "fabric:load_conditions".- See Also:
-
OVERLAYS_KEY
The JSON key for conditional overlays in pack.mcmeta files.- See Also:
-
-
Method Details
-
register
Registerscondition.- Parameters:
condition- the condition to register- Throws:
IllegalArgumentException- ifconditionis already registered
-
getConditionType
- Returns:
- the condition with ID
id, ornullif there is no such condition
-
alwaysTrue
A condition that always passes. Has IDfabric:true. -
not
A condition that passes ifconditiondoes not pass. Has IDfabric:notand takes one field,value, which is a resource condition. -
and
A condition that passes if each of theconditionspasses. Has IDfabric:andand takes one field,values, which is a list of resource conditions. If there are no conditions to check, it always passes. -
or
A condition that passes if any of theconditionspasses. Has IDfabric:orand takes one field,values, which is a list of resource conditions. If there are no conditions to check, it always fails. -
allModsLoaded
A condition that passes if each of the specifiedmodIdsare loaded. Has IDall_mods_loadedand takes one field,values, which is a list of strings indicating mod IDs. If there are no IDs to check, it always passes. -
anyModsLoaded
A condition that passes if any of the specifiedmodIdsare loaded. Has IDany_mods_loadedand takes one field,values, which is a list of strings indicating mod IDs. If there are no IDs to check, it always fails. -
tagsPopulated
A condition that passes if each of thetagsexist. This does not check if those tags have any entries. Has IDtags_populatedand takes two fields:registry, which is the ID of the registry the tag is for, andvalues, 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
A condition that passes if each of thefeaturesare enabled. Has IDfeatures_enabledand 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
- See Also:
-
registryContains
A condition that passes if each of theentriesexist. The entries may be from static or dynamic registries. Has IDregistry_containsand takes two fields:registry, which is the ID of the registry, andvalues, 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:
-