Search in sources :

Example 1 with TableRecipeShapeless

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

the class TableCrafting method addShapeless.

@ZenMethod
public static void addShapeless(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;
    }
    Map<Integer, Function<ItemStack, ItemStack>> transformers = new HashMap<>();
    for (int i = 0; i < ingredients.length; i++) {
        IIngredient iing = ingredients[i];
        Ingredient ing = CraftingHelper.getIngredient(toObject(iing));
        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 TableRecipeShapeless(tier, toStack(output), toObjects(ingredients)).withTransforms(transformers)));
}
Also used : Function(java.util.function.Function) IIngredient(crafttweaker.api.item.IIngredient) HashMap(java.util.HashMap) Ingredient(net.minecraft.item.crafting.Ingredient) IIngredient(crafttweaker.api.item.IIngredient) IItemStack(crafttweaker.api.item.IItemStack) TableRecipeShapeless(com.blakebr0.extendedcrafting.crafting.table.TableRecipeShapeless) ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 2 with TableRecipeShapeless

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

the class EnderCrafting method addShapeless.

@ZenMethod
public static void addShapeless(IItemStack output, IIngredient[] ingredients, int seconds) {
    TableRecipeShapeless recipe = new TableRecipeShapeless(1, toStack(output), toObjects(ingredients));
    recipe.enderCrafterRecipeTimeRequired = seconds;
    CraftTweakerAPI.apply(new Add(recipe));
}
Also used : TableRecipeShapeless(com.blakebr0.extendedcrafting.crafting.table.TableRecipeShapeless) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 3 with TableRecipeShapeless

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

the class EnderCrafterRecipeManager method addShapeless.

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

Aggregations

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