Class ResourceConditions
java.lang.Object
net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditions
Contains default resource conditions and the condition registry.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceCondition
allModsLoaded
(String... modIds) A condition that passes if each of the specifiedmodIds
are loaded.static ResourceCondition
A condition that always passes.static ResourceCondition
and
(ResourceCondition... conditions) A condition that passes if each of theconditions
passes.static ResourceCondition
anyModsLoaded
(String... modIds) A condition that passes if any of the specifiedmodIds
are loaded.static ResourceCondition
featuresEnabled
(FeatureFlag... features) static ResourceCondition
featuresEnabled
(Identifier... features) A condition that passes if each of thefeatures
are enabled.static ResourceConditionType
<?> static ResourceCondition
not
(ResourceCondition condition) A condition that passes ifcondition
does not pass.static ResourceCondition
or
(ResourceCondition... conditions) A condition that passes if any of theconditions
passes.static void
register
(ResourceConditionType<?> condition) Registerscondition
.static <T> ResourceCondition
registryContains
(RegistryKey<? extends Registry<T>> registry, Identifier... entries) static <T> ResourceCondition
registryContains
(RegistryKey<T>... entries) A condition that passes if each of theentries
exist.static <T> ResourceCondition
tagsPopulated
(RegistryKey<? extends Registry<T>> registry, TagKey<T>... tags) static <T> ResourceCondition
tagsPopulated
(TagKey<T>... tags) A condition that passes if each of thetags
exist.
-
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
- ifcondition
is already registered
-
getConditionType
- Returns:
- the condition with ID
id
, ornull
if there is no such condition
-
alwaysTrue
A condition that always passes. Has IDfabric:true
. -
not
A condition that passes ifcondition
does not pass. Has IDfabric:not
and takes one field,value
, which is a resource condition. -
and
A condition that passes if each of theconditions
passes. Has IDfabric:and
and 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 theconditions
passes. Has IDfabric:or
and 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 specifiedmodIds
are loaded. Has IDall_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
A condition that passes if any of the specifiedmodIds
are loaded. Has IDany_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
A condition that passes if each of thetags
exist. This does not check if those tags have any entries. Has IDtags_populated
and 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 thefeatures
are enabled. Has IDfeatures_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
- See Also:
-
registryContains
A condition that passes if each of theentries
exist. The entries may be from static or dynamic registries. Has IDregistry_contains
and 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:
-