Class ResourceCache
java.lang.Object
dev.lukebemish.dynamicassetgenerator.api.ResourceCache
- Direct Known Subclasses:
AssetResourceCache,DataResourceCache
Caches instructions for producing resources, and generates them as packs are loaded.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<Supplier<? extends PathAwareInputStreamSource>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanallowAccess(String packId) Determines whether this cache can access the provided resources during resource generationSet<net.minecraft.resources.ResourceLocation> net.minecraft.resources.ResourceLocationgetName()abstract @NonNull net.minecraft.server.packs.PackTypeMap<net.minecraft.resources.ResourceLocation, net.minecraft.server.packs.resources.IoSupplier<InputStream>> @NonNull ResourceGenerationContextmakeContext(boolean blind) Creates a context for generating resources within this cache.voidplanResetListener(Resettable listener) Adds a listener to be called when this cache is reset.voidplanSource(PathAwareInputStreamSource source) Plan to generate a source when this cache is resolved.voidplanSource(Supplier<? extends PathAwareInputStreamSource> source) Plan to generate a currently unresulved source when this cache is resolved.voidplanSource(Supplier<Set<net.minecraft.resources.ResourceLocation>> locations, InputStreamSource source) Plan to generate sources at a currently unresolved set of locations when this cache is resolved.voidplanSource(Set<net.minecraft.resources.ResourceLocation> locations, InputStreamSource source) Plan to generate sources at a set of locations when this cache is resolved.voidplanSource(net.minecraft.resources.ResourceLocation rl, InputStreamSource source) Plan a source to be generated at a given resource location when this cache is resolved.static <T extends ResourceCache>
Tregister(T cache) Register a new resource cache as the lowest priority resource pack.static <T extends ResourceCache>
Tregister(T cache, net.minecraft.server.packs.repository.Pack.Position position) Register a new resource cache.voidreset(ResourceGenerationContext context) Resets all listeners associated with this cache.
-
Field Details
-
cache
-
-
Constructor Details
-
ResourceCache
public ResourceCache(net.minecraft.resources.ResourceLocation name) - Parameters:
name- a unique identifier for this cache
-
-
Method Details
-
register
public static <T extends ResourceCache> T register(T cache, net.minecraft.server.packs.repository.Pack.Position position) Register a new resource cache.- Type Parameters:
T- the type of the cache- Parameters:
cache- the cache to registerposition- the position to register the cache at- Returns:
- the registered cache
-
getDependencies
- Returns:
- names of other
ResourceCaches that this cache is allowed to use during generation
-
allowAccess
Determines whether this cache can access the provided resources during resource generation- Parameters:
packId- the name of the pack to check whether access is allowed- Returns:
- true if access is allowed; false otherwise
-
register
Register a new resource cache as the lowest priority resource pack.- Type Parameters:
T- the type of the cache- Parameters:
cache- the cache to register- Returns:
- the registered cache
-
getName
public net.minecraft.resources.ResourceLocation getName()- Returns:
- a unique identifier for this cache
-
getResources
public Map<net.minecraft.resources.ResourceLocation,net.minecraft.server.packs.resources.IoSupplier<InputStream>> getResources()- Returns:
- a map of all resources this pack can generate; calling this may resolve any given source cached to it
-
makeContext
Creates a context for generating resources within this cache.- Parameters:
blind- if true, the context should not be able to read resources. Must be true if the available resources are not guaranteed to be set up yet- Returns:
- a context for generating resources within this cache
-
planResetListener
Adds a listener to be called when this cache is reset.- Parameters:
listener- the listener to add
-
reset
Resets all listeners associated with this cache. -
planSource
Plan a source to be generated at a given resource location when this cache is resolved.- Parameters:
rl- the resource location the generated source is located atsource- the source to generate
-
planSource
public void planSource(Supplier<Set<net.minecraft.resources.ResourceLocation>> locations, InputStreamSource source) Plan to generate sources at a currently unresolved set of locations when this cache is resolved.- Parameters:
locations- the locations to generate; resolved when this cache is resolvedsource- the source to generate
-
planSource
public void planSource(Set<net.minecraft.resources.ResourceLocation> locations, InputStreamSource source) Plan to generate sources at a set of locations when this cache is resolved.- Parameters:
locations- the locations to generatesource- the source to generate
-
planSource
Plan to generate a source when this cache is resolved.- Parameters:
source- the source to generate
-
planSource
Plan to generate a currently unresulved source when this cache is resolved.- Parameters:
source- the source to generate; resulved when this cache is resolved
-
getPackType
public abstract @NonNull net.minecraft.server.packs.PackType getPackType()- Returns:
- the type of pack this cache will generate resources for
-