net.minecraftforge.fml.common.ProgressManager Java Examples

The following examples show how to use net.minecraftforge.fml.common.ProgressManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NovaMinecraft.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent evt) {
	try {
		proxy.init(evt);
		nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.init(evt));
		int size = novaModWrappers.size() + novaWrappers.size();
		if (size > 0) {
			ProgressManager.ProgressBar progressBar = ProgressManager.push("Initializing NOVA wrappers", size);
			FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
			novaModWrappers.stream().forEachOrdered(wrapper -> {
				fmlProgressBar.step(wrapper.getClass());
				wrapper.init(evt);
			});
			novaWrappers.stream().forEachOrdered(wrapper -> {
				fmlProgressBar.step(wrapper.getClass());
				wrapper.init(evt);
			});
			fmlProgressBar.finish();
			ProgressManager.pop(progressBar);
		}
	} catch (Exception e) {
		Game.logger().error("Error during init");
		e.printStackTrace();
		throw new InitializationException(e);
	}
}
 
Example #2
Source File: NEIInitialization.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private static void loadModSubsets() {
    ProgressBar bar = ProgressManager.push("Mod Subsets", ForgeRegistries.ITEMS.getKeys().size());
    HashMap<String, ItemStackSet> modSubsets = new HashMap<>();

    for (Item item : ForgeRegistries.ITEMS) {
        try {
            ResourceLocation ident = item.getRegistryName();
            bar.step(ident.toString());
            if (ident == null) {
                LogHelper.error("Failed to find identifier for: " + item);
                continue;
            }
            String modId = ident.getResourceDomain();
            ItemInfo.itemOwners.put(item, modId);
            ItemStackSet itemset = modSubsets.computeIfAbsent(modId, k -> new ItemStackSet());
            itemset.with(item);
        } catch (Throwable t) {
            LogHelper.errorError("Failed to process mod subset item %s %s", t, String.valueOf(item), String.valueOf(item.getRegistryName()));
        }
    }
    ProgressManager.pop(bar);

    API.addSubset("Mod.Minecraft", modSubsets.remove("minecraft"));
    for (Entry<String, ItemStackSet> entry : modSubsets.entrySet()) {
        ModContainer mc = FMLCommonHandler.instance().findContainerFor(entry.getKey());
        if (mc == null) {
            LogHelper.error("Missing container for " + entry.getKey());
        } else {
            API.addSubset("Mod." + mc.getName(), entry.getValue());
        }
    }
}
 
Example #3
Source File: NovaMinecraft.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent evt) {
	try {
		proxy.postInit(evt);
		nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.postInit(evt));
		Game.recipes().init();
		int size = novaModWrappers.size() + novaWrappers.size();
		if (size > 0) {
			ProgressManager.ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA wrappers", size);
			FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
			novaModWrappers.stream().forEachOrdered(wrapper -> {
				fmlProgressBar.step(wrapper.getClass());
				wrapper.postInit(evt);
			});
			novaWrappers.stream().forEachOrdered(wrapper -> {
				fmlProgressBar.step(wrapper.getClass());
				wrapper.postInit(evt);
			});
			fmlProgressBar.finish();
			ProgressManager.pop(progressBar);
		}
	} catch (Exception e) {
		Game.logger().error("Error during postInit");
		e.printStackTrace();
		throw new InitializationException(e);
	}
}