This repository has been archived on 2021-07-14. You can view files and clone it, but cannot push or open issues or pull requests.
scriptcraft/src/main/js/modules/canary/recipes.js

37 lines
886 B
JavaScript

var cm = Packages.net.canarymod;
var cmRecipe = cm.api.inventory.recipes.CraftingRecipe;
var cmRecipeRow = cm.api.inventory.recipes.RecipeRow;
function addRecipe( recipe ){
if (!recipe){
return null;
}
var result,
rows,
i,j,
cells,
rr;
if (recipe.shape){
rows = [];
for (i = 0; i < recipe.shape.length; i++){
cells = recipe.shape[i].split('');
rr = [];
for ( j = 0; j < cells.length ; j++){
if (cells[j] != ' '){
rr.push(recipe.ingredients[cells[j]]);
}
}
rows.push( new cmRecipeRow(recipe.shape[i], rr) );
}
result = __plugin.makeShapedRecipe( recipe.result, rows);
} else {
result = __plugin.makeShapelessRecipe( recipe.result, recipe.ingredients );
}
return result;
}
function removeRecipe( recipe ){
server.removeRecipe( recipe );
}
exports.add = addRecipe;
exports.remove = removeRecipe;