Guest User

Untitled

a guest
Dec 14th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. import crafttweaker.item.IItemStack;
  2. import crafttweaker.item.IIngredient;
  3. import crafttweaker.oredict.IOreDict;
  4. import crafttweaker.oredict.IOreDictEntry;
  5. import crafttweaker.data.IData;
  6.  
  7. BulkOreDict("DEBUG", [<minecraft:iron_ingot>, <minecraft:grass>, <minecraft:dirt>], 2,3,3,false);
  8. BulkOreDict("DEBU2", [<minecraft:gold_ingot>, <minecraft:bow>, <minecraft:redstone>], 3,3,3,false);
  9.  
  10. /*
  11. Types:
  12. 1) No recipe conversion
  13. 2) All can be crafted to the first item
  14. 3) Chain crafting
  15.  
  16. Parameters:
  17. oreDictName: name of the oreDict
  18. items: Array containing all the items
  19. recipeType see above
  20. recipeQuantity: how many items the recipe consumes (only in type 2 and 3)
  21. recipeOutput: how many items the recipe outputs (only in type 2 and 3)
  22. wholeOreDict: should the chain recipe be set up for the whole oreDict or only for the provided items? Only needed in type 3
  23. */
  24.  
  25.  
  26. function BulkOreDict(oreDictName as string, items as IItemStack[], recipeType as int, recipeQuantity as int, recipeOutput as int, wholeOreDict as bool) as bool {
  27. 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.");}
  28. if (recipeType < 1 | recipeType > 3) {logger.logError("Recipe type needs to be 1, 2, 3"); return false;}
  29. if (recipeQuantity < 1 | recipeQuantity > 9) {logger.logError("Recipe quantity needs to be between 1 and 9"); return false;}
  30. if (recipeOutput <1 | recipeOutput > 64) {logger.logError("Recipe Output needs to be between 1 and 64"); return false;}
  31. val oreDictionary = oreDict.get(oreDictName);
  32. oreDictionary.addItems(items);
  33.  
  34. if (recipeType == 2) {
  35. recipes.addShapeless(oreDictionary.firstItem * recipeOutput, getIngredient(oreDictionary, recipeQuantity));
  36. }
  37. if (recipeType == 3) {
  38. for input, output in createChainMap(wholeOreDict ? oreDictionary.itemArray : items) {
  39. recipes.addShapeless(output * recipeOutput, getIngredient(input as IItemStack, recipeQuantity));
  40. }
  41. }
  42. return true;
  43. }
  44.  
  45.  
  46. function createChainMap (itemArr as IItemStack[]) as IItemStack[IItemStack] {
  47. if (itemArr.length == 0) {return null;}
  48.  
  49. val whatever as int = itemArr.length;
  50. var map as IItemStack[IItemStack] = {
  51. itemArr[0] : itemArr[(whatever - 1)]
  52. };
  53.  
  54. for i in 1 to whatever {
  55. //that call doesn't work inside for-loops...
  56. addToMap(itemArr[i], itemArr[i - 1], map);
  57. }
  58.  
  59. return map;
  60. }
  61.  
  62. function addToMap (key as IItemStack, value as IItemStack, map as IItemStack[IItemStack]) {
  63. map[key] = value;
  64. }
  65.  
  66. function getIngredient (ing as IIngredient, amount as int) as IIngredient[] {
  67. if (amount == 9) {return [ing,ing,ing,ing,ing,ing,ing,ing,ing];}
  68. if (amount == 8) {return [ing,ing,ing,ing,ing,ing,ing,ing];}
  69. if (amount == 7) {return [ing,ing,ing,ing,ing,ing,ing];}
  70. if (amount == 6) {return [ing,ing,ing,ing,ing,ing];}
  71. if (amount == 5) {return [ing,ing,ing,ing,ing];}
  72. if (amount == 4) {return [ing,ing,ing,ing];}
  73. if (amount == 3) {return [ing,ing,ing];}
  74. if (amount == 2) {return [ing,ing];}
  75. return [ing];
  76. }
Add Comment
Please, Sign In to add comment