Search in sources :

Example 96 with ShapedOreRecipe

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

the class RollingMachineRecipe method addShapedOreRecipe.

public void addShapedOreRecipe(ResourceLocation resourceLocation, ItemStack outputItemStack, Object... objectInputs) {
    Validate.notNull(outputItemStack);
    Validate.notNull(outputItemStack.getItem());
    if (objectInputs.length == 0) {
        // Quick way to crash
        Validate.notNull(null);
    }
    recipes.put(resourceLocation, new ShapedOreRecipe(resourceLocation, outputItemStack, objectInputs));
}
Also used : ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe)

Example 97 with ShapedOreRecipe

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

the class GuiAutoCrafting method renderRecipe.

// Based of vanilla code
public void renderRecipe(IRecipe recipe, int x, int y) {
    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableAlpha();
    mc.getTextureManager().bindTexture(RECIPE_BOOK_TEXTURE);
    this.drawTexturedModalRect(x, y, 152, 78, 24, 24);
    int recipeWidth = 3;
    int recipeHeight = 3;
    if (recipe instanceof ShapedRecipes) {
        ShapedRecipes shapedrecipes = (ShapedRecipes) recipe;
        recipeWidth = shapedrecipes.getWidth();
        recipeHeight = shapedrecipes.getHeight();
    }
    if (recipe instanceof ShapedOreRecipe) {
        ShapedOreRecipe shapedrecipes = (ShapedOreRecipe) recipe;
        recipeWidth = shapedrecipes.getRecipeWidth();
        recipeHeight = shapedrecipes.getRecipeHeight();
    }
    Iterator<Ingredient> ingredients = recipe.getIngredients().iterator();
    for (int rHeight = 0; rHeight < recipeHeight; ++rHeight) {
        int j1 = 3 + rHeight * 7;
        for (int rWidth = 0; rWidth < recipeWidth; ++rWidth) {
            if (ingredients.hasNext()) {
                ItemStack[] aitemstack = ingredients.next().getMatchingStacks();
                if (aitemstack.length != 0) {
                    int l1 = 3 + rWidth * 7;
                    GlStateManager.pushMatrix();
                    int i2 = (int) ((float) (x + l1) / 0.42F - 3.0F);
                    int j2 = (int) ((float) (y + j1) / 0.42F - 3.0F);
                    GlStateManager.scale(0.42F, 0.42F, 1.0F);
                    GlStateManager.enableLighting();
                    mc.getRenderItem().renderItemAndEffectIntoGUI(aitemstack[0], i2, j2);
                    GlStateManager.disableLighting();
                    GlStateManager.popMatrix();
                }
            }
        }
    }
    GlStateManager.disableAlpha();
    RenderHelper.disableStandardItemLighting();
}
Also used : ShapedRecipes(net.minecraft.item.crafting.ShapedRecipes) Ingredient(net.minecraft.item.crafting.Ingredient) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 98 with ShapedOreRecipe

use of net.minecraftforge.oredict.ShapedOreRecipe in project Metalworks by canitzp.

the class ItemToolCollection method registerRecipes.

public void registerRecipes(final Map<ResourceLocation, IRecipe> recipes, Object ingotStackOrString) {
    recipes.put(new ResourceLocation(Metalworks.MODID, "pickaxe_" + this.material.name()), new ShapedOreRecipe(null, pickaxe, "mmm", " s ", " s ", 'm', ingotStackOrString, 's', "stickWood"));
    recipes.put(new ResourceLocation(Metalworks.MODID, "axe_" + this.material.name()), new ShapedOreRecipe(null, axe, "mm", "ms", " s", 'm', ingotStackOrString, 's', "stickWood"));
    recipes.put(new ResourceLocation(Metalworks.MODID, "sword_" + this.material.name()), new ShapedOreRecipe(null, sword, "m", "m", "s", 'm', ingotStackOrString, 's', "stickWood"));
    recipes.put(new ResourceLocation(Metalworks.MODID, "shovel_" + this.material.name()), new ShapedOreRecipe(null, shovel, "m", "s", "s", 'm', ingotStackOrString, 's', "stickWood"));
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe)

Example 99 with ShapedOreRecipe

use of net.minecraftforge.oredict.ShapedOreRecipe in project EnderIO by SleepyTrousers.

the class MaterialRecipes method register.

