Interface ResourceGenerator

All Superinterfaces:
InputStreamSource, PathAwareInputStreamSource
All Known Implementing Classes:
DummyGenerator, TextureGenerator, TextureMetaGenerator

public interface ResourceGenerator extends PathAwareInputStreamSource
Represents a set of instructions to generate any number of resources, to be read from JSON.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<ResourceGenerator>
     
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.mojang.serialization.MapCodec<? extends ResourceGenerator>
     
    default @Nullable String
    createCacheKey(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 void
    register(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

    get

    Methods inherited from interface dev.lukebemish.dynamicassetgenerator.api.PathAwareInputStreamSource

    getLocations
  • Field Details

  • 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: InputStreamSource
      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.
      Specified by:
      createCacheKey in interface InputStreamSource
      Parameters:
      outRl - the resource location that will be generated
      context - 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 generated
      context - 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