Class ResourceCacheManager
java.lang.Object
io.github.vampirestudios.vampirelib.api.datagen.ResourceCacheManager
Cache manager for resources.
This class handles caching the resource listing calls on a pack, pack type and namespace level.
-
Constructor Summary
ConstructorsConstructorDescriptionResourceCacheManager(boolean supportsReloading, String indexOnThreadConfigurationKey, BiFunction<net.minecraft.server.packs.PackType, String, List<Path>> pathBuilder) -
Method Summary
Modifier and TypeMethodDescriptiongetNamespaces(net.minecraft.server.packs.PackType type) Looks up all already indexed namespaces.booleanIndicates if the given namespace is completely cached for the given pack type.voidInvoked to trigger indexing of a given namespaces resources.voidlistResources(net.minecraft.server.packs.PackType type, String resourceNamespace, Path inputPath, BiFunction<net.minecraft.server.packs.PackType, net.minecraft.resources.ResourceLocation, net.minecraft.server.packs.resources.IoSupplier<InputStream>> resourceFunction, net.minecraft.server.packs.PackResources.ResourceOutput resourceOutput) Lists the cached resources for the given pack type, namespace, path prefix and filter.booleanDeprecated, for removal: This API element is subject to removal in a future version.booleanIndicates if this cache manager requires the indexing of the file-tree to happen on the main thread.static booleanIndicates if the caching system is enabled or not.
-
Constructor Details
-
ResourceCacheManager
public ResourceCacheManager(boolean supportsReloading, String indexOnThreadConfigurationKey, BiFunction<net.minecraft.server.packs.PackType, String, List<Path>> pathBuilder)
-
-
Method Details
-
shouldUseCache
public static boolean shouldUseCache()Indicates if the caching system is enabled or not.- Returns:
trueif the caching system is enabled,falseotherwise.
-
shouldIndexOnThread
public boolean shouldIndexOnThread()Indicates if this cache manager requires the indexing of the file-tree to happen on the main thread.- Returns:
trueif the indexing of the file-tree should happen on the main thread,falseotherwise.
-
shouldIndexOffThread
Deprecated, for removal: This API element is subject to removal in a future version.Indicates if this cache manager requires the indexing of the file-tree to happen off the main thread.- Returns:
trueif the indexing of the file-tree should happen off the main thread,trueotherwise.
-
index
Invoked to trigger indexing of a given namespaces resources.- Parameters:
namespace- The namespace to index.
-
listResources
public void listResources(net.minecraft.server.packs.PackType type, String resourceNamespace, Path inputPath, BiFunction<net.minecraft.server.packs.PackType, net.minecraft.resources.ResourceLocation, net.minecraft.server.packs.resources.IoSupplier<InputStream>> resourceFunction, net.minecraft.server.packs.PackResources.ResourceOutput resourceOutput) Lists the cached resources for the given pack type, namespace, path prefix and filter.- Parameters:
type- The type of pack to look up in (data or resource)resourceNamespace- The namespace of the resources to look up.inputPath- The input path prefix to check for.resourceFunction- The function that turns a resource location into an input stream supplier.resourceOutput- The resource output to accept resources.
-
getNamespaces
Looks up all already indexed namespaces. Note even though a namespace might be returned from this method, it does not mean that the indexing has completed on that namespace if it is running off-thread.- Parameters:
type- The type of the pack to get the namespaces for.- Returns:
- The namespaces which are known for the given pack type.
-
hasCached
Indicates if the given namespace is completely cached for the given pack type.- Parameters:
packType- The pack type to check.namespace- The namespace to check.- Returns:
- True if the namespace is completely cached for the given pack type.
-