WIP Caching Hints and Caching Sampler

This commit is contained in:
Zoe Gidiere
2024-10-09 23:36:12 -06:00
parent 370b2e0122
commit 1ae0d1f867
11 changed files with 222 additions and 9 deletions

View File

@@ -310,6 +310,24 @@ public abstract class AbstractPlatform implements Platform {
}
}
public static int getGenerationThreadsWithReflection(String className, String fieldName, String project) {
try {
Class aClass = Class.forName(className);
int threads = aClass.getField(fieldName).getInt(null);
logger.info("{} found, setting {} generation threads.", project, threads);
return threads;
} catch(ClassNotFoundException e) {
logger.info("{} not found.", project);
} catch(NoSuchFieldException e) {
logger.warn("{} found, but {} field not found this probably means {0} has changed its code and " +
"Terra has not updated to reflect that.", project, fieldName);
} catch(IllegalAccessException e) {
logger.error("Failed to access {} field in {}, assuming 1 generation thread.", fieldName, project, e);
}
return 0;
}
@Override
public void register(TypeRegistry registry) {
loaders.register(registry);
@@ -339,4 +357,9 @@ public abstract class AbstractPlatform implements Platform {
public @NotNull Profiler getProfiler() {
return profiler;
}
@Override
public int getGenerationThreads() {
return 1;
}
}

View File

@@ -232,7 +232,7 @@ public class ConfigPackImpl implements ConfigPack {
ConfigPackPostTemplate packPostTemplate = new ConfigPackPostTemplate();
selfLoader.load(packPostTemplate, packManifest);
seededBiomeProvider =
template.getBiomeCache() ? packPostTemplate.getProviderBuilder().caching() : packPostTemplate.getProviderBuilder();
template.getBiomeCache() ? packPostTemplate.getProviderBuilder().caching(platform) : packPostTemplate.getProviderBuilder();
checkDeadEntries();
}