Fix mcmeta files not being included in hasResource() calls

This commit is contained in:
embeddedt 2023-01-05 11:06:33 -05:00
parent 8317912475
commit ac27dbca4e
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 10 additions and 10 deletions

View File

@ -57,15 +57,18 @@ public abstract class ModFileResourcePackMixin {
try {
Path root = modFile.getLocator().findPath(modFile, type.getDirectory(), namespace).toAbsolutePath();
try (Stream<Path> stream = Files.walk(root)) {
List<Path> paths = stream
ArrayList<Path> rootListingPaths = new ArrayList<>();
stream
.map(path -> root.relativize(path.toAbsolutePath()))
.filter(this::isValidCachedResourcePath)
.collect(Collectors.toList());
rootListingForNamespaces.put(namespace, paths);
for(Path path : paths) {
String mergedPath = slashJoiner.join(type.getDirectory(), namespace, path);
this.containedPaths.add(mergedPath);
}
.forEach(path -> {
if(!path.toString().endsWith(".mcmeta"))
rootListingPaths.add(path);
String mergedPath = slashJoiner.join(type.getDirectory(), namespace, path);
this.containedPaths.add(mergedPath);
});
rootListingPaths.trimToSize();
rootListingForNamespaces.put(namespace, rootListingPaths);
}
} catch(IOException e) {
rootListingForNamespaces.put(namespace, Collections.emptyList());
@ -77,8 +80,6 @@ public abstract class ModFileResourcePackMixin {
private boolean isValidCachedResourcePath(Path path) {
String str = path.toString();
if(str.endsWith(".mcmeta"))
return false;
for(int i = 0; i < str.length(); i++) {
if(!ResourceLocation.validPathChar(str.charAt(i))) {
ModernFix.LOGGER.warn("Asset " + str + " does not have a valid resource path and will not be listed");

View File

@ -49,7 +49,6 @@ public class VanillaPackMixin {
try(Stream<Path> stream = Files.walk(root)) {
stream
.map(path -> root.relativize(path.toAbsolutePath()))
.filter(path -> !path.toString().endsWith(".mcmeta"))
.forEach(path -> containedPaths.add(slashJoiner.join(type.getDirectory(), path)));
}
} catch(IOException e) {