java.lang.Object
dev.lukebemish.dynamicassetgenerator.api.client.generators.TextureGenerator
All Implemented Interfaces:
InputStreamSource, PathAwareInputStreamSource, ResourceGenerator

public class TextureGenerator extends Object implements ResourceGenerator
A resource generator that generates a PNG texture as specified by a TexSource. As TexSources are cached in memory to avoid regenerating duplicate parts of a texture, this generator should only be used with a AssetResourceCache.
  • Field Details

    • CODEC

      public static final com.mojang.serialization.MapCodec<TextureGenerator> CODEC
  • Constructor Details

    • TextureGenerator

      public TextureGenerator(@NonNull net.minecraft.resources.ResourceLocation outputLocation, @NonNull TexSource source)
      Parameters:
      outputLocation - the location to generate a texture at, excluding the "textures/" prefix or ".png" extension
      source - the texture source to generate
  • Method Details

    • get

      public net.minecraft.server.packs.resources.IoSupplier<InputStream> get(net.minecraft.resources.ResourceLocation outRl, ResourceGenerationContext context)
      Description copied from interface: InputStreamSource
      Gets an input stream for the given resource location.
      Specified by:
      get in interface InputStreamSource
      Parameters:
      outRl - ResourceLocation to get the input stream for.
      context - ResourceGenerationContext containing information about when and where the resource is being generated.
      Returns:
      Supplier for an InputStream for the location. Should be null if the resource cannot be loaded.
    • persistentCacheData

      public <T> @NonNull com.mojang.serialization.DataResult<T> persistentCacheData(com.mojang.serialization.DynamicOps<T> ops, net.minecraft.resources.ResourceLocation location, ResourceGenerationContext context)
      Description copied from interface: ResourceGenerator
      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:
      persistentCacheData in interface ResourceGenerator
      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
    • getLocations

      public @NonNull Set<net.minecraft.resources.ResourceLocation> getLocations(ResourceGenerationContext context)
      Specified by:
      getLocations in interface PathAwareInputStreamSource
      Returns:
      the locations that this InputStreamSource can provide resources at.
    • codec

      public com.mojang.serialization.MapCodec<? extends ResourceGenerator> codec()
      Specified by:
      codec in interface ResourceGenerator
      Returns:
      A codec that can serialize this resource generator.