gemstones.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. event.load("entity_click");
  2. event.load("inv_click");
  3. event.load("inv_close");
  4. amber = item.getAmber();
  5. ruby = item.getRuby();
  6. air = item.getAir();
  7. arrow_right = read.item("km:arrow_right", 1, "§fConvert");
  8. prefix_commands = "§6Commands";
  9. hint_1 = read.item("minecraft:iron_chestplate", 1, "§fArmor Part");
  10. hint_2 = read.item("{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:16632375,display:{Name:'{\"text\":\"§fGemstone\"}'}}}");
  11. hint_3 = read.item("km:copper_hammer", 1, "§fHammer");
  12. item.hide(hint_1, "attributes");
  13. item.hide(hint_2, "attributes");
  14. item.hide(hint_3, "attributes");
  15. slot_head = read.slot("head");
  16. slot_chest = read.slot("chest");
  17. slot_legs = read.slot("legs");
  18. slot_feet = read.slot("feet");
  19. tag_helmet = item.getTag("km:helmet");
  20. tag_chestplate = item.getTag("km:chestplate");
  21. tag_leggings = item.getTag("km:leggings");
  22. tag_boots = item.getTag("km:boots");
  23. tag_hammer = item.getTag("km:hammer");
  24. msg("dev", "§bGemstones §rloaded.");
  25. @wait
  26. wait();
  27. if(event == "entity_click") {
  28. if(hand == "OFF_HAND") {
  29. goto("wait");
  30. }
  31. entity_type = entity.getType(entity);
  32. if(entity_type != "human") {
  33. goto("wait");
  34. }
  35. entity_name = entity.getName(entity);
  36. if(entity_name != "Ludwig") {
  37. goto("wait");
  38. }
  39. inv = inv.new("011102010033300000");
  40. inv.setItem(inv, 3, arrow_right);
  41. inv.setItem(inv, 5, hint_1);
  42. inv.setItem(inv, 6, hint_2);
  43. inv.setItem(inv, 7, hint_3);
  44. inv.open(inv, player, "Gemstone-Anvil");
  45. goto("wait");
  46. }
  47. if(event == "inv_close") {
  48. player.safeGiveItem(player, inv.getItem(inv, 0));
  49. player.safeGiveItem(player, inv.getItem(inv, 1));
  50. player.safeGiveItem(player, inv.getItem(inv, 2));
  51. player.safeGiveItem(player, inv.getItem(inv, 4));
  52. waitfor(2);
  53. inv.update(player);
  54. goto("wait");
  55. }
  56. if(event == "inv_click") {
  57. if(inv_slot == 3) {
  58. //Ziel-slot muss leer sein
  59. item = inv.getItem(inv, 4);
  60. if(item.getType(item) != "minecraft:air") {
  61. msg.prefix(player, prefix_commands, "Fourth slot needs to be empty.");
  62. goto("wait");
  63. }
  64. //Quell-slots müssen belegt sein
  65. item_0 = inv.getItem(inv, 0);
  66. item_type = item.getType(item_0);
  67. if(item_type == "minecraft:air") {
  68. msg.prefix(player, prefix_commands, "First slot is empty.");
  69. goto("wait");
  70. }
  71. item_1 = inv.getItem(inv, 1);
  72. item_type = item.getType(item_1);
  73. if(item_type == "minecraft:air") {
  74. msg.prefix(player, prefix_commands, "Second slot is empty.");
  75. goto("wait");
  76. }
  77. item_2 = inv.getItem(inv, 2);
  78. if(!item.hasTag(tag_hammer, item_2)) {
  79. msg.prefix(player, prefix_commands, "Third slot is not a hammer.");
  80. goto("wait");
  81. }
  82. if(item.hasTag(tag_helmet, item_0)) {
  83. slot = slot_head;
  84. } elseif(item.hasTag(tag_chestplate, item_0)) {
  85. slot = slot_chest;
  86. } elseif(item.hasTag(tag_leggings, item_0)) {
  87. slot = slot_legs;
  88. } elseif(item.hasTag(tag_boots, item_0)) {
  89. slot = slot_feet;
  90. } else {
  91. msg.prefix(player, prefix_commands, "First slot is not an armor part.");
  92. goto("wait");
  93. }
  94. if(item.getAmount(item_0) != 1) {
  95. msg.prefix(player, prefix_commands, "Only one armor part allowed.");
  96. goto("wait");
  97. }
  98. max_damage = item.getMaxDamage(item_2);
  99. new_damage = item.getDamage(item_2) + 50;
  100. if(new_damage > max_damage + 1) {
  101. msg.prefix(player, prefix_commands, "Hammer has not enough durability.");
  102. goto("wait");
  103. }
  104. //which gemstone
  105. if(item.isRuby(item_1)) {
  106. att_type = "generic.max_health";
  107. att_amount = 2;
  108. }
  109. elseif(item.isSapphire(item_1)) {
  110. att_type = "generic.armor";
  111. att_amount = 1;
  112. }
  113. elseif(item.isAmber(item_1)) {
  114. att_type = "generic.movement_speed";
  115. att_amount = 0.02;
  116. } else {
  117. msg.prefix(player, prefix_commands, "Second slot needs to be one Gemstone (Amber, Ruby, ...).");
  118. goto("wait");
  119. }
  120. if(new_damage > max_damage) {
  121. inv.setItem(inv, 2, air);
  122. //playsound
  123. }
  124. item.setDamage(item_2, new_damage);
  125. if(!item.hasAttributes(item_0)) {
  126. item.addDefaultTags(item_0);
  127. }
  128. item.addAttribute(item_0, att_type, slot, att_amount, 0);
  129. inv.setItem(inv, 0, air);
  130. inv.setItem(inv, 1, air);
  131. inv.setItem(inv, 4, item_0);
  132. inv.update(player);
  133. }
  134. }
  135. goto("wait");