thephoenixlodge

Untitled

Apr 16th, 2019
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. ////Imports
  2. import crafttweaker.data.IData;
  3. import crafttweaker.item.IItemStack;
  4.  
  5. ////Variables
  6.  
  7.  
  8.  
  9.  
  10. function itemWithAttributes(item as IItemStack, attribute as string, op as string, amount as int, slot as string) as IItemStack {
  11. var attributeMap = {
  12. maxHealth : "generic.maxHealth",
  13. mobFollowRange : "generic.followRange",
  14. knockbackResistance : "generic.knockbackResistance",
  15. speed : "generic.movementSpeed",
  16. damage : "generic.attackDamage",
  17. armour : "generic.armor",
  18. armourToughness : "generic.armorToughness",
  19. attackSpeed : "generic.attackSpeed",
  20. luck : "generic.luck"
  21. } as string[string];
  22. val operation = {
  23. //add to the base value
  24. additive : 0,
  25. //add together, then multiply by base
  26. multisum : 1,
  27. //multiply by base individually
  28. multiplicative : 2
  29. } as int[string];
  30.  
  31. if (item.hasTag() == true) {
  32. var inputTag = item.tag().asString();
  33. var inputAttributes = inputTag.split(???????????);
  34. print(inputAttributes);
  35. }
  36. /*
  37. var modifiers = {} as IData[IData];
  38. modifiers[attribute] = "{Slot:" ~ slot ~ ",AttributeName:" ~ attributeMap[attribute] ~ ",Name:" ~ attributeMap[attribute] ~ ",Amount:" ~ amount ~ ",Operation:" ~ operation[op] ~ ",UUIDLeast:0,UUIDMost:1000000}";
  39.  
  40. var modifiersBuilder = "";
  41. for key, modifier in modifiers {
  42. modifiersBuilder = modifiersBuilder ~ "," ~ modifier;
  43. }
  44. var finalNBT = "{AttributeModifiers: [" ~ modifiersBuilder ~ "]}";*/
  45.  
  46. }
  47.  
  48.  
  49. //Lets try and play with attributes shall we
  50. /*function addAttribute(attribute as string, op as string, amount as int, slot as string) as string[string] {
  51. var attributeMap = {
  52. maxHealth : "generic.maxHealth",
  53. mobFollowRange : "generic.followRange",
  54. knockbackResistance : "generic.knockbackResistance",
  55. speed : "generic.movementSpeed",
  56. damage : "generic.attackDamage",
  57. armour : "generic.armor",
  58. armourToughness : "generic.armorToughness",
  59. attackSpeed : "generic.attackSpeed",
  60. luck : "generic.luck"
  61. } as string[string];
  62. val operation = {
  63. //add to the base value
  64. additive : 0,
  65. //add together, then multiply by base
  66. multisum : 1,
  67. //multiply by base individually
  68. multiplicative : 2
  69. } as int[string];
  70.  
  71. //var attributesToAdd = {} as string[][string];
  72.  
  73. modifiers[attribute] = "{Slot:" ~ slot ~ ",AttributeName:" ~ attributeMap[attribute] ~ ",Name:" ~ attributeMap[attribute] ~ ",Amount:" ~ amount ~ ",Operation:" ~ operation[op] ~ ",UUIDLeast:0,UUIDMost:1000000}";
  74. return modifiers;
  75. }
  76.  
  77. function setAttributes(attributes as any) as IData {
  78. var modifiersBuilder = "";
  79. for key, modifier in modifiers {
  80. modifiersBuilder = modifiersBuilder ~ "," ~ modifier;
  81. }
  82. var finalNBT = "{AttributeModifiers: [" ~ modifiersBuilder ~ "]}";
  83. return finalNBT;
  84. }
  85.  
  86. //test recipe
  87. recipes.addShaped(<minecraft:diamond_sword>.withTag(setAttributes([addAttribute("maxHealth", "additive", 10, "chest")])), [[<minecraft:dirt>]]);
  88. //recipes.addShaped(<minecraft:diamond_sword>.withTag(setAttributes([addAttribute("maxHealth", "additive", 10, "chest"), addAttribute("speed", "multisum", 2, "chest")])), [[<minecraft:dirt>, <minecraft:dirt>]]);
  89.  
  90.  
  91.  
  92. //example
  93. //item.withTag(setAttributes([addAttribute("damage", "additive", 5, "mainHand"), addAttribute("maxHealth", "additive", )]))
  94. /*
  95. .withTag({AttributeModifiers: [
  96. {Slot:"chest",AttributeName:"generic.movementSpeed",Name:"generic.movementSpeed",Amount:0.2,Operation:1,UUIDLeast:1,UUIDMost:1},
  97. {Slot:"chest",AttributeName:"generic.armor",Name:"generic.armor",Amount:5,Operation:0,UUIDLeast:10,UUIDMost:10}],
  98. display:{Name:"Light Iron Chestplate"}})*/
Advertisement
Add Comment
Please, Sign In to add comment