Search in sources :

Example 1 with TableRecipeShaped

use of com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped in project ExtendedCrafting by BlakeBr0.

the class TableCrafting method addShapedMirrored.

@ZenMethod
public static void addShapedMirrored(int tier, IItemStack output, IIngredient[][] ingredients) {
    if (tier > 4 || tier < 0) {
        CraftTweakerAPI.getLogger().logError("Unable to assign a tier to the Table Recipe for stack " + output.getDisplayName() + ". Tier cannot be greater than 4 or less than 0.");
        tier = 0;
    }
    int height = ingredients.length;
    int width = 0;
    for (IIngredient[] row : ingredients) {
        if (width < row.length) {
            width = row.length;
        }
    }
    NonNullList<Ingredient> input = NonNullList.withSize(height * width, Ingredient.EMPTY);
    Map<Integer, Function<ItemStack, ItemStack>> transformers = new HashMap<>();
    int i = 0;
    for (int a = 0; a < height; a++) {
        for (int b = 0; b < ingredients[a].length; b++) {
            IIngredient iing = ingredients[a][b];
            Ingredient ing = CraftingHelper.getIngredient(toObject(iing));
            if (ing == null) {
                ing = Ingredient.EMPTY;
            }
            i = a * width + b;
            input.set(i, ing);
            if (ing != Ingredient.EMPTY && iing.hasNewTransformers()) {
                transformers.put(i, stack -> {
                    IItemStack istack = iing.applyNewTransform(CraftTweakerMC.getIItemStack(stack));
                    ItemStack transformed = CraftTweakerMC.getItemStack(istack);
                    return transformed;
                });
            }
        }
    }
    CraftTweakerAPI.apply(new Add(new TableRecipeShaped(tier, toStack(output), width, height, input).setMirrored(true).withTransformers(transformers)));
}
Also used : TableRecipeShaped(com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped) IIngredient(crafttweaker.api.item.IIngredient) HashMap(java.util.HashMap) Function(java.util.function.Function) Ingredient(net.minecraft.item.crafting.Ingredient) IIngredient(crafttweaker.api.item.IIngredient) IItemStack(crafttweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 2 with TableRecipeShaped

use of com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped in project ExtendedCrafting by BlakeBr0.

the class TableCrafting method addShaped.

@ZenMethod
public static void addShaped(int tier, IItemStack output, IIngredient[][] ingredients) {
    if (tier > 4 || tier < 0) {
        CraftTweakerAPI.getLogger().logError("Unable to assign a tier to the Table Recipe for stack " + output.getDisplayName() + ". Tier cannot be greater than 4 or less than 0.");
        tier = 0;
    }
    int height = ingredients.length;
    int width = 0;
    for (IIngredient[] row : ingredients) {
        if (width < row.length) {
            width = row.length;
        }
    }
    NonNullList<Ingredient> input = NonNullList.withSize(height * width, Ingredient.EMPTY);
    Map<Integer, Function<ItemStack, ItemStack>> transformers = new HashMap<>();
    int i = 0;
    for (int a = 0; a < height; a++) {
        for (int b = 0; b < ingredients[a].length; b++) {
            IIngredient iing = ingredients[a][b];
            Ingredient ing = CraftingHelper.getIngredient(toObject(iing));
            if (ing == null) {
                ing = Ingredient.EMPTY;
            }
            i = a * width + b;
            input.set(i, ing);
            if (ing != Ingredient.EMPTY && iing.hasNewTransformers()) {
                transformers.put(i, stack -> {
                    IItemStack istack = iing.applyNewTransform(CraftTweakerMC.getIItemStack(stack));
                    ItemStack transformed = CraftTweakerMC.getItemStack(istack);
                    return transformed;
                });
            }
        }
    }
    CraftTweakerAPI.apply(new Add(new TableRecipeShaped(tier, toStack(output), width, height, input).withTransformers(transformers)));
}
Also used : TableRecipeShaped(com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped) IIngredient(crafttweaker.api.item.IIngredient) HashMap(java.util.HashMap) Function(java.util.function.Function) Ingredient(net.minecraft.item.crafting.Ingredient) IIngredient(crafttweaker.api.item.IIngredient) IItemStack(crafttweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 3 with TableRecipeShaped

use of com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped in project ExtendedCrafting by BlakeBr0.

the class EnderCrafterRecipeManager method addShaped.

public TableRecipeShaped addShaped(ItemStack result, int time, Object... recipe) {
    TableRecipeShaped craft = new TableRecipeShaped(1, result, recipe);
    if (ModConfig.confEnderEnabled) {
        craft.enderCrafterRecipeTimeRequired = time;
        this.recipes.add(craft);
    }
    return craft;
}
Also used : TableRecipeShaped(com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped)

Example 4 with TableRecipeShaped

use of com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped in project ExtendedCrafting by BlakeBr0.

the class EnderCrafting method addShaped.

@ZenMethod
public static void addShaped(IItemStack output, IIngredient[][] ingredients, int seconds) {
    int height = ingredients.length;
    int width = 0;
    for (IIngredient[] row : ingredients) {
        if (width < row.length) {
            width = row.length;
        }
    }
    NonNullList<Ingredient> input = NonNullList.withSize(height * width, Ingredient.EMPTY);
    int i = 0;
    for (int a = 0; a < height; a++) {
        for (int b = 0; b < ingredients[a].length; b++) {
            Ingredient ing = CraftingHelper.getIngredient(toObject(ingredients[a][b]));
            if (ing == null) {
                ing = Ingredient.EMPTY;
            }
            i = a * width + b;
            input.set(i, ing);
        }
    }
    TableRecipeShaped recipe = new TableRecipeShaped(1, toStack(output), width, height, input);
    recipe.enderCrafterRecipeTimeRequired = seconds;
    CraftTweakerAPI.apply(new Add(recipe));
}
Also used : TableRecipeShaped(com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped) IIngredient(crafttweaker.api.item.IIngredient) Ingredient(net.minecraft.item.crafting.Ingredient) IIngredient(crafttweaker.api.item.IIngredient) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Aggregations

TableRecipeShaped (com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped)4 IIngredient (crafttweaker.api.item.IIngredient)3 Ingredient (net.minecraft.item.crafting.Ingredient)3 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)3 IItemStack (crafttweaker.api.item.IItemStack)2 HashMap (java.util.HashMap)2 Function (java.util.function.Function)2 ItemStack (net.minecraft.item.ItemStack)2