Interface ResourceGenerationContext.ResourceSource

All Known Implementing Classes:
TrackingResourceSource
Enclosing interface:
ResourceGenerationContext

public static interface ResourceGenerationContext.ResourceSource
  • Method Details

    • blind

      Returns:
      a resource source which can read no resources
    • getResource

      @Nullable net.minecraft.server.packs.resources.IoSupplier<InputStream> getResource(@NonNull net.minecraft.resources.ResourceLocation location)
      Attempts to get a resource at a given location, from the highest priority pack not provided by a ResourceCache.
      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

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

      Map<net.minecraft.resources.ResourceLocation,net.minecraft.server.packs.resources.IoSupplier<InputStream>> listResources(@NonNull String path, @NonNull Predicate<net.minecraft.resources.ResourceLocation> filter)
      Lists all resources in a namespace that match a given filter, from the highest priority pack not provided by a ResourceCache.
      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

      Map<net.minecraft.resources.ResourceLocation,List<net.minecraft.server.packs.resources.IoSupplier<InputStream>>> listResourceStacks(@NonNull String path, @NonNull Predicate<net.minecraft.resources.ResourceLocation> filter)
      Lists all resources within a given path, from highest to lowest priority.
      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

      @NonNull Set<String> getNamespaces()
      Returns:
      a set of all namespaces that have resources in this context
    • filtered

      static ResourceGenerationContext.ResourceSource filtered(Predicate<String> allowedPacks, net.minecraft.server.packs.PackType type)
      A default implementation which exposes resources captured during pack load. Should not be accessed before packs are available, and must be reset every pack reload by reconstructing the listener.
      Parameters:
      allowedPacks - which packs to select from the captured packs; useful to avoid recursive generation
      type - the type of captured pack to target
      Returns:
      a resource source based on the captured packs available when first invoked
    • filtered

      static ResourceGenerationContext.ResourceSource filtered(Predicate<String> allowedPacks, net.minecraft.server.packs.PackType type, Supplier<Stream<net.minecraft.server.packs.PackResources>> packResources)
      A default implementation which uses a lazy-loaded list of packs. Should be discarded and re-created when the underlying list would change.
      Parameters:
      allowedPacks - which packs to select from the captured packs; useful to avoid recursive generation
      type - the type of pack to target
      packResources - supplies a list of packs to provide resources from
      Returns:
      a resource based on the supplied packs available when first invoked
    • fallback

      Creates a source which checks the provided fallback source if a resource is not found in this source.
      Parameters:
      fallback - the source to check if a resource is not found in this source
      Returns:
      a resource source that falls back to the provided source
    • of

      static ResourceGenerationContext.ResourceSource of(net.minecraft.server.packs.PackType type, Supplier<Stream<net.minecraft.server.packs.PackResources>> resources)
      A default implementation which uses a lazy-loaded list of packs. Should be discarded and re-created when the underlying list would change.
      Parameters:
      type - the type of pack to target
      resources - supplies a list of packs to provide resources from
      Returns:
      a resource based on the supplied packs available when first invoked