Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import crafttweaker.item.IItemStack;
- import crafttweaker.item.IIngredient;
- import crafttweaker.oredict.IOreDict;
- import crafttweaker.oredict.IOreDictEntry;
- import crafttweaker.data.IData;
- BulkOreDict("DEBUG", [<minecraft:iron_ingot>, <minecraft:grass>, <minecraft:dirt>], 2,3,3,false);
- BulkOreDict("DEBU2", [<minecraft:gold_ingot>, <minecraft:bow>, <minecraft:redstone>], 3,3,3,false);
- /*
- Types:
- 1) No recipe conversion
- 2) All can be crafted to the first item
- 3) Chain crafting
- Parameters:
- oreDictName: name of the oreDict
- items: Array containing all the items
- recipeType see above
- recipeQuantity: how many items the recipe consumes (only in type 2 and 3)
- recipeOutput: how many items the recipe outputs (only in type 2 and 3)
- wholeOreDict: should the chain recipe be set up for the whole oreDict or only for the provided items? Only needed in type 3
- */
- function BulkOreDict(oreDictName as string, items as IItemStack[], recipeType as int, recipeQuantity as int, recipeOutput as int, wholeOreDict as bool) as bool {
- if (oreDict.contains(oreDictName) & !wholeOreDict) {logger.logWarning("OreDict " ~ oreDictName ~ " already exists and the method is not set to use the whole OreDict! Some recipes may not be added correctly.");}
- if (recipeType < 1 | recipeType > 3) {logger.logError("Recipe type needs to be 1, 2, 3"); return false;}
- if (recipeQuantity < 1 | recipeQuantity > 9) {logger.logError("Recipe quantity needs to be between 1 and 9"); return false;}
- if (recipeOutput <1 | recipeOutput > 64) {logger.logError("Recipe Output needs to be between 1 and 64"); return false;}
- val oreDictionary = oreDict.get(oreDictName);
- oreDictionary.addItems(items);
- if (recipeType == 2) {
- recipes.addShapeless(oreDictionary.firstItem * recipeOutput, getIngredient(oreDictionary, recipeQuantity));
- }
- if (recipeType == 3) {
- for input, output in createChainMap(wholeOreDict ? oreDictionary.itemArray : items) {
- recipes.addShapeless(output * recipeOutput, getIngredient(input as IItemStack, recipeQuantity));
- }
- }
- return true;
- }
- function createChainMap (itemArr as IItemStack[]) as IItemStack[IItemStack] {
- if (itemArr.length == 0) {return null;}
- val whatever as int = itemArr.length;
- var map as IItemStack[IItemStack] = {
- itemArr[0] : itemArr[(whatever - 1)]
- };
- for i in 1 to whatever {
- //that call doesn't work inside for-loops...
- addToMap(itemArr[i], itemArr[i - 1], map);
- }
- return map;
- }
- function addToMap (key as IItemStack, value as IItemStack, map as IItemStack[IItemStack]) {
- map[key] = value;
- }
- function getIngredient (ing as IIngredient, amount as int) as IIngredient[] {
- if (amount == 9) {return [ing,ing,ing,ing,ing,ing,ing,ing,ing];}
- if (amount == 8) {return [ing,ing,ing,ing,ing,ing,ing,ing];}
- if (amount == 7) {return [ing,ing,ing,ing,ing,ing,ing];}
- if (amount == 6) {return [ing,ing,ing,ing,ing,ing];}
- if (amount == 5) {return [ing,ing,ing,ing,ing];}
- if (amount == 4) {return [ing,ing,ing,ing];}
- if (amount == 3) {return [ing,ing,ing];}
- if (amount == 2) {return [ing,ing];}
- return [ing];
- }
Add Comment
Please, Sign In to add comment