Class TrackingResourceSource

java.lang.Object
dev.lukebemish.dynamicassetgenerator.api.TrackingResourceSource
All Implemented Interfaces:
ResourceGenerationContext.ResourceSource

public class TrackingResourceSource extends Object implements ResourceGenerationContext.ResourceSource
A resource source that tracks the resources that have been accessed.
  • Method Details

    • getTouchedTextures

      public List<net.minecraft.resources.ResourceLocation> getTouchedTextures()
      Returns:
      the list of resources that have been touched by generators seeing this
    • of

      @Contract("_, _, _ -> new") public static TrackingResourceSource of(ResourceGenerationContext.ResourceSource delegate, String prefix, String suffix)
      Creates a new tracking resource source.
      Parameters:
      delegate - the delegate resource source
      prefix - the prefix to track resources within, such as "textures
      suffix - the suffix to track resources ending with, such as ".png"
    • getResource

      public @Nullable net.minecraft.server.packs.resources.IoSupplier<InputStream> getResource(@NonNull net.minecraft.resources.ResourceLocation location)
      Description copied from interface: ResourceGenerationContext.ResourceSource
      Attempts to get a resource at a given location, from the highest priority pack not provided by a ResourceCache.
      Specified by:
      getResource in interface ResourceGenerationContext.ResourceSource
      Parameters:
      location - the location to get the resource at
      Returns:
      a supplier for an input stream for the resource, or null if the resource does not exist
    • getResourceStack

      public List<net.minecraft.server.packs.resources.IoSupplier<InputStream>> getResourceStack(@NonNull net.minecraft.resources.ResourceLocation location)
      Description copied from interface: ResourceGenerationContext.ResourceSource
      Lists all resources within a given path, from highest to lowest priority.
      Specified by:
      getResourceStack in interface ResourceGenerationContext.ResourceSource
      Parameters:
      location - the location to list resources from
      Returns:
      a list of suppliers for input streams for the resources
    • listResources

      public Map<net.minecraft.resources.ResourceLocation,net.minecraft.server.packs.resources.IoSupplier<InputStream>> listResources(@NonNull String path, @NonNull Predicate<net.minecraft.resources.ResourceLocation> filter)
      Description copied from interface: ResourceGenerationContext.ResourceSource
      Lists all resources in a namespace that match a given filter, from the highest priority pack not provided by a ResourceCache.
      Specified by:
      listResources in interface ResourceGenerationContext.ResourceSource
      Parameters:
      path - the path to list resources in
      filter - a filter to apply to the resource locations
      Returns:
      a map of resource locations to suppliers for input streams for the resources
    • listResourceStacks

      public Map<net.minecraft.resources.ResourceLocation,List<net.minecraft.server.packs.resources.IoSupplier<InputStream>>> listResourceStacks(@NonNull String path, @NonNull Predicate<net.minecraft.resources.ResourceLocation> filter)
      Description copied from interface: ResourceGenerationContext.ResourceSource
      Lists all resources within a given path, from highest to lowest priority.
      Specified by:
      listResourceStacks in interface ResourceGenerationContext.ResourceSource
      Parameters:
      path - the path to list resources in
      filter - a filter to apply to the resource locations
      Returns:
      a map of resource locations to suppliers for input streams for the resources
    • getNamespaces

      public @NonNull Set<String> getNamespaces()
      Specified by:
      getNamespaces in interface ResourceGenerationContext.ResourceSource
      Returns:
      a set of all namespaces that have resources in this context