Class ResourceCacheManager.NamespacedResourceCacheManager

java.lang.Object
net.minecraftforge.resource.ResourceCacheManager.NamespacedResourceCacheManager
Enclosing class:
ResourceCacheManager

private static class ResourceCacheManager.NamespacedResourceCacheManager extends Object
A namespaced and pack type specific cache which the ResourceCacheManager can delegate the handling to.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • packType

      private final PackType packType
      The pack type this manager is responsible for.
    • namespace

      private final String namespace
      The namespace this manager is responsible for.
    • indexOnThread

      private final boolean indexOnThread
      Indicates if the indexing should run on-thread.
    • pathBuilder

      private final BiFunction<PackType,String,Path> pathBuilder
      The path builder to use.
    • pathFinder

      private final ResourceCacheManager.PathWalkerFactory pathFinder
      The path walker stream factory to use.
    • entriesByPathPrefix

      private final Map<String,List<ResourceCacheManager.ResourceCacheEntry>> entriesByPathPrefix
      The cache entries for this manager.
    • cacheLoaded

      private final AtomicBoolean cacheLoaded
      Indicates if the cache has been loaded successfully.
  • Constructor Details

    • NamespacedResourceCacheManager

      private NamespacedResourceCacheManager(PackType packType, String namespace, boolean indexOnThread, BiFunction<PackType,String,Path> pathBuilder, ResourceCacheManager.PathWalkerFactory pathFinder)
      Creates a new namespaced resource cache manager.
      Parameters:
      packType - The pack type that this manager handles.
      namespace - The namespace that this manager handles.
      indexOnThread - True to enable indexing on-thread.
      pathBuilder - The path builder to use.
      pathFinder - The path walker stream factory to use.
  • Method Details

    • index

      public void index()
      Triggers indexing of this manager.
    • doIndex

      private void doIndex()
      Performs the actual indexing of this manager. Can be invoked on- or off-thread.
    • injectIntoCache

      private void injectIntoCache(ResourceCacheManager.ResourceCacheEntry entry)
      Injects the given cache entry into the cache. By first injecting it into the parent of the entry (so the directory it resides in) and then recursively walking up.
      Parameters:
      entry - The entry to inject into the cache, must not be null.
    • injectIntoCache

      private void injectIntoCache(@Nullable @Nullable Path parentPath, ResourceCacheManager.ResourceCacheEntry entry)
      Injects the given cache entry into the cache, recursively into all of its parent paths.
      Parameters:
      parentPath - The parent path to inject into the cache, can be null. Null will be treated as the root path.
      entry - The entry to inject into the cache, must not be null.
    • getResources

      public Collection<ResourceLocation> getResources(Path inputPath, Predicate<ResourceLocation> filter)
      Looks up resources in the given input path prefix as well as those that match the filter.
      Parameters:
      inputPath - The input path prefix to look in.
      filter - The filter which the resources must match.
      Returns:
      A collection of resource location which match the given path prefix and who match the filter.
    • cacheLoaded

      public boolean cacheLoaded()
      Indicates if the cache of this manager has been loaded.
      Returns:
      True if the cache has been loaded, false otherwise.