Skip to content

Instantly share code, notes, and snippets.

@kindlich
Created April 30, 2018 21:24
Show Gist options
  • Select an option

  • Save kindlich/473dd6b168a99a35b2c4e91afbb13ce9 to your computer and use it in GitHub Desktop.

Select an option

Save kindlich/473dd6b168a99a35b2c4e91afbb13ce9 to your computer and use it in GitHub Desktop.
import crafttweaker.item.IItemStack;
import crafttweaker.item.IIngredient;
import crafttweaker.recipes.IRecipeFunction;
import crafttweaker.data.IData;
val recipes as IData[IIngredient[]] = {
//[Brush, dyeIngredient] : [repairValue, maxDyeCount]
//[Brush, dyeIngredient] : repairValue
[<minecraft:iron_pickaxe>, <ore:dyeRed>] : [10, 3],
[<minecraft:iron_pickaxe>, <minecraft:gold_ingot>] : 15
};
var recipeNo = 0;
for recipe, data in recipes {
if(recipe.length == 2 & recipe[0] instanceof IItemStack) {
val brush as IItemStack = recipe[0];
var maxDyeCount = 8;
var repairValue as int;
if(data.length == 2) {
maxDyeCount = data[1].asInt();
repairValue = data[0].asInt();
} else {
repairValue = data.asInt();
}
generateRecipe(brush, recipe[1], repairValue, recipeNo, maxDyeCount);
recipeNo += 1;
}
}
function calcNewDamage(map as IItemStack[string]) as int {
var newDamage = map.mark.damage;
for key, value in map {
if("mark" != key) {
newDamage -= key.split("↔")[1] as int;
}
}
return newDamage;
}
function generateRecipe(brush as IItemStack, dye as IIngredient, value as int, recipeNo as int, maxDyeCount as int) as void {
var ingredients as IIngredient[] = [brush.anyDamage().marked("mark")];
val recipeFunction as IRecipeFunction = function(out, ins, cInfo) {return ins.mark.withDamage(max(0, calcNewDamage(ins)));};
for i in 0 .. maxDyeCount {
ingredients += dye.marked(i ~ "↔" ~ value as string);
recipes.addShapeless("brushRecipe" ~ recipeNo ~ "_" ~ i, brush, ingredients, recipeFunction, null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment