Loosen up registry locks until data freeze.

This commit is contained in:
LexManos 2017-06-23 17:52:59 -07:00
parent d032a34aaa
commit dd42f84a47
3 changed files with 9 additions and 4 deletions

View File

@ -593,23 +593,24 @@ public class CraftingHelper {
}
}
public static void loadRecipes()
public static void loadRecipes(boolean revertFrozen)
{
//TODO: If this errors in ServerInit it freezes the client at loading world, find a way to pop that up?
//TODO: Figure out how to remove recipes, and override them. This relies on cpw to help.
//For now this is only done one after mod init, I want to move this to ServerInit and re-do it many times.
init();
ForgeRegistry<IRecipe> reg = (ForgeRegistry<IRecipe>)ForgeRegistries.RECIPES;
//reg.unfreeze();
if (DEBUG_LOAD_MINECRAFT)
reg.clear();
else
else if (revertFrozen)
GameData.revert(RegistryManager.FROZEN, GameData.RECIPES, false);
//ModContainer old = Loader.instance().activeModContainer();
Loader.instance().setActiveModContainer(null);
Loader.instance().getActiveModList().forEach((mod) -> loadFactories(mod));
Loader.instance().getActiveModList().forEach((mod) -> loadRecipes(mod));
Loader.instance().setActiveModContainer(null);
reg.freeze();
//reg.freeze();
}
private static void loadFactories(ModContainer mod)

View File

@ -824,7 +824,7 @@ public class Loader
public void initializeMods()
{
progressBar.step("Initializing mods Phase 2");
CraftingHelper.loadRecipes();
CraftingHelper.loadRecipes(false);
// Mod controller should be in the initialization state here
modController.distributeStateMessage(LoaderState.INITIALIZATION);
progressBar.step("Initializing mods Phase 3");

View File

@ -662,10 +662,12 @@ public class GameData
{
List<ResourceLocation> keys = Lists.newArrayList(RegistryManager.ACTIVE.registries.keySet());
Collections.sort(keys, (o1, o2) -> o1.toString().compareToIgnoreCase(o2.toString()));
/*
RegistryManager.ACTIVE.registries.forEach((name, reg) -> {
if (filter.test(name))
((ForgeRegistry<?>)reg).unfreeze();
});
*/
if (filter.test(BLOCKS))
{
@ -686,9 +688,11 @@ public class GameData
ObjectHolderRegistry.INSTANCE.applyObjectHolders(); // inject everything else
/*
RegistryManager.ACTIVE.registries.forEach((name, reg) -> {
if (filter.test(name))
((ForgeRegistry<?>)reg).freeze();
});
*/
}
}