Search in sources :

Example 51 with Ingredient

use of net.minecraft.item.crafting.Ingredient in project Adventurers-Toolbox by the-realest-stu.

the class ModRecipes method getToolHeadSchematicRecipe.

private static IRecipe getToolHeadSchematicRecipe(ItemStack output, String material, String type, int cost) {
    NonNullList<Ingredient> inputs = NonNullList.withSize(cost + 1, Ingredient.EMPTY);
    ItemStack schematic = new ItemStack(ModItems.schematic);
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setString(ItemSchematic.type_tag, type);
    schematic.setTagCompound(nbt);
    Ingredient schematicIngredient = new IngredientNBT(schematic) {
    };
    inputs.set(0, schematicIngredient);
    for (int i = 1; i <= cost; i++) {
        inputs.set(i, new OreIngredient(material));
    }
    return new ShapelessOreRecipe(null, inputs, output);
}
Also used : IngredientNBT(net.minecraftforge.common.crafting.IngredientNBT) Ingredient(net.minecraft.item.crafting.Ingredient) OreIngredient(net.minecraftforge.oredict.OreIngredient) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ShapelessOreRecipe(net.minecraftforge.oredict.ShapelessOreRecipe) OreIngredient(net.minecraftforge.oredict.OreIngredient) ItemStack(net.minecraft.item.ItemStack)

Example 52 with Ingredient

use of net.minecraft.item.crafting.Ingredient in project Adventurers-Toolbox by the-realest-stu.

the class CommonProxy method processRecipes.

protected void processRecipes() {
    if (ForgeRegistries.RECIPES instanceof IForgeRegistryModifiable) {
        IForgeRegistryModifiable registry = (IForgeRegistryModifiable) ForgeRegistries.RECIPES;
        Entry<ResourceLocation, IRecipe>[] recipeEntries = ForgeRegistries.RECIPES.getEntries().toArray(new Entry[ForgeRegistries.RECIPES.getEntries().size()]);
        for (int recipeIndex = 0; recipeIndex < recipeEntries.length; recipeIndex++) {
            Entry<ResourceLocation, IRecipe> recipeEntry = recipeEntries[recipeIndex];
            IRecipe recipe = recipeEntry.getValue();
            NonNullList<Ingredient> ingredients = recipe.getIngredients();
            Item output = recipe.getRecipeOutput().getItem();
            String rp = output.getRegistryName().getResourcePath();
            if ((output instanceof ItemHoe || output instanceof ItemAxe || output instanceof ItemSpade || output instanceof ItemPickaxe || output instanceof ItemSword) || (output instanceof ItemTool && (rp.contains("pick") || rp.contains("axe") || rp.contains("shovel") || rp.contains("spade"))) || (output instanceof ItemTool && (output.getRegistryName().getResourceDomain().equals("thermalfoundation") && rp.contains("hammer")))) {
                String materialName = output instanceof ItemHoe ? ((ItemHoe) output).getMaterialName() : output instanceof ItemSword ? ((ItemSword) output).getToolMaterialName() : ((ItemTool) output).getToolMaterialName();
                if (Materials.canReplaceMaterial(materialName, recipe.getRecipeOutput())) {
                    // System.out.println(materialName);
                    registry.remove(recipeEntry.getKey());
                    registry.register(new IRecipe() {

                        private ResourceLocation registryName;

                        @Override
                        public IRecipe setRegistryName(ResourceLocation name) {
                            this.registryName = name;
                            return this;
                        }

                        @Override
                        public ResourceLocation getRegistryName() {
                            return this.registryName;
                        }

                        @Override
                        public Class<IRecipe> getRegistryType() {
                            return IRecipe.class;
                        }

                        @Override
                        public boolean matches(InventoryCrafting inv, World worldIn) {
                            return false;
                        }

                        @Override
                        public ItemStack getCraftingResult(InventoryCrafting inv) {
                            return ItemStack.EMPTY;
                        }

                        @Override
                        public boolean canFit(int width, int height) {
                            return false;
                        }

                        @Override
                        public ItemStack getRecipeOutput() {
                            return ItemStack.EMPTY;
                        }
                    }.setRegistryName(recipeEntry.getKey()));
                    removed_recipes.add(recipeEntry.getKey());
                } else {
                    System.out.println(output.getRegistryName() + " -> " + materialName);
                }
            } else {
                for (int i = 0; i < ingredients.size(); i++) {
                    ItemStack[] matchingStacks = ingredients.get(i).getMatchingStacks();
                    boolean flag = false;
                    Item ingredientItem = null;
                    for (int j = 0; j < matchingStacks.length && !flag; j++) {
                        Item item = matchingStacks[j].getItem();
                        if (!getToolReplacement(item).isEmpty()) {
                            ingredientItem = item;
                            flag = true;
                        }
                    }
                    if (flag && ingredientItem != null && !getToolReplacement(ingredientItem).isEmpty()) {
                        ingredients.set(i, new IngredientNBT(getToolReplacement(ingredientItem)) {
                        });
                    }
                }
            }
        }
    }
}
Also used : ItemSword(net.minecraft.item.ItemSword) ItemAxe(net.minecraft.item.ItemAxe) IForgeRegistryModifiable(net.minecraftforge.registries.IForgeRegistryModifiable) ItemTool(net.minecraft.item.ItemTool) IngredientNBT(net.minecraftforge.common.crafting.IngredientNBT) IRecipe(net.minecraft.item.crafting.IRecipe) InventoryCrafting(net.minecraft.inventory.InventoryCrafting) World(net.minecraft.world.World) Item(net.minecraft.item.Item) ItemHoe(net.minecraft.item.ItemHoe) Entry(java.util.Map.Entry) Ingredient(net.minecraft.item.crafting.Ingredient) ItemSpade(net.minecraft.item.ItemSpade) ResourceLocation(net.minecraft.util.ResourceLocation) ItemPickaxe(net.minecraft.item.ItemPickaxe) ItemStack(net.minecraft.item.ItemStack)

