use of com.builtbroken.mc.core.registry.implement.IPostInit in project Engine by VoltzEngine-Project.
the class JsonContentLoader method handlePostCalls.
/**
* Called to handle post call code on generated objects.
* <p>
* Separated from {@link #postInit()} due to other processors
* having special handling.
*
* @param generatedObjects
*/
public void handlePostCalls(List<IJsonGenObject> generatedObjects) {
if (generatedObjects != null && !generatedObjects.isEmpty()) {
for (IJsonGenObject obj : generatedObjects) {
debug.start("Handling: " + obj);
if (obj instanceof IPostInit) {
((IPostInit) obj).onPostInit();
}
if (obj instanceof IRecipeContainer) {
List<IRecipe> recipes = new ArrayList();
((IRecipeContainer) obj).genRecipes(recipes);
if (recipes.size() > 0) {
debug.start("Adding recipes from gen object:");
for (IRecipe recipe : recipes) {
if (recipe != null) {
if (recipe.getRecipeOutput() != null) {
GameRegistry.addRecipe(recipe);
} else {
debug.log("Null recipe output detected");
}
} else {
debug.log("Null recipe detected");
}
}
debug.end();
}
}
debug.end();
}
}
}
use of com.builtbroken.mc.core.registry.implement.IPostInit in project Engine by VoltzEngine-Project.
the class ModManager method firePostInit.
/**
* Called during post init phase of mod loading
*/
public void firePostInit() {
for (Object object : temp_registry_list) {
if (object instanceof IPostInit) {
((IPostInit) object).onPostInit();
}
}
for (Object object : temp_registry_list) {
if (object instanceof IRecipeContainer) {
List<IRecipe> recipes = new ArrayList();
((IRecipeContainer) object).genRecipes(recipes);
for (IRecipe recipe : recipes) {
if (recipe.getRecipeOutput() != null) {
if (recipe.getRecipeOutput().getItem() != null) {
if (recipe.getRecipeOutput().getMaxStackSize() > 0) {
// TODO check that input -> output
// TODO check for basic errors
// TODO check size
// TODO check for missing items
// TODO check for oreName replacement
GameRegistry.addRecipe(recipe);
} else if (Engine.runningAsDev) {
throw new IllegalArgumentException("Recipe[" + recipe + "] output's stack size is less than 1");
}
} else if (Engine.runningAsDev) {
throw new IllegalArgumentException("Recipe[" + recipe + "] output's item is null");
}
} else if (Engine.runningAsDev) {
throw new IllegalArgumentException("Recipe[" + recipe + "] output is null");
}
}
}
}
}
use of com.builtbroken.mc.core.registry.implement.IPostInit in project Engine by VoltzEngine-Project.
the class JsonContentLoader method postInit.
@Override
public void postInit() {
processEntries();
for (IJsonGenObject obj : generatedObjects) {
if (obj instanceof IPostInit) {
((IPostInit) obj).onPostInit();
}
if (obj instanceof IRecipeContainer) {
List<IRecipe> recipes = new ArrayList();
((IRecipeContainer) obj).genRecipes(recipes);
for (IRecipe recipe : recipes) {
if (recipe != null && recipe.getRecipeOutput() != null) {
GameRegistry.addRecipe(recipe);
}
}
}
}
}
Aggregations