@SubscribeEvent
public static void register(@Nonnull RegistryEvent.Register<IRecipe> event) {
    final IForgeRegistry<IRecipe> registry = event.getRegistry();
    for (Alloy alloy : Alloy.values()) {
        registry.register(new ShapedOreRecipe(null, alloy.getStackBlock(), "iii", "iii", "iii", 'i', alloy.getOreIngot()).setRegistryName(Crafting.mkRL("Auto: " + alloy.getBaseName() + " 1 block to 9 ingots")));
        registry.register(new ShapelessOreRecipe(null, alloy.getStackIngot(9), alloy.getOreBlock()).setRegistryName(Crafting.mkRL("Auto: " + alloy.getBaseName() + " 9 ingots to 1 block")));
        registry.register(new ShapedOreRecipe(null, alloy.getStackIngot(), "nnn", "nnn", "nnn", 'n', alloy.getOreNugget()).setRegistryName(Crafting.mkRL("Auto: " + alloy.getBaseName() + " 9 nuggets to 1 ingot")));
        registry.register(new ShapelessOreRecipe(null, alloy.getStackNugget(9), alloy.getStackIngot()).setRegistryName(Crafting.mkRL("Auto: " + alloy.getBaseName() + " 1 ingot to 9 nuggets")));
    }
    for (EnumDyeColor color : EnumDyeColor.values()) {
        for (FusedQuartzType type : FusedQuartzType.values()) {
            registry.register(new ShapedOreRecipe(null, new ItemStack(type.getBlock(), 8, color.getMetadata()), "GGG", "CGG", "GGG", 'G', type.getOreDictName(), 'C', "dye" + MaterialOredicts.dyes[color.getDyeDamage()]).setRegistryName(Crafting.mkRL("Auto: Coloring " + type.getName() + " with " + color.getUnlocalizedName())));
        }
    }
    registry.register(new NutritiousStickRecipe().setRegistryName(Crafting.mkRL("Auto: NutritiousStickRecipe")));
}
Also used : IRecipe(net.minecraft.item.crafting.IRecipe) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) ShapelessOreRecipe(net.minecraftforge.oredict.ShapelessOreRecipe) NutritiousStickRecipe(crazypants.enderio.base.material.material.NutritiousStickRecipe) FusedQuartzType(crazypants.enderio.base.material.glass.FusedQuartzType) ItemStack(net.minecraft.item.ItemStack) Alloy(crazypants.enderio.base.material.alloy.Alloy) EnumDyeColor(net.minecraft.item.EnumDyeColor) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 100 with ShapedOreRecipe

use of net.minecraftforge.oredict.ShapedOreRecipe in project GregTech by GregTechCE.

the class ModHandler method addMirroredShapedRecipe.

// /////////////////////////////////////////////////
// Crafting Recipe Helpers          //
// /////////////////////////////////////////////////
/**
 * Adds Shaped Crafting Recipes.
 * <p/>
 * MetaValueItem's are converted to ItemStack via {@link MetaItem.MetaValueItem#getStackForm()} method.
 * <p/>
 * For Enums - {@link Enum#name()} is called.
 * <p/>
 * For UnificationEntry - {@link UnificationEntry#toString()} is called.
 * <p/>
 * Lowercase Letters are reserved for Tools. They are as follows:
 * <p/>
 * <ul>
 * <li>'b' -  ToolDictNames.craftingToolBlade</li>
 * <li>'c' -  ToolDictNames.craftingToolCrowbar</li>
 * <li>'d' -  ToolDictNames.craftingToolScrewdriver</li>
 * <li>'f' -  ToolDictNames.craftingToolFile</li>
 * <li>'h' -  ToolDictNames.craftingToolHardHammer</li>
 * <li>'i' -  ToolDictNames.craftingToolSolderingIron</li>
 * <li>'j' -  ToolDictNames.craftingToolSolderingMetal</li>
 * <li>'k' -  ToolDictNames.craftingToolKnife</li>
 * <li>'m' -  ToolDictNames.craftingToolMortar</li>
 * <li>'p' -  ToolDictNames.craftingToolDrawplate</li>
 * <li>'r' -  ToolDictNames.craftingToolSoftHammer</li>
 * <li>'s' -  ToolDictNames.craftingToolSaw</li>
 * <li>'w' -  ToolDictNames.craftingToolWrench</li>
 * <li>'x' -  ToolDictNames.craftingToolWireCutter</li>
 * </ul>
 */
public static void addMirroredShapedRecipe(String regName, ItemStack result, Object... recipe) {
    result = OreDictUnifier.getUnificated(result);
    boolean skip = false;
    if (result.isEmpty()) {
        GTLog.logger.error("Result cannot be an empty ItemStack. Recipe: {}", regName);
        GTLog.logger.error("Stacktrace:", new IllegalArgumentException());
        skip = true;
    }
    skip |= validateRecipe(regName, recipe);
    if (skip) {
        RecipeMap.setFoundInvalidRecipe(true);
        return;
    }
    IRecipe shapedOreRecipe = new ShapedOreRecipe(new ResourceLocation(GTValues.MODID, "general"), result.copy(), finalizeShapedRecipeInput(recipe)).setMirrored(true).setRegistryName(regName);
    ForgeRegistries.RECIPES.register(shapedOreRecipe);
}
Also used : IRecipe(net.minecraft.item.crafting.IRecipe) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) ResourceLocation(net.minecraft.util.ResourceLocation)

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