Search in sources :

Example 1 with IPostInit

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();
        }
    }
}
Also used : IPostInit(com.builtbroken.mc.core.registry.implement.IPostInit) IRecipe(net.minecraft.item.crafting.IRecipe) IJsonGenObject(com.builtbroken.mc.lib.json.imp.IJsonGenObject) IRecipeContainer(com.builtbroken.mc.core.registry.implement.IRecipeContainer)

Example 2 with IPostInit

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");
                }
            }
        }
    }
}
Also used : IPostInit(com.builtbroken.mc.core.registry.implement.IPostInit) IRecipe(net.minecraft.item.crafting.IRecipe) ArrayList(java.util.ArrayList) IRecipeContainer(com.builtbroken.mc.core.registry.implement.IRecipeContainer)

Example 3 with IPostInit

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);
                }
            }
        }
    }
}
Also used : IPostInit(com.builtbroken.mc.core.registry.implement.IPostInit) IRecipe(net.minecraft.item.crafting.IRecipe) IJsonGenObject(com.builtbroken.mc.lib.json.imp.IJsonGenObject) IRecipeContainer(com.builtbroken.mc.core.registry.implement.IRecipeContainer)

Aggregations

IPostInit (com.builtbroken.mc.core.registry.implement.IPostInit)3 IRecipeContainer (com.builtbroken.mc.core.registry.implement.IRecipeContainer)3 IRecipe (net.minecraft.item.crafting.IRecipe)3 IJsonGenObject (com.builtbroken.mc.lib.json.imp.IJsonGenObject)2 ArrayList (java.util.ArrayList)1