Package net.minecraftforge.resource
Class ResourceCacheManager.NamespacedResourceCacheManager
java.lang.Object
net.minecraftforge.resource.ResourceCacheManager.NamespacedResourceCacheManager
- Enclosing class:
- ResourceCacheManager
A namespaced and pack type specific cache which the
ResourceCacheManager
can delegate the handling to.-
Field Summary
Modifier and TypeFieldDescriptionprivate final AtomicBoolean
Indicates if the cache has been loaded successfully.private final Map<String,
List<ResourceCacheManager.ResourceCacheEntry>> The cache entries for this manager.private final boolean
Indicates if the indexing should run on-thread.private static final org.slf4j.Logger
private final String
The namespace this manager is responsible for.private final PackType
The pack type this manager is responsible for.private final BiFunction<PackType,
String, Path> The path builder to use.private final ResourceCacheManager.PathWalkerFactory
The path walker stream factory to use. -
Constructor Summary
ModifierConstructorDescriptionprivate
NamespacedResourceCacheManager
(PackType packType, String namespace, boolean indexOnThread, BiFunction<PackType, String, Path> pathBuilder, ResourceCacheManager.PathWalkerFactory pathFinder) Creates a new namespaced resource cache manager. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates if the cache of this manager has been loaded.private void
doIndex()
Performs the actual indexing of this manager.getResources
(Path inputPath, Predicate<ResourceLocation> filter) Looks up resources in the given input path prefix as well as those that match the filter.void
index()
Triggers indexing of this manager.private void
injectIntoCache
(@Nullable Path parentPath, ResourceCacheManager.ResourceCacheEntry entry) Injects the given cache entry into the cache, recursively into all of its parent paths.private void
Injects the given cache entry into the cache.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
packType
The pack type this manager is responsible for. -
namespace
The namespace this manager is responsible for. -
indexOnThread
private final boolean indexOnThreadIndicates if the indexing should run on-thread. -
pathBuilder
The path builder to use. -
pathFinder
The path walker stream factory to use. -
entriesByPathPrefix
The cache entries for this manager. -
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
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.
-