use of org.blockartistry.DynSurround.data.Profiles.ProfileScript in project DynamicSurroundings by OreCruncher.
the class RegistryManager method reload.
public void reload() {
// Collect the locations where DS data is configured
final List<Pack> packs = ResourcePacks.findResourcePacks();
final List<ModContainer> activeMods = Loader.instance().getActiveModList();
DSurround.log().info("Identified the following resource pack locations");
packs.stream().map(Pack::toString).forEach(DSurround.log()::info);
// Do the preinit
this.initOrder.forEach(Registry::init);
// Process the mod config from each of our packs
activeMods.stream().map(mod -> {
return new ResourceLocation(DSurround.MOD_ID, "data/" + mod.getModId().toLowerCase() + ".json");
}).forEach(rl -> {
packs.forEach(p -> {
final String loadingText = "[" + rl.toString() + "] <- [" + p.getModName() + "]";
process(p, rl, loadingText);
});
});
// Process general config files from our packs
final ResourceLocation rl = ResourcePacks.CONFIGURE_RESOURCE;
packs.stream().forEach(p -> process(p, rl, "[" + rl.toString() + "] <- [" + p.getModName() + "]"));
// Apply built-in profiles
final List<ProfileScript> resources = Profiles.getProfileStreams();
for (final ProfileScript script : resources) {
try (final InputStreamReader reader = new InputStreamReader(script.stream)) {
final ModConfigurationFile cfg = DataScripts.loadFromStream(reader);
final String loadingText = "[" + DSurround.MOD_ID + "] <- [" + script.packName + "]";
configRegistries(cfg, loadingText);
} catch (@Nonnull final Throwable ex) {
final String temp = String.format("Unable to load profile [%s]", script.packName);
DSurround.log().error(temp, ex);
}
}
// Load scripts specified in the configuration
Arrays.stream(ModOptions.general.externalScriptFiles).forEach(cfg -> configRegistries(DataScripts.loadFromDirectory(cfg), "[" + cfg + "]"));
// Have the registries finalize their settings
this.initOrder.forEach(Registry::initComplete);
// Let everyone know a reload happened
MinecraftForge.EVENT_BUS.post(new ReloadEvent.Registry(this.side));
}
Aggregations