Example 53 with Ingredient

use of net.minecraft.item.crafting.Ingredient in project BloodMagic by WayofTime.

the class BloodMagicRecipeRegistrar method addAlchemyTable.

@Override
public void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks, @Nonnegative int minimumTier, @Nonnull Ingredient... input) {
    Preconditions.checkNotNull(output, "output cannot be null.");
    Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
    Preconditions.checkArgument(ticks >= 0, "ticks cannot be negative.");
    Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
    Preconditions.checkNotNull(input, "input cannot be null.");
    NonNullList<Ingredient> inputs = NonNullList.from(Ingredient.EMPTY, input);
    alchemyRecipes.add(new RecipeAlchemyTable(inputs, output, syphon, ticks, minimumTier));
}
Also used : Ingredient(net.minecraft.item.crafting.Ingredient) RecipeAlchemyTable(WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyTable)

Example 54 with Ingredient

use of net.minecraft.item.crafting.Ingredient in project BloodMagic by WayofTime.

the class BloodMagicRecipeRegistrar method addTartaricForge.

public void addTartaricForge(@Nonnull ItemStack output, @Nonnegative double minimumSouls, @Nonnegative double soulDrain, @Nonnull Object... input) {
    Preconditions.checkNotNull(output, "output cannot be null.");
    Preconditions.checkArgument(minimumSouls >= 0, "minimumSouls cannot be negative.");
    Preconditions.checkArgument(soulDrain >= 0, "soulDrain cannot be negative.");
    Preconditions.checkNotNull(input, "input cannot be null.");
    List<Ingredient> ingredients = Lists.newArrayList();
    for (Object object : input) {
        if (object instanceof ItemStack && ((ItemStack) object).getItem() instanceof IBloodOrb) {
            ingredients.add(new IngredientBloodOrb(((IBloodOrb) ((ItemStack) object).getItem()).getOrb((ItemStack) object)));
            continue;
        }
        ingredients.add(CraftingHelper.getIngredient(object));
    }
    addTartaricForge(output, minimumSouls, soulDrain, ingredients.toArray(new Ingredient[0]));
}
Also used : IngredientBloodOrb(WayofTime.bloodmagic.core.recipe.IngredientBloodOrb) Ingredient(net.minecraft.item.crafting.Ingredient) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) ItemStack(net.minecraft.item.ItemStack)

Example 55 with Ingredient

use of net.minecraft.item.crafting.Ingredient in project BloodMagic by WayofTime.

the class BloodMagicRecipeRegistrar method addAlchemyTable.

public void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks, @Nonnegative int minimumTier, @Nonnull Object... input) {
    Preconditions.checkNotNull(output, "output cannot be null.");
    Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
    Preconditions.checkArgument(ticks >= 0, "ticks cannot be negative.");
    Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
    Preconditions.checkNotNull(input, "input cannot be null.");
    List<Ingredient> ingredients = Lists.newArrayList();
    for (Object object : input) {
        if (object instanceof ItemStack && ((ItemStack) object).getItem() instanceof IBloodOrb) {
            ingredients.add(new IngredientBloodOrb(((IBloodOrb) ((ItemStack) object).getItem()).getOrb((ItemStack) object)));
            continue;
        }
        ingredients.add(CraftingHelper.getIngredient(object));
    }
    addAlchemyTable(output, syphon, ticks, minimumTier, ingredients.toArray(new Ingredient[0]));
}
Also used : IngredientBloodOrb(WayofTime.bloodmagic.core.recipe.IngredientBloodOrb) Ingredient(net.minecraft.item.crafting.Ingredient) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Ingredient (net.minecraft.item.crafting.Ingredient)57 ItemStack (net.minecraft.item.ItemStack)49 ResourceLocation (net.minecraft.util.ResourceLocation)12 ArrayList (java.util.ArrayList)10 JsonElement (com.google.gson.JsonElement)8 JsonObject (com.google.gson.JsonObject)7 List (java.util.List)7 IRecipe (net.minecraft.item.crafting.IRecipe)7 JsonArray (com.google.gson.JsonArray)6 Block (net.minecraft.block.Block)6 Item (net.minecraft.item.Item)6 HashMap (java.util.HashMap)5 IBlockState (net.minecraft.block.state.IBlockState)5 ShapelessRecipes (net.minecraft.item.crafting.ShapelessRecipes)5 FluidStack (net.minecraftforge.fluids.FluidStack)5 JsonParser (com.google.gson.JsonParser)4 File (java.io.File)4 FileNotFoundException (java.io.FileNotFoundException)4 FileReader (java.io.FileReader)4 EntityItem (net.minecraft.entity.item.EntityItem)4