Search in sources :

Example 21 with ShapelessOreRecipe

use of net.minecraftforge.oredict.ShapelessOreRecipe in project Engine by VoltzEngine-Project.

the class JsonCraftingRecipeData method genRecipes.

@Override
public void genRecipes(List<IRecipe> recipes) {
    //If output is a string convert
    if (output instanceof String) {
        Object out = convertItemEntry((String) output);
        if (out != null) {
            output = out;
        }
    }
    if (shaped) {
        //Shaped starts with a series of strings representing the grid, then goes "char, item, char2, item2...."
        boolean convert = false;
        int gridEnd = 0;
        for (int i = 0; i < data.length; i++) {
            Object dataObject = data[i];
            //Do not convert until after the first char entry
            if (dataObject instanceof Character) {
                if (gridEnd == 0) {
                    gridEnd = i;
                }
                convert = true;
            } else if (convert) {
                Object out = convertItemEntry((String) dataObject);
                if (out != null) {
                    data[i] = out;
                } else {
                    Engine.logger().error("The item value of [" + dataObject + "] could not be parsed into a valid recipe item entry. Recipe -> " + this);
                    return;
                }
            }
        }
        //Create recipe
        if (output instanceof Block) {
            if (largeGrid) {
                recipes.add(new RecipeShapedOreLarge((Block) output, data));
            } else {
                recipes.add(new ShapedOreRecipe((Block) output, data));
            }
        } else if (output instanceof Item) {
            if (largeGrid) {
                recipes.add(new RecipeShapedOreLarge((Item) output, data));
            } else {
                recipes.add(new ShapedOreRecipe((Item) output, data));
            }
        } else if (output instanceof ItemStack) {
            if (largeGrid) {
                recipes.add(new RecipeShapedOreLarge((ItemStack) output, data));
            } else {
                recipes.add(new ShapedOreRecipe((ItemStack) output, data));
            }
        } else {
            Engine.logger().error("The type of output value [" + output + "] could not be recognized for recipe creation. Recipe -> " + this);
        }
    } else {
        //Shapeless is an array of string data
        for (int i = 0; i < data.length; i++) {
            Object dataObject = data[i];
            if (dataObject instanceof String) {
                //Convert entries to correct outputs
                Object out = convertItemEntry((String) dataObject);
                if (out != null) {
                    data[i] = out;
                } else {
                    Engine.logger().error("The item value of [" + dataObject + "] could not be parsed into a valid recipe item entry. Recipe -> " + this);
                    return;
                }
            } else {
                Engine.logger().error("The item value of [" + dataObject + "] is not a valid string for parsing. Recipe -> " + this);
                return;
            }
        }
        //Create recipe
        if (output instanceof Block) {
            recipes.add(new ShapelessOreRecipe((Block) output, data));
        } else if (output instanceof Item) {
            recipes.add(new ShapelessOreRecipe((Item) output, data));
        } else if (output instanceof ItemStack) {
            recipes.add(new ShapelessOreRecipe((ItemStack) output, data));
        } else {
            Engine.logger().error("The type of output value [" + output + "] could not be recognized for recipe creation. Recipe -> " + this);
        }
    }
}
Also used : Item(net.minecraft.item.Item) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) ShapelessOreRecipe(net.minecraftforge.oredict.ShapelessOreRecipe) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) RecipeShapedOreLarge(com.builtbroken.mc.lib.recipe.item.grid.RecipeShapedOreLarge)

Example 22 with ShapelessOreRecipe

use of net.minecraftforge.oredict.ShapelessOreRecipe in project Engine by VoltzEngine-Project.

the class NuggetRecipeLoader method postInit.

