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