More aggressively load model files

This commit is contained in:
embeddedt 2023-06-21 21:17:11 -04:00
parent 2fe5c088e3
commit 19c6687745
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -105,21 +105,21 @@ public class ModelBakeryHelpers {
} }
} }
allPackResources.removeIf(pack -> { allPackResources.removeIf(pack -> {
if(isTrustedPack.test(pack)) { for(String namespace : pack.getNamespaces(PackType.CLIENT_RESOURCES)) {
for(String namespace : pack.getNamespaces(PackType.CLIENT_RESOURCES)) { Collection<ResourceLocation> allBlockstates = pack.getResources(PackType.CLIENT_RESOURCES, namespace, "blockstates", Integer.MAX_VALUE, p -> p.endsWith(".json"));
Collection<ResourceLocation> allBlockstates = pack.getResources(PackType.CLIENT_RESOURCES, namespace, "blockstates", Integer.MAX_VALUE, p -> p.endsWith(".json")); for(ResourceLocation blockstate : allBlockstates) {
for(ResourceLocation blockstate : allBlockstates) { allAvailableStates.add(new ResourceLocation(blockstate.getNamespace(), blockstate.getPath().replace("blockstates/", "").replace(".json", "")));
allAvailableStates.add(new ResourceLocation(blockstate.getNamespace(), blockstate.getPath().replace("blockstates/", "").replace(".json", ""))); }
} Collection<ResourceLocation> allModels = pack.getResources(PackType.CLIENT_RESOURCES, namespace, "models", Integer.MAX_VALUE, p -> p.endsWith(".json"));
Collection<ResourceLocation> allModels = pack.getResources(PackType.CLIENT_RESOURCES, namespace, "models", Integer.MAX_VALUE, p -> p.endsWith(".json")); for(ResourceLocation blockstate : allModels) {
for(ResourceLocation blockstate : allModels) { allAvailableModels.add(new ResourceLocation(blockstate.getNamespace(), blockstate.getPath().replace("models/", "").replace(".json", "")));
allAvailableModels.add(new ResourceLocation(blockstate.getNamespace(), blockstate.getPath().replace("models/", "").replace(".json", "")));
}
} }
return true;
} }
ModernFix.LOGGER.debug("Pack with class {} needs manual scan", pack.getClass().getName()); if(!isTrustedPack.test(pack)) {
return false; ModernFix.LOGGER.debug("Pack with class {} needs manual scan", pack.getClass().getName());
return false;
}
return true;
}); });
gatherAdditionalViaManualScan(allPackResources, allAvailableStates, blockStateFiles, "blockstates/"); gatherAdditionalViaManualScan(allPackResources, allAvailableStates, blockStateFiles, "blockstates/");
@ -215,6 +215,7 @@ public class ModelBakeryHelpers {
blockStateData = null; blockStateData = null;
blockStateLoadedFiles.clear(); blockStateLoadedFiles.clear();
modelFiles.addAll(allAvailableModels);
/* figure out which models we should actually load */ /* figure out which models we should actually load */
gatherAdditionalViaManualScan(allPackResources, allAvailableModels, modelFiles, "models/"); gatherAdditionalViaManualScan(allPackResources, allAvailableModels, modelFiles, "models/");
modelFiles.retainAll(allAvailableModels); modelFiles.retainAll(allAvailableModels);