@Override
public void postInit() {
    if (DefinedGenItems.NUGGET.item != null) {
        EnumSet<GenMaterial> mats = EnumSet.allOf(GenMaterial.class);
        mats.remove(GenMaterial.UNKNOWN);
        for (GenMaterial material : mats) {
            if (OreDictionary.getOres("ingot" + LanguageUtility.capitalizeFirst(material.name().toLowerCase()), false).size() > 0 && !DefinedGenItems.NUGGET.ignoreMaterials.contains(material)) {
                GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(DefinedGenItems.NUGGET.item, 9, material.ordinal()), "ingot" + LanguageUtility.capitalizeFirst(material.name().toLowerCase())));
                if (DefinedGenItems.INGOT.item != null) {
                    GameRegistry.addRecipe(new ShapedOreRecipe(DefinedGenItems.INGOT.stack(material), "nnn", "nnn", "nnn", 'n', new ItemStack(DefinedGenItems.NUGGET.item, 1, material.ordinal())));
                } else {
                    GameRegistry.addRecipe(new ShapedOreRecipe(OreDictionary.getOres("ingot" + LanguageUtility.capitalizeFirst(material.name().toLowerCase())).get(0), "nnn", "nnn", "nnn", 'n', new ItemStack(DefinedGenItems.NUGGET.item, 1, material.ordinal())));
                }
            }
        }
    }
}
Also used : ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) ShapelessOreRecipe(net.minecraftforge.oredict.ShapelessOreRecipe) GenMaterial(com.builtbroken.mc.core.content.resources.GenMaterial) ItemStack(net.minecraft.item.ItemStack)

Example 23 with ShapelessOreRecipe

use of net.minecraftforge.oredict.ShapelessOreRecipe in project Railcraft by Railcraft.

the class CraftingPlugin method addShapelessRecipe.

public static void addShapelessRecipe(@Nullable ItemStack result, Object... recipeArray) {
    ProcessedRecipe processedRecipe;
    try {
        processedRecipe = processRecipe(RecipeType.SHAPELESS, result, recipeArray);
    } catch (InvalidRecipeException ex) {
        Game.logTrace(Level.WARN, ex.getRawMessage());
        return;
    }
    if (processedRecipe.isOreRecipe) {
        IRecipe recipe = new ShapelessOreRecipe(processedRecipe.result, processedRecipe.recipeArray);
        addRecipe(recipe);
    } else
        GameRegistry.addShapelessRecipe(processedRecipe.result, processedRecipe.recipeArray);
}
Also used : IRecipe(net.minecraft.item.crafting.IRecipe) ShapelessOreRecipe(net.minecraftforge.oredict.ShapelessOreRecipe) InvalidRecipeException(mods.railcraft.common.util.crafting.InvalidRecipeException)

Example 24 with ShapelessOreRecipe

use of net.minecraftforge.oredict.ShapelessOreRecipe in project BetterWithAddons by DaedalusGame.

the class InteractionCondensedOutputs method addUncondensingRecipe.

private void addUncondensingRecipe(ForgeRegistry<IRecipe> registry, String id, ItemStack condensed, ItemStack material) {
    ItemStack outmaterial = material.copy();
    outmaterial.setCount(8);
    ResourceLocation uncompressLoc = new ResourceLocation(Reference.MOD_ID, "uncompress_" + id);
    registry.register(new ShapelessOreRecipe(uncompressLoc, outmaterial, condensed).setRegistryName(uncompressLoc));
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ShapelessOreRecipe(net.minecraftforge.oredict.ShapelessOreRecipe) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ShapelessOreRecipe (net.minecraftforge.oredict.ShapelessOreRecipe)24 ItemStack (net.minecraft.item.ItemStack)21 ShapedOreRecipe (net.minecraftforge.oredict.ShapedOreRecipe)19 ArrayList (java.util.ArrayList)3 Item (net.minecraft.item.Item)3 IRecipe (net.minecraft.item.crafting.IRecipe)3 ShapedRecipes (net.minecraft.item.crafting.ShapedRecipes)3 ShapelessRecipes (net.minecraft.item.crafting.ShapelessRecipes)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 List (java.util.List)2 Block (net.minecraft.block.Block)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 SpellRecipeItemsEvent (am2.api.events.SpellRecipeItemsEvent)1 ISkillTreeEntry (am2.api.spell.component.interfaces.ISkillTreeEntry)1 ISpellPart (am2.api.spell.component.interfaces.ISpellPart)1 ItemSpellPart (am2.items.ItemSpellPart)1 RecipeArsMagica (am2.items.RecipeArsMagica)1 ComparableItemStack (blusunrize.immersiveengineering.api.ComparableItemStack)1 ChemthrowerEffect (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect)1 ChemthrowerEffect_Extinguish (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Extinguish)1