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)));
}
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)));
}
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;
}
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));
}
Aggregations