Package net.minecraftforge.resource
Class PathPackResources
java.lang.Object
net.minecraft.server.packs.AbstractPackResources
net.minecraftforge.resource.PathPackResources
- All Implemented Interfaces:
AutoCloseable
,PackResources
,IForgePackResources
Defines a resource pack from an arbitrary Path.
This is primarily intended to support including optional resource packs inside a mod, such as to have alternative textures to use along with Programmer Art, or optional alternative recipes for compatibility ot to replace vanilla recipes.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ResourceCacheManager
private final String
private final Path
Fields inherited from class net.minecraft.server.packs.AbstractPackResources
file
Fields inherited from interface net.minecraft.server.packs.PackResources
METADATA_EXTENSION, PACK_META
-
Constructor Summary
ConstructorDescriptionPathPackResources
(String packName, Path source) Constructs a java.nio.Path-based resource pack. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
getName()
Returns the identifying name for the pack.getNamespaces
(PackType type) protected InputStream
getResource
(String name) getResource
(PackType type, ResourceLocation location) getResources
(PackType type, String resourceNamespace, String pathIn, Predicate<ResourceLocation> filter) Returns the source path containing the resource pack.protected boolean
hasResource
(String name) boolean
hasResource
(PackType type, ResourceLocation location) void
void
initForNamespace
(String namespace) protected Path
Implement to return a file or folder path for the given set of path components.toString()
Methods inherited from class net.minecraft.server.packs.AbstractPackResources
getMetadataFromStream, getMetadataSection, getRelativePath, getRootResource, logWarning
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minecraftforge.common.extensions.IForgePackResources
isHidden
-
Field Details
-
source
-
packName
-
cacheManager
-
-
Constructor Details
-
PathPackResources
Constructs a java.nio.Path-based resource pack.- Parameters:
packName
- the identifying name of the pack. This name should be unique within the pack finder, preferably the name of the file or folder containing the resources.source
- the root path of the pack. This needs to point to the folder that contains "assets" and/or "data", not the asset folder itself!
-
-
Method Details
-
initForNamespace
-
init
-
getSource
Returns the source path containing the resource pack. This is used for error display.- Returns:
- the root path of the resources.
-
getName
Returns the identifying name for the pack.- Specified by:
getName
in interfacePackResources
- Overrides:
getName
in classAbstractPackResources
- Returns:
- the identifier of the pack.
-
resolve
Implement to return a file or folder path for the given set of path components.- Parameters:
paths
- One or more path strings to resolve. Can include slash-separated paths.- Returns:
- the resulting path, which may not exist.
-
getResource
- Specified by:
getResource
in classAbstractPackResources
- Throws:
IOException
-
hasResource
- Specified by:
hasResource
in classAbstractPackResources
-
getResources
public Collection<ResourceLocation> getResources(PackType type, String resourceNamespace, String pathIn, Predicate<ResourceLocation> filter) -
getNamespaces
-
getNamespacesFromDisk
-
getResource
- Specified by:
getResource
in interfacePackResources
- Overrides:
getResource
in classAbstractPackResources
- Throws:
IOException
-
hasResource
- Specified by:
hasResource
in interfacePackResources
- Overrides:
hasResource
in classAbstractPackResources
-
close
public void close() -
toString
- Overrides:
toString
in classAbstractPackResources
-