Class TrackingResourceSource
java.lang.Object
dev.lukebemish.dynamicassetgenerator.api.TrackingResourceSource
- All Implemented Interfaces:
ResourceGenerationContext.ResourceSource
public class TrackingResourceSource
extends Object
implements ResourceGenerationContext.ResourceSource
A resource source that tracks the resources that have been accessed.
-
Method Summary
Modifier and TypeMethodDescription@Nullable net.minecraft.server.packs.resources.IoSupplier<InputStream> getResource(@NonNull net.minecraft.resources.ResourceLocation location) Attempts to get a resource at a given location, from the highest priority pack not provided by aResourceCache.List<net.minecraft.server.packs.resources.IoSupplier<InputStream>> getResourceStack(@NonNull net.minecraft.resources.ResourceLocation location) Lists all resources within a given path, from highest to lowest priority.List<net.minecraft.resources.ResourceLocation> Map<net.minecraft.resources.ResourceLocation, net.minecraft.server.packs.resources.IoSupplier<InputStream>> listResources(@NonNull String path, @NonNull Predicate<net.minecraft.resources.ResourceLocation> filter) Lists all resources in a namespace that match a given filter, from the highest priority pack not provided by aResourceCache.Map<net.minecraft.resources.ResourceLocation, List<net.minecraft.server.packs.resources.IoSupplier<InputStream>>> listResourceStacks(@NonNull String path, @NonNull Predicate<net.minecraft.resources.ResourceLocation> filter) Lists all resources within a given path, from highest to lowest priority.static TrackingResourceSourceof(ResourceGenerationContext.ResourceSource delegate, String prefix, String suffix) Creates a new tracking resource source.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.lukebemish.dynamicassetgenerator.api.ResourceGenerationContext.ResourceSource
fallback
-
Method Details
-
getTouchedTextures
- Returns:
- the list of resources that have been touched by generators seeing this
-
of
@Contract("_, _, _ -> new") public static TrackingResourceSource of(ResourceGenerationContext.ResourceSource delegate, String prefix, String suffix) Creates a new tracking resource source.- Parameters:
delegate- the delegate resource sourceprefix- the prefix to track resources within, such as"texturessuffix- the suffix to track resources ending with, such as".png"
-
getResource
public @Nullable net.minecraft.server.packs.resources.IoSupplier<InputStream> getResource(@NonNull net.minecraft.resources.ResourceLocation location) Description copied from interface:ResourceGenerationContext.ResourceSourceAttempts to get a resource at a given location, from the highest priority pack not provided by aResourceCache.- Specified by:
getResourcein interfaceResourceGenerationContext.ResourceSource- Parameters:
location- the location to get the resource at- Returns:
- a supplier for an input stream for the resource, or null if the resource does not exist
-
getResourceStack
public List<net.minecraft.server.packs.resources.IoSupplier<InputStream>> getResourceStack(@NonNull net.minecraft.resources.ResourceLocation location) Description copied from interface:ResourceGenerationContext.ResourceSourceLists all resources within a given path, from highest to lowest priority.- Specified by:
getResourceStackin interfaceResourceGenerationContext.ResourceSource- Parameters:
location- the location to list resources from- Returns:
- a list of suppliers for input streams for the resources
-
listResources
public Map<net.minecraft.resources.ResourceLocation,net.minecraft.server.packs.resources.IoSupplier<InputStream>> listResources(@NonNull String path, @NonNull Predicate<net.minecraft.resources.ResourceLocation> filter) Description copied from interface:ResourceGenerationContext.ResourceSourceLists all resources in a namespace that match a given filter, from the highest priority pack not provided by aResourceCache.- Specified by:
listResourcesin interfaceResourceGenerationContext.ResourceSource- Parameters:
path- the path to list resources infilter- a filter to apply to the resource locations- Returns:
- a map of resource locations to suppliers for input streams for the resources
-
listResourceStacks
public Map<net.minecraft.resources.ResourceLocation,List<net.minecraft.server.packs.resources.IoSupplier<InputStream>>> listResourceStacks(@NonNull String path, @NonNull Predicate<net.minecraft.resources.ResourceLocation> filter) Description copied from interface:ResourceGenerationContext.ResourceSourceLists all resources within a given path, from highest to lowest priority.- Specified by:
listResourceStacksin interfaceResourceGenerationContext.ResourceSource- Parameters:
path- the path to list resources infilter- a filter to apply to the resource locations- Returns:
- a map of resource locations to suppliers for input streams for the resources
-
getNamespaces
- Specified by:
getNamespacesin interfaceResourceGenerationContext.ResourceSource- Returns:
- a set of all namespaces that have resources in this context
-