Package org.moddingx.libx.datapack
Class DataLoader
java.lang.Object
org.moddingx.libx.datapack.DataLoader
Utilities to load data from a 
ResourceManager- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceA factory to map a resource to something else.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> Map<net.minecraft.resources.ResourceLocation, T> collect(List<ResourceEntry> resources, DataLoader.ResourceFactory<net.minecraft.server.packs.resources.Resource, T> factory) Collects data from the givenresourcesby a given factory.static <T> Map<net.minecraft.resources.ResourceLocation, T> collectJson(List<ResourceEntry> resources, com.mojang.serialization.Codec<T> codec) Collects data from the givenresourcesby a givenCodec.static <T> Map<net.minecraft.resources.ResourceLocation, T> collectJson(List<ResourceEntry> resources, DataLoader.ResourceFactory<JsonElement, T> factory) Collects data from the givenresourcesby a given factory.static <T> Map<net.minecraft.resources.ResourceLocation, T> collectText(List<ResourceEntry> resources, DataLoader.ResourceFactory<String, T> factory) Collects data from the givenresourcesby a given factory.static <T> Stream<T> join(List<ResourceEntry> resources, DataLoader.ResourceFactory<net.minecraft.server.packs.resources.Resource, T> factory) Joins data from the givenresourcesby a given factory into a stream.static <T> Stream<T> joinJson(List<ResourceEntry> resources, DataLoader.ResourceFactory<JsonElement, T> factory) Joins data from the givenresourcesby a given factory into a stream.static <T> Stream<T> joinText(List<ResourceEntry> resources, DataLoader.ResourceFactory<String, T> factory) Joins data from the givenresourcesby a given factory into a stream.static <T> Map<net.minecraft.resources.ResourceLocation, T> loadJson(net.minecraft.server.packs.resources.ResourceManager rm, String basePath, com.mojang.serialization.Codec<T> codec) Loads json data from a base path.static <T> Map<net.minecraft.resources.ResourceLocation, T> loadJson(net.minecraft.server.packs.resources.ResourceManager rm, String basePath, DataLoader.ResourceFactory<JsonElement, T> factory) Loads json data from a base path.static List<ResourceEntry> Locates resources in different namespaces.static List<ResourceEntry> locate(net.minecraft.server.packs.resources.ResourceManager rm, String basePath, String suffix, boolean recursive) Locates resources in a specific folder.
- 
Constructor Details- 
DataLoaderpublic DataLoader()
 
- 
- 
Method Details- 
loadJsonpublic static <T> Map<net.minecraft.resources.ResourceLocation,T> loadJson(net.minecraft.server.packs.resources.ResourceManager rm, String basePath, com.mojang.serialization.Codec<T> codec) throws IOException Loads json data from a base path. For example if the base path isa/band there are the json filesa/b/c.jsonanda/b/d/e.json, the resulting ids will bemodid:candmodid:d/e.- Parameters:
- codec- A- Codecto create the resulting objects.
- Throws:
- IOException
 
- 
loadJsonpublic static <T> Map<net.minecraft.resources.ResourceLocation,T> loadJson(net.minecraft.server.packs.resources.ResourceManager rm, String basePath, DataLoader.ResourceFactory<JsonElement, T> factory) throws IOExceptionLoads json data from a base path. For example if the base path isa/band there are the json filesa/b/c.jsonanda/b/d/e.json, the resulting ids will bemodid:candmodid:d/e.- Parameters:
- factory- A factory to create the resulting objects.
- Throws:
- IOException
 
- 
collectpublic static <T> Map<net.minecraft.resources.ResourceLocation,T> collect(List<ResourceEntry> resources, DataLoader.ResourceFactory<net.minecraft.server.packs.resources.Resource, T> factory) throws IOExceptionCollects data from the givenresourcesby a given factory.- Throws:
- IOException
 
- 
collectTextpublic static <T> Map<net.minecraft.resources.ResourceLocation,T> collectText(List<ResourceEntry> resources, DataLoader.ResourceFactory<String, T> factory) throws IOExceptionCollects data from the givenresourcesby a given factory. The contents of the resource are mapped to aStringfirst.- Throws:
- IOException
 
- 
collectJsonpublic static <T> Map<net.minecraft.resources.ResourceLocation,T> collectJson(List<ResourceEntry> resources, com.mojang.serialization.Codec<T> codec) throws IOException Collects data from the givenresourcesby a givenCodec. The contents of the resource are mapped to aJsonElementfirst.- Throws:
- IOException
 
- 
collectJsonpublic static <T> Map<net.minecraft.resources.ResourceLocation,T> collectJson(List<ResourceEntry> resources, DataLoader.ResourceFactory<JsonElement, T> factory) throws IOExceptionCollects data from the givenresourcesby a given factory. The contents of the resource are mapped to aJsonElementfirst.- Throws:
- IOException
 
- 
joinpublic static <T> Stream<T> join(List<ResourceEntry> resources, DataLoader.ResourceFactory<net.minecraft.server.packs.resources.Resource, T> factory) throws IOExceptionJoins data from the givenresourcesby a given factory into a stream.- Throws:
- IOException
 
- 
joinTextpublic static <T> Stream<T> joinText(List<ResourceEntry> resources, DataLoader.ResourceFactory<String, T> factory) throws IOExceptionJoins data from the givenresourcesby a given factory into a stream. The contents of the resource are mapped to aStringfirst.- Throws:
- IOException
 
- 
joinJsonpublic static <T> Stream<T> joinJson(List<ResourceEntry> resources, DataLoader.ResourceFactory<JsonElement, T> factory) throws IOExceptionJoins data from the givenresourcesby a given factory into a stream. The contents of the resource are mapped to aJsonElementfirst.- Throws:
- IOException
 
- 
locatepublic static List<ResourceEntry> locate(net.minecraft.server.packs.resources.ResourceManager rm, String fullPath, String idPath) Locates resources in different namespaces.- Parameters:
- rm- The resource manager to use.
- fullPath- The full path of the resource
- idPath- The string that will be used as path name for the id in the resulting resource.
 
- 
locatepublic static List<ResourceEntry> locate(net.minecraft.server.packs.resources.ResourceManager rm, String basePath, @Nullable String suffix, boolean recursive) Locates resources in a specific folder.- Parameters:
- rm- The resource manager to use.
- basePath- The base path to scan.
- suffix- The suffix of the files to load. A file must wnd in a point followed by this if- suffixis non-null.
- recursive- Whether to scan sub-directories as well.
- Returns:
- A list of resources. Their ids will have basePathandsuffixstripped.
 
 
-