Don't cache invalid resource locations at all

Fixes #2
This commit is contained in:
embeddedt 2023-01-04 17:23:34 -05:00
parent 99ee81ab78
commit dc18e782c4
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 15 additions and 2 deletions

View File

@ -16,7 +16,7 @@ plugins {
apply plugin: 'org.spongepowered.mixin'
group = 'org.embeddedt'
version = '1.1.0'
version = '1.2.0'
java {
archivesBaseName = 'modernfix-mc' + minecraft_version

View File

@ -59,7 +59,7 @@ public abstract class ModFileResourcePackMixin {
try (Stream<Path> stream = Files.walk(root)) {
List<Path> paths = stream
.map(path -> root.relativize(path.toAbsolutePath()))
.filter(path -> !path.toString().endsWith(".mcmeta"))
.filter(this::isValidCachedResourcePath)
.collect(Collectors.toList());
rootListingForNamespaces.put(namespace, paths);
for(Path path : paths) {
@ -75,6 +75,19 @@ 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");
return false;
}
}
return true;
}
@Inject(method = "getNamespaces", at = @At("HEAD"), cancellable = true)
private void useCacheForNamespaces(ResourcePackType type, CallbackInfoReturnable<Set<String>> cir) {
if(useNamespaceCaches) {