Search in sources :

Example 1 with ShapedRecipe

use of crazypants.enderio.base.config.recipes.ShapedRecipe in project EnderIO by SleepyTrousers.

the class Crafting method register.

@Override
public void register(@Nonnull String recipeName) {
    if (valid && active) {
        final ResourceLocation recipeRL = mkRL(recipeName);
        final IForgeRegistry<IRecipe> registry = ForgeRegistries.RECIPES;
        if (grid != null) {
            if (upgrade) {
                log("ShapedRecipe.Upgrade", recipeName, recipeRL, getOutput().getItemStack(), grid.getIngredients());
                registry.register(new ShapedRecipe.Upgrade(recipeRL, grid.getWidth(), grid.getHeight(), grid.getIngredients(), getOutput().getThing()));
            } else {
                log("ShapedRecipe", recipeName, recipeRL, getOutput().getItemStack(), grid.getIngredients());
                registry.register(new ShapedRecipe(recipeRL, grid.getWidth(), grid.getHeight(), grid.getIngredients(), getOutput().getThing()));
            }
            if (getOutput().hasAlternatives()) {
                getOutput().getAlternatives().apply(new Callback<ItemStack>() {

                    @Override
                    public void apply(@Nonnull ItemStack alternative) {
                        Log.debug("Providing synthetic alternative recipe to JEI for oredicted output: " + alternative + ": " + grid.getIngredients());
                        JeiAccessor.addAlternativeRecipe(new ShapedRecipes("", grid.getWidth(), grid.getHeight(), grid.getIngredients(), alternative));
                    }
                });
            }
        } else {
            if (upgrade) {
                log("GenericUpgradeRecipeShapeless", recipeName, recipeRL, getOutput().getItemStack(), shapeless.getIngredients());
                registry.register(new ShapelessRecipe.Upgrade(recipeRL, shapeless.getIngredients(), getOutput().getThing()));
            } else {
                log("ShapelessOreRecipe", recipeName, recipeRL, getOutput().getItemStack(), shapeless.getIngredients());
                registry.register(new ShapelessRecipe(recipeRL, shapeless.getIngredients(), getOutput().getThing()));
            }
            if (getOutput().hasAlternatives()) {
                getOutput().getAlternatives().apply(new Callback<ItemStack>() {

                    @Override
                    public void apply(@Nonnull ItemStack alternative) {
                        Log.debug("Providing synthetic alternative recipe to JEI for oredicted output: " + alternative + ": " + shapeless.getIngredients());
                        JeiAccessor.addAlternativeRecipe(new ShapelessRecipes("", alternative, shapeless.getIngredients()));
                    }
                });
            }
        }
    } else {
        Log.debug("Skipping Crafting '" + (getOutput() == null ? "null" : getOutput().getItemStack()) + "' (valid=" + valid + ", active=" + active + ")");
    }
}
Also used : ShapedRecipes(net.minecraft.item.crafting.ShapedRecipes) IRecipe(net.minecraft.item.crafting.IRecipe) ResourceLocation(net.minecraft.util.ResourceLocation) ShapedRecipe(crazypants.enderio.base.config.recipes.ShapedRecipe) ShapelessRecipe(crazypants.enderio.base.config.recipes.ShapelessRecipe) ItemStack(net.minecraft.item.ItemStack) ShapelessRecipes(net.minecraft.item.crafting.ShapelessRecipes)

Aggregations

ShapedRecipe (crazypants.enderio.base.config.recipes.ShapedRecipe)1 ShapelessRecipe (crazypants.enderio.base.config.recipes.ShapelessRecipe)1 ItemStack (net.minecraft.item.ItemStack)1 IRecipe (net.minecraft.item.crafting.IRecipe)1 ShapedRecipes (net.minecraft.item.crafting.ShapedRecipes)1 ShapelessRecipes (net.minecraft.item.crafting.ShapelessRecipes)1 ResourceLocation (net.minecraft.util.ResourceLocation)1