Class ResourceCacheManager

java.lang.Object
io.github.vampirestudios.vampirelib.api.datagen.ResourceCacheManager

@Internal public class ResourceCacheManager extends Object
Cache manager for resources.

This class handles caching the resource listing calls on a pack, pack type and namespace level.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ResourceCacheManager(boolean supportsReloading, String indexOnThreadConfigurationKey, BiFunction<net.minecraft.server.packs.PackType,String,List<Path>> pathBuilder)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getNamespaces(net.minecraft.server.packs.PackType type)
    Looks up all already indexed namespaces.
    boolean
    hasCached(net.minecraft.server.packs.PackType packType, String namespace)
    Indicates if the given namespace is completely cached for the given pack type.
    void
    index(String namespace)
    Invoked to trigger indexing of a given namespaces resources.
    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.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    Indicates if this cache manager requires the indexing of the file-tree to happen on the main thread.
    static boolean
    Indicates if the caching system is enabled or not.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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:
      true if the caching system is enabled, false otherwise.
    • shouldIndexOnThread

      public boolean shouldIndexOnThread()
      Indicates if this cache manager requires the indexing of the file-tree to happen on the main thread.
      Returns:
      true if the indexing of the file-tree should happen on the main thread, false otherwise.
    • shouldIndexOffThread

      @Deprecated(forRemoval=true, since="1.19.2") public boolean 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:
      true if the indexing of the file-tree should happen off the main thread, true otherwise.
    • index

      public void index(String namespace)
      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

      public Set<String> getNamespaces(net.minecraft.server.packs.PackType type)
      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

      public boolean hasCached(net.minecraft.server.packs.PackType packType, String namespace)
      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.