Created
April 30, 2018 21:24
-
-
Save kindlich/473dd6b168a99a35b2c4e91afbb13ce9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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