Search in sources :

Example 81 with ShapedOreRecipe

use of net.minecraftforge.oredict.ShapedOreRecipe in project Witchworks by Um-Mitternacht.

the class ShapedRecipe method build.

public void build() {
    final List<Object> recipes = new ArrayList<>();
    if (mirror) {
        recipes.add(true);
    }
    if (rows.isEmpty())
        throw new IllegalArgumentException("There must be at least one row in the recipe, please report this to the mod author!");
    Collections.addAll(recipes, rows.toArray());
    characters.forEach((character, o) -> {
        recipes.add(character);
        recipes.add(o);
    });
    final ShapedOreRecipe recipe = new ShapedOreRecipe(out, recipes.toArray());
    CraftingManager.getInstance().getRecipeList().add(recipe);
}
Also used : ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe)

Example 82 with ShapedOreRecipe

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

the class CraftingPlugin method addRecipe.

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

Example 83 with ShapedOreRecipe

use of net.minecraftforge.oredict.ShapedOreRecipe in project AgriCraft by AgriCraft.

the class ItemNugget method registerRecipes.

@Override
public void registerRecipes(IForgeRegistry<IRecipe> registry) {
    for (AgriNuggetType type : AgriNuggetType.values()) {
        // 1) Ore Dictionary registration.
        AgriCore.getLogger("agricraft").info("Registering in Ore Dictionary: {0}", type.nugget);
        ItemStack oneNugget = new ItemStack(this, 1, type.ordinal());
        OreDictionary.registerOre(type.nugget, oneNugget);
        // 2) Conditional recipes. Only if the ingot exists, because AgriCraft doesn't add its own.
        ItemStack ingot = OreDictHelper.getIngot(type.ingot);
        if (!ingot.isEmpty()) {
            AgriCore.getLogger("agricraft").info("Adding a recipe to convert nine {0} into one {1}", type.nugget, type.ingot);
            final ResourceLocation group = new ResourceLocation(AgriCraft.instance.getModId(), "combine_nugget");
            final ResourceLocation name = new ResourceLocation(AgriCraft.instance.getModId(), "combine_nugget_" + type.name().toLowerCase());
            final ShapedOreRecipe recipe = new ShapedOreRecipe(group, ingot, "nnn", "nnn", "nnn", 'n', type.nugget);
            recipe.setRegistryName(name);
            AgriCore.getLogger("agricraft").info("Registering nugget recipe: {0}!", recipe.getRegistryName());
            registry.register(recipe);
        }
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) AgriNuggetType(com.infinityraider.agricraft.reference.AgriNuggetType) ItemStack(net.minecraft.item.ItemStack)

Example 84 with ShapedOreRecipe

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

the class InteractionCondensedOutputs method addCondensingRecipe.

private void addCondensingRecipe(ForgeRegistry<IRecipe> registry, String id, ItemStack output, ItemStack material, ItemStack frame) {
    ItemStack outmaterial = material.copy();
    outmaterial.setCount(8);
    ResourceLocation compressLoc = new ResourceLocation(Reference.MOD_ID, "compress_" + id);
    registry.register(new ShapedOreRecipe(compressLoc, output, "aaa", "aba", "aaa", 'a', material, 'b', frame).setRegistryName(compressLoc));
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 85 with ShapedOreRecipe

use of net.minecraftforge.oredict.ShapedOreRecipe in project Charset by CharsetMC.

the class RecipeReplacement method process.

public void process(Collection<IRecipe> registry) {
    for (IRecipe recipe : registry) {
        ResourceLocation recipeName = recipe.getRegistryName();
        boolean dirty = false;
        if (recipe instanceof ShapedRecipes || recipe instanceof ShapelessRecipes || recipe instanceof ShapedOreRecipe || recipe instanceof ShapelessOreRecipe) {
            NonNullList<Ingredient> ingredients = recipe.getIngredients();
            for (int i = 0; i < ingredients.size(); i++) {
                Ingredient ing = ingredients.get(i);
                Ingredient ingNew = replaceIngredient(ing);
                if (ingNew != null) {
                    ingredients.set(i, ingNew);
                    dirty = true;
                }
            }
        } else if (recipe instanceof RecipeCharset) {
            TCharObjectMap<Ingredient> charToIngredient = ((RecipeCharset) recipe).charToIngredient;
            NonNullList<Ingredient> ingredients = recipe.getIngredients();
            for (int i = 0; i < ingredients.size(); i++) {
                Ingredient ing = ingredients.get(i);
                Ingredient ingNew = replaceIngredient(ing);
                if (ingNew != null) {
                    ingredients.set(i, ingNew);
                    TCharIterator iterator = charToIngredient.keySet().iterator();
                    while (iterator.hasNext()) {
                        char c = iterator.next();
                        if (charToIngredient.get(c) == ing) {
                            charToIngredient.put(c, ing);
                        }
                    }
                    dirty = true;
                }
            }
        }
        if (dirty) {
            ModCharset.logger.info("Successfully edited " + recipeName + "!");
        }
    }
}
Also used : ShapedRecipes(net.minecraft.item.crafting.ShapedRecipes) IRecipe(net.minecraft.item.crafting.IRecipe) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) TCharIterator(gnu.trove.iterator.TCharIterator) TCharObjectMap(gnu.trove.map.TCharObjectMap) Ingredient(net.minecraft.item.crafting.Ingredient) OreIngredient(net.minecraftforge.oredict.OreIngredient) NonNullList(net.minecraft.util.NonNullList) ResourceLocation(net.minecraft.util.ResourceLocation) ShapelessOreRecipe(net.minecraftforge.oredict.ShapelessOreRecipe) ShapelessRecipes(net.minecraft.item.crafting.ShapelessRecipes)

Aggregations

ShapedOreRecipe (net.minecraftforge.oredict.ShapedOreRecipe)132 ItemStack (net.minecraft.item.ItemStack)94 ShapelessOreRecipe (net.minecraftforge.oredict.ShapelessOreRecipe)35 IRecipe (net.minecraft.item.crafting.IRecipe)22 ResourceLocation (net.minecraft.util.ResourceLocation)19 ShapedRecipes (net.minecraft.item.crafting.ShapedRecipes)15 ArrayList (java.util.ArrayList)13 ShapelessRecipes (net.minecraft.item.crafting.ShapelessRecipes)10 List (java.util.List)7 Item (net.minecraft.item.Item)7 ShapedPrimer (net.minecraftforge.common.crafting.CraftingHelper.ShapedPrimer)5 Block (net.minecraft.block.Block)4 EnumDyeColor (net.minecraft.item.EnumDyeColor)4 Ingredient (net.minecraft.item.crafting.Ingredient)4 EnumGem (net.silentchaos512.gems.lib.EnumGem)4 PacketRegistry (pl.asie.charset.lib.network.PacketRegistry)4 JsonObject (com.google.gson.JsonObject)3 Pair (com.builtbroken.jlib.type.Pair)2 JsonArray (com.google.gson.JsonArray)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2