Class ResourcePack
- java.lang.Object
-
- net.minecraft.modding.api.game.client.resources.ResourcePack
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
AssetsResourcePack,DelegatingResourcePack,EmptyResourcePack,MultiResourcePack,PathResourcePack
public abstract class ResourcePack extends java.lang.Object implements java.io.Closeable
-
-
Constructor Summary
Constructors Constructor Description ResourcePack()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()abstract java.util.stream.Stream<Resource>findResources(@Nullable java.lang.String namespace, java.lang.String directory, java.lang.String extension)Finds allResources that match the given query.java.lang.StringgetDescription()abstract java.lang.StringgetName()abstract java.util.Optional<Resource>getResource(ResourceLocation location)Returns aResourcethat exists at the given location.abstract java.util.stream.Stream<Resource>getResources(java.lang.String path)Returns allResources that are at the given path, regardless of namespace.java.util.stream.Stream<Resource>getResources(ResourceLocation location)Returns allResources that match the given location.byte @Nullable []getThumbnail()booleanisLegacyTexturePack()Signals whether callers should search for assets in legacy locations.
-
-
-
Method Detail
-
getName
public abstract java.lang.String getName()
-
getDescription
public java.lang.String getDescription()
-
getThumbnail
public byte @Nullable [] getThumbnail()
-
isLegacyTexturePack
public boolean isLegacyTexturePack()
Signals whether callers should search for assets in legacy locations.- Returns:
- If this
ResourcePackrepresents a legacy texture pack format.
-
getResources
public java.util.stream.Stream<Resource> getResources(ResourceLocation location)
Returns allResources that match the given location. An empty namespace will search outside theassets/dir. This may return multiple resources in the case of aMultiResourcePack.- Parameters:
location- The exact location of the resources.- Returns:
- A stream that iterates over the
Resources.
-
getResource
public abstract java.util.Optional<Resource> getResource(ResourceLocation location)
Returns aResourcethat exists at the given location. An empty namespace will search outside theassets/dir.- Parameters:
location- The exact location of the resource.- Returns:
- A present optional if the resource exists,
Optional.empty()otherwise.
-
getResources
public abstract java.util.stream.Stream<Resource> getResources(java.lang.String path)
Returns allResources that are at the given path, regardless of namespace. This includes the empty namespace only ifisLegacyTexturePack()returns true.- Parameters:
path- The path to search at. All namespaces will be checked.- Returns:
- A stream that iterates over the
Resources.
-
findResources
public abstract java.util.stream.Stream<Resource> findResources(@Nullable @Nullable java.lang.String namespace, java.lang.String directory, java.lang.String extension)
Finds allResources that match the given query. UnlikegetResources(ResourceLocation), this will only return the first occurrence of a resource in the case of aMultiResourcePack.- Parameters:
namespace-nullto 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.
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-