use of net.minecraft.server.packs.PackType in project MinecraftForge by MinecraftForge.
the class PathResourcePack method getResources.
@Override
public Collection<ResourceLocation> getResources(PackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate<String> filter) {
try {
Path root = resolve(type.getDirectory(), resourceNamespace).toAbsolutePath();
Path inputPath = root.getFileSystem().getPath(pathIn);
return Files.walk(root).map(root::relativize).filter(path -> path.getNameCount() <= maxDepth && !path.toString().endsWith(".mcmeta") && path.startsWith(inputPath)).filter(path -> filter.test(path.getFileName().toString())).map(path -> new ResourceLocation(resourceNamespace, Joiner.on('/').join(path))).collect(Collectors.toList());
} catch (IOException e) {
return Collections.emptyList();
}
}
use of net.minecraft.server.packs.PackType in project MinecraftForge by MinecraftForge.
the class DelegatingResourcePack method buildNamespaceMap.
private Map<String, List<PackResources>> buildNamespaceMap(PackType type, List<PackResources> packList) {
Map<String, List<PackResources>> map = new HashMap<>();
for (PackResources pack : packList) {
for (String namespace : pack.getNamespaces(type)) {
map.computeIfAbsent(namespace, k -> new ArrayList<>()).add(pack);
}
}
map.replaceAll((k, list) -> ImmutableList.copyOf(list));
return ImmutableMap.copyOf(map);
}
Aggregations