Interface ResourceGenerator
- All Superinterfaces:
InputStreamSource,PathAwareInputStreamSource
- All Known Implementing Classes:
DummyGenerator,TextureGenerator,TextureMetaGenerator
Represents a set of instructions to generate any number of resources, to be read from JSON.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<ResourceGenerator> static final String -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec<? extends ResourceGenerator> codec()default @Nullable StringcreateCacheKey(net.minecraft.resources.ResourceLocation outRl, ResourceGenerationContext context) Create a key that can be uniquely used to identify the resource this generator will generate.default <T> @NonNull com.mojang.serialization.DataResult<T> persistentCacheData(com.mojang.serialization.DynamicOps<T> ops, net.minecraft.resources.ResourceLocation location, ResourceGenerationContext context) Create a key that can be uniquely used to identify the resource this generator will generate.static voidregister(net.minecraft.resources.ResourceLocation rl, com.mojang.serialization.MapCodec<? extends ResourceGenerator> reader) Registers a new resource generator type.Methods inherited from interface dev.lukebemish.dynamicassetgenerator.api.InputStreamSource
getMethods inherited from interface dev.lukebemish.dynamicassetgenerator.api.PathAwareInputStreamSource
getLocations
-
Field Details
-
PERSISTENT_CACHE_KEY
- See Also:
-
CODEC
-
-
Method Details
-
register
static void register(net.minecraft.resources.ResourceLocation rl, com.mojang.serialization.MapCodec<? extends ResourceGenerator> reader) Registers a new resource generator type.- Parameters:
rl- The resource location to register the generator under; becomes the"type"field in JSON.reader- The codec used to deserialize the generator from JSON.
-
codec
com.mojang.serialization.MapCodec<? extends ResourceGenerator> codec()- Returns:
- A codec that can serialize this resource generator.
-
createCacheKey
@NonExtendable default @Nullable String createCacheKey(net.minecraft.resources.ResourceLocation outRl, ResourceGenerationContext context) Description copied from interface:InputStreamSourceCreate a key that can be uniquely used to identify the resource this generator will generate. Note that this is used for caching across reloads, and so should incorporate any resources that may be used to generate the resource. If this is not possible, return null.- Specified by:
createCacheKeyin interfaceInputStreamSource- Parameters:
outRl- the resource location that will be generatedcontext- the context that the resource will be generated in. Resources can safely be accessed in this context- Returns:
- a key that can be used to uniquely identify the resource, or null if this is not possible
-
persistentCacheData
@Experimental default <T> @NonNull com.mojang.serialization.DataResult<T> persistentCacheData(com.mojang.serialization.DynamicOps<T> ops, net.minecraft.resources.ResourceLocation location, ResourceGenerationContext context) Create a key that can be uniquely used to identify the resource this generator will generate. Note that this is used for caching across reloads, and so should incorporate any resources that may be used to generate the resource. If this is not possible, return null.- Parameters:
ops- DynamicOps to encode the unique key with.location- the resource location that will be generatedcontext- the context that the resource will be generated in. Resources can safely be accessed in this context- Returns:
- a key that can be used to uniquely identify the resource, or null if this is not possible
-