Search in sources :

Example 66 with ShapedOreRecipe

use of net.minecraftforge.oredict.ShapedOreRecipe 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 67 with ShapedOreRecipe

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

the class ItemSheetMetalTools method onPostInit.

@Override
public void onPostInit() {
    //TODO add rivets to small cone recipe
    if (Engine.itemSheetMetal != null) {
        //Plate creation
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.FULL.stack(), "IH", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'H', getHammer()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.RIVETS.stack(16), "H", "I", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'H', getHammer()));
        //Sheet metal reduction recipes
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.HALF.stack(2), "IC", 'I', ItemSheetMetal.SheetMetal.FULL.stack(), 'C', getShears()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.QUARTER.stack(2), "IC", 'I', ItemSheetMetal.SheetMetal.HALF.stack(), 'C', getShears()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.EIGHTH.stack(2), "IC", 'I', ItemSheetMetal.SheetMetal.QUARTER.stack(), 'C', getShears()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.THIRD.stack(3), "I", "C", 'I', ItemSheetMetal.SheetMetal.FULL.stack(), 'C', getShears()));
        //Cone creations
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.TRIANGLE.stack(4), "I ", " C", 'I', ItemSheetMetal.SheetMetal.FULL.stack(), 'C', getShears()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.CONE_MICRO.stack(), "I ", " H", 'I', ItemSheetMetal.SheetMetal.TRIANGLE.stack(), 'H', getHammer()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.CONE_SMALL.stack(), " I ", "IHI", " I ", 'I', ItemSheetMetal.SheetMetal.TRIANGLE.stack(), 'H', getHammer()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.CONE_MEDIUM.stack(), " II", "IHI", "II ", 'I', ItemSheetMetal.SheetMetal.TRIANGLE.stack(), 'H', getHammer()));
        //Fine creation
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.FIN_MICRO.stack(2), "C", "I", 'I', ItemSheetMetal.SheetMetal.TRIANGLE.stack(), 'C', getShears()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.FIN_SMALL.stack(2), "I ", " C", 'I', ItemSheetMetal.SheetMetal.HALF.stack(), 'C', getShears()));
        //Curved plates
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.CURVED_1.stack(), "IH", 'I', ItemSheetMetal.SheetMetal.FULL.stack(), 'H', getHammer()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.CURVED_2.stack(), "IH", 'I', ItemSheetMetal.SheetMetal.CURVED_1.stack(), 'H', getHammer()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.CURVED_3.stack(), "IH", 'I', ItemSheetMetal.SheetMetal.CURVED_2.stack(), 'H', getHammer()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.CURVED_4.stack(), "IH", 'I', ItemSheetMetal.SheetMetal.CURVED_3.stack(), 'H', getHammer()));
        //Cylinders
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.SMALL_CYLINDER.stack(), "IRH", 'I', ItemSheetMetal.SheetMetal.CURVED_4.stack(), 'H', getHammer(), 'R', ItemSheetMetal.SheetMetal.RIVETS.stack()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.HALF_CYLINDER.stack(), "IRI", 'I', ItemSheetMetal.SheetMetal.CURVED_4.stack(), 'R', ItemSheetMetal.SheetMetal.RIVETS.stack()));
        GameRegistry.addRecipe(new RecipeSheetMetal(ItemSheetMetal.SheetMetal.CYLINDER.stack(), "IRI", 'I', ItemSheetMetal.SheetMetal.HALF_CYLINDER.stack(), 'R', ItemSheetMetal.SheetMetal.RIVETS.stack()));
    }
    GameRegistry.addRecipe(new ShapedOreRecipe(getHammer(), "III", " I ", " S ", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'S', OreNames.WOOD_STICK));
    GameRegistry.addRecipe(new ShapedOreRecipe(getShears(), "I I", " I ", "S S", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'S', OreNames.WOOD_STICK));
}
Also used : RecipeSheetMetal(com.builtbroken.mc.lib.recipe.item.sheetmetal.RecipeSheetMetal) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe)

Example 68 with ShapedOreRecipe

use of net.minecraftforge.oredict.ShapedOreRecipe 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 69 with ShapedOreRecipe

use of net.minecraftforge.oredict.ShapedOreRecipe in project Guide-API by TeamAmeriFrance.

the class TestBook method buildBook.

@Nullable
@Override
public Book buildBook() {
    book = new Book();
    book.setAuthor("TehNut");
    book.setColor(Color.BLUE);
    book.setDisplayName("Display Name");
    book.setTitle("Title message");
    book.setWelcomeMessage("Is this still a thing?");
    List<CategoryAbstract> categories = Lists.newArrayList();
    Map<ResourceLocation, EntryAbstract> entries = Maps.newHashMap();
    List<IPage> pages = Lists.newArrayList();
    pages.add(new PageText("Hello, this is\nsome text"));
    pages.add(new PageFurnaceRecipe(Blocks.COBBLESTONE));
    pages.add(new PageIRecipe(new ShapedOreRecipe(Items.ACACIA_BOAT, "X X", "XXX", 'X', "plankWood")));
    Entry entry = new EntryItemStack(pages, "test.entry.name", new ItemStack(Items.POTATO));
    entries.put(new ResourceLocation("guideapi", "entry"), entry);
    categories.add(new CategoryItemStack(entries, "test.category.name", new ItemStack(Items.BANNER)));
    book.setCategoryList(categories);
    book.setRegistryName(new ResourceLocation("guideapi", "test_book"));
    return book;
}
Also used : EntryAbstract(amerifrance.guideapi.api.impl.abstraction.EntryAbstract) PageFurnaceRecipe(amerifrance.guideapi.page.PageFurnaceRecipe) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) PageText(amerifrance.guideapi.page.PageText) EntryItemStack(amerifrance.guideapi.entry.EntryItemStack) CategoryItemStack(amerifrance.guideapi.category.CategoryItemStack) Entry(amerifrance.guideapi.api.impl.Entry) CategoryAbstract(amerifrance.guideapi.api.impl.abstraction.CategoryAbstract) PageIRecipe(amerifrance.guideapi.page.PageIRecipe) Book(amerifrance.guideapi.api.impl.Book) ResourceLocation(net.minecraft.util.ResourceLocation) EntryItemStack(amerifrance.guideapi.entry.EntryItemStack) ItemStack(net.minecraft.item.ItemStack) CategoryItemStack(amerifrance.guideapi.category.CategoryItemStack) Nullable(javax.annotation.Nullable)

Example 70 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)

Aggregations

ShapedOreRecipe (net.minecraftforge.oredict.ShapedOreRecipe)73 ItemStack (net.minecraft.item.ItemStack)63 ShapelessOreRecipe (net.minecraftforge.oredict.ShapelessOreRecipe)19 ResourceLocation (net.minecraft.util.ResourceLocation)8 IRecipe (net.minecraft.item.crafting.IRecipe)7 ArrayList (java.util.ArrayList)6 Item (net.minecraft.item.Item)6 List (java.util.List)5 ShapedRecipes (net.minecraft.item.crafting.ShapedRecipes)5 Block (net.minecraft.block.Block)4 ShapelessRecipes (net.minecraft.item.crafting.ShapelessRecipes)3 Book (amerifrance.guideapi.api.impl.Book)2 CategoryAbstract (amerifrance.guideapi.api.impl.abstraction.CategoryAbstract)2 CategoryItemStack (amerifrance.guideapi.category.CategoryItemStack)2 EntryItemStack (amerifrance.guideapi.entry.EntryItemStack)2 PageFurnaceRecipe (amerifrance.guideapi.page.PageFurnaceRecipe)2 PageIRecipe (amerifrance.guideapi.page.PageIRecipe)2 PageText (amerifrance.guideapi.page.PageText)2 AgriNuggetType (com.infinityraider.agricraft.reference.AgriNuggetType)2 SpellRecipeItemsEvent (am2.api.events.SpellRecipeItemsEvent)1