Class AssetsResourcePack

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class AssetsResourcePack
    extends ResourcePack
    • Constructor Detail

      • AssetsResourcePack

        public AssetsResourcePack​(java.nio.file.Path assetsDir,
                                  java.lang.String assetIndex)
                           throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getMissing

        public java.util.Set<java.lang.String> getMissing()
      • isLegacyTexturePack

        public boolean isLegacyTexturePack()
        Description copied from class: ResourcePack
        Signals whether callers should search for assets in legacy locations.
        Overrides:
        isLegacyTexturePack in class ResourcePack
        Returns:
        If this ResourcePack represents a legacy texture pack format.
      • getResource

        public java.util.Optional<Resource> getResource​(ResourceLocation location)
        Description copied from class: ResourcePack
        Returns a Resource that exists at the given location. An empty namespace will search outside the assets/ dir.
        Specified by:
        getResource in class ResourcePack
        Parameters:
        location - The exact location of the resource.
        Returns:
        A present optional if the resource exists, Optional.empty() otherwise.
      • getResources

        public java.util.stream.Stream<Resource> getResources​(java.lang.String path)
        Description copied from class: ResourcePack
        Returns all Resources that are at the given path, regardless of namespace. This includes the empty namespace only if ResourcePack.isLegacyTexturePack() returns true.
        Specified by:
        getResources in class ResourcePack
        Parameters:
        path - The path to search at. All namespaces will be checked.
        Returns:
        A stream that iterates over the Resources.
      • getMaybeMissingResource

        public java.util.Optional<Resource> getMaybeMissingResource​(java.lang.String path)
      • findResources

        public java.util.stream.Stream<Resource> findResources​(@Nullable
                                                               @Nullable java.lang.String namespace,
                                                               java.lang.String directory,
                                                               java.lang.String extension)
        Description copied from class: ResourcePack
        Finds all Resources that match the given query. Unlike ResourcePack.getResources(ResourceLocation), this will only return the first occurrence of a resource in the case of a MultiResourcePack.
        Specified by:
        findResources in class ResourcePack
        Parameters:
        namespace - null to search all namespaces. A specific namespace to search otherwise.
        directory - The directory to search through. End with /** to search recursively.
        extension - The extension to require files to end with. Should be prefixed with a dot (e.g. ".json"). Use "" to ignore file extension.
        Returns:
        A stream that iterates over all the found Resources.
      • downloadIndex

        public static void downloadIndex​(java.nio.file.Path assetsDir,
                                         java.lang.String assetIndex)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • downloadMissing

        public void downloadMissing​(java.nio.file.Path assetsDir,
                                    java.lang.String assetIndex,
                                    java.util.function.DoubleConsumer progressConsumer)
                             throws java.io.IOException
        Throws:
        java.io.IOException