Skip to content

Instantly share code, notes, and snippets.

@kindlich
Created November 1, 2018 10:43
Show Gist options
  • Save kindlich/afd48c982f923c9c8e1d21f2a965fd8b to your computer and use it in GitHub Desktop.
Save kindlich/afd48c982f923c9c8e1d21f2a965fd8b to your computer and use it in GitHub Desktop.
#debug
import crafttweaker.item.IItemStack;
import crafttweaker.item.IIngredient;
function FlattenIngredient(inputs as IItemStack[]) as IIngredient {
return FlattenIngredientAnyDamageParam(inputs, false);
}
function FlattenIngredientAnyDamageParam(inputs as IItemStack[], anyDamage as bool) as IIngredient {
if(isNull(inputs)) {
logger.logError("Null Input array");
return null;
}
val length = inputs.length;
if(length == 0) {
logger.logError("Empty Input array");
return null;
}
var out as IIngredient = (anyDamage ? inputs[0].anyDamage() : inputs[0]) as IIngredient;
if(isNull(out)) {
logger.logError("First item may not be null!");
return null;
}
if(length == 1)
return out;
for i in 1 .. length {
out |= anyDamage ? inputs[i].anyDamage() : inputs[i];
}
return out;
}
val AxeArray = [
<minecraft:wooden_axe>,<minecraft:stone_axe>,<minecraft:golden_axe>,<minecraft:iron_axe>,<minecraft:diamond_axe>//,
//<mysticalagriculture:inferium_axe>,<mysticalagriculture:prudentium_axe>,<mysticalagriculture:intermedium_axe>,<mysticalagriculture:superium_axe>,
//<mysticalagriculture:supremium_axe>.withTag({}),<appliedenergistics2:certus_quartz_axe>,<appliedenergistics2:nether_quartz_axe>,<immersiveengineering:axe_steel>,
//<thermalfoundation:tool.axe_copper>,<thermalfoundation:tool.axe_tin>,<thermalfoundation:tool.axe_silver>,<thermalfoundation:tool.axe_lead>,
//<thermalfoundation:tool.axe_aluminum>,<thermalfoundation:tool.axe_nickel>,<thermalfoundation:tool.axe_platinum>,<thermalfoundation:tool.axe_steel>,
//<thermalfoundation:tool.axe_electrum>,<thermalfoundation:tool.axe_invar>,<thermalfoundation:tool.axe_bronze>,<thermalfoundation:tool.axe_constantan>
] as IItemStack[]; //25 Axes
val PlanksToLogs = {
<minecraft:planks:0> : <minecraft:log:0>,
<minecraft:planks:1> : <minecraft:log:1>,
<minecraft:planks:2> : <minecraft:log:2>,
<minecraft:planks:3> : <minecraft:log:3>,
<minecraft:planks:4> : <minecraft:log2:0>,
<minecraft:planks:5> : <minecraft:log2:1>
} as IItemStack[IItemStack];
var FlattenedAxeIngredient = FlattenIngredientAnyDamageParam(AxeArray, true).transformDamage();
for plank, accLog in PlanksToLogs {
recipes.removeShapeless(plank, [accLog]);
recipes.removeShaped(plank, [[accLog]]);
recipes.addShapeless(plank, [accLog]);
recipes.addShapeless(plank * 3, [accLog, FlattenedAxeIngredient]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment