gemstones.txt 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. event.load("entity_click");
  2. event.load("snuvi_click");
  3. slot_head = slot.getHead();
  4. slot_chest = slot.getChest();
  5. slot_legs = slot.getLegs();
  6. slot_feet = slot.getFeet();
  7. amber = item.getAmber();
  8. ruby = item.getRuby();
  9. sapphire = item.getSapphire();
  10. air = item.getAir();
  11. arrow_right = item.custom.create("ARROW_RIGHT", 1, "§fConvert", null);
  12. prefix_commands = "§6Commands";
  13. hint_1 = item.create("minecraft:iron_chestplate", 1, "§fArmor Part", null);
  14. hint_2 = item.getRuby();
  15. hint_3 = item.custom.create("GOLD_COIN", 1, "§f4096 Snuvis", null);
  16. hint_4 = item.create("minecraft:iron_chestplate", 1, "§fArmor Part", null);
  17. hint_5 = item.create("minecraft:iron_chestplate", 1, "§fArmor Part", null);
  18. hint_6 = item.getSapphire();
  19. hint_7 = item.custom.create("GOLD_COIN", 1, "§f4096 Snuvis", null);
  20. hint_8 = item.create("minecraft:iron_chestplate", 1, "§fArmor Part", null);
  21. hint_9 = item.create("minecraft:iron_chestplate", 1, "§fArmor Part", null);
  22. hint_10 = item.getAmber();
  23. hint_11 = item.custom.create("GOLD_COIN", 1, "§f4096 Snuvis", null);
  24. hint_12 = item.create("minecraft:iron_chestplate", 1, "§fArmor Part", null);
  25. item.addFlag(hint_2, "HIDE_ATTRIBUTES");
  26. item.addFlag(hint_3, "HIDE_ATTRIBUTES");
  27. item.addFlag(hint_6, "HIDE_ATTRIBUTES");
  28. item.addFlag(hint_10, "HIDE_ATTRIBUTES");
  29. item.addFlag(hint_11, "HIDE_ATTRIBUTES");
  30. item.addDefaultTags(hint_4);
  31. item.addDefaultTags(hint_8);
  32. item.addDefaultTags(hint_12);
  33. item.addAttribute(hint_4, "GENERIC_MAX_HEALTH", slot_chest, 2, "ADD_NUMBER");
  34. item.addAttribute(hint_8, "GENERIC_ARMOR", slot_chest, 1, "ADD_NUMBER");
  35. item.addAttribute(hint_12, "GENERIC_KNOCKBACK_RESISTANCE", slot_chest, 0.1, "ADD_NUMBER");
  36. anvil_use = sound.get("BLOCK_ANVIL_USE");
  37. sc_master = sound.getCategory("MASTER");
  38. snuvis = 4096;
  39. tag_helmet = item.getTag("km:helmet");
  40. tag_chestplate = item.getTag("km:chestplate");
  41. tag_leggings = item.getTag("km:leggings");
  42. tag_boots = item.getTag("km:boots");
  43. msg.string("dev", "§bGemstones §rloaded.");
  44. @wait
  45. wait();
  46. if(event == "entity_click") {
  47. if(slot.isOffHand(hand)) {
  48. goto("wait");
  49. }
  50. if(!isCitizen(entity)) {
  51. goto("wait");
  52. }
  53. entity_name = entity.getName(entity);
  54. string_name = string.text(entity_name);
  55. if(string_name != "Ludwig") {
  56. goto("wait");
  57. }
  58. inv = inv.new("011020100022000000022000000022000000", text.new("Gemstone-Anvil"));
  59. inv.setItem(inv, 4, arrow_right);
  60. inv.setItem(inv, 10, hint_1);
  61. inv.setItem(inv, 11, hint_2);
  62. inv.setItem(inv, 12, hint_3);
  63. inv.setItem(inv, 15, hint_4);
  64. inv.setItem(inv, 19, hint_5);
  65. inv.setItem(inv, 20, hint_6);
  66. inv.setItem(inv, 21, hint_7);
  67. inv.setItem(inv, 24, hint_8);
  68. inv.setItem(inv, 28, hint_9);
  69. inv.setItem(inv, 29, hint_10);
  70. inv.setItem(inv, 30, hint_11);
  71. inv.setItem(inv, 33, hint_12);
  72. inv.open(inv, player);
  73. goto("wait");
  74. }
  75. if(event == "snuvi_click") {
  76. title_string = string.text(inv_title);
  77. if(title_string != "Gemstone-Anvil") {
  78. goto("wait");
  79. }
  80. if(inv_slot == 4) {
  81. //Ziel-slot muss leer sein
  82. item = inv.getItem(inv, 6);
  83. if(item != null) {
  84. msg.prefix(player, prefix_commands, "Result slot needs to be empty.");
  85. goto("wait");
  86. }
  87. //Quell-slots müssen belegt sein
  88. item_0 = inv.getItem(inv, 1);
  89. if(item_0 == null) {
  90. msg.prefix(player, prefix_commands, "First slot is empty.");
  91. goto("wait");
  92. }
  93. item_1 = inv.getItem(inv, 2);
  94. if(item_1 == null) {
  95. msg.prefix(player, prefix_commands, "Second slot is empty.");
  96. goto("wait");
  97. }
  98. if(item.hasTag(item_0, tag_helmet)) {
  99. slot = slot_head;
  100. } elseif(item.hasTag(item_0, tag_chestplate)) {
  101. slot = slot_chest;
  102. } elseif(item.hasTag(item_0, tag_leggings)) {
  103. slot = slot_legs;
  104. } elseif(item.hasTag(item_0, tag_boots)) {
  105. slot = slot_feet;
  106. } else {
  107. msg.prefix(player, prefix_commands, "First slot is not an armor part.");
  108. goto("wait");
  109. }
  110. if(item.getAmount(item_0) != 1) {
  111. msg.prefix(player, prefix_commands, "Only one armor part allowed.");
  112. goto("wait");
  113. }
  114. //which gemstone
  115. if(item.isRuby(item_1)) {
  116. gem = ruby;
  117. att_type = "GENERIC_MAX_HEALTH";
  118. att_amount = 2;
  119. }
  120. elseif(item.isSapphire(item_1)) {
  121. gem = sapphire;
  122. att_type = "GENERIC_ARMOR";
  123. att_amount = 1;
  124. }
  125. elseif(item.isAmber(item_1)) {
  126. gem = amber;
  127. att_type = "GENERIC_KNOCKBACK_RESISTANCE";
  128. att_amount = 0.1;
  129. } else {
  130. msg.prefix(player, prefix_commands, "Second slot needs to be one Gemstone (Amber, Ruby, ...).");
  131. goto("wait");
  132. }
  133. if(item.getAmount(item_1) != 1) {
  134. msg.prefix(player, prefix_commands, "Second slot needs to be one Gemstone (Amber, Ruby, ...).");
  135. goto("wait");
  136. }
  137. if(!hasEnoughMoney(player, snuvis)) {
  138. msg.prefix(player, prefix_plot, string.concat("You need ", money.getString(snuvis), " snuvis for this."));
  139. goto("wait");
  140. }
  141. money.sub(player, snuvis);
  142. sound.spawn(entity.getLocation(player), anvil_use, sc_master);
  143. if(!item.hasAttributes(item_0)) {
  144. item.addDefaultTags(item_0);
  145. }
  146. item.addAttribute(item_0, att_type, slot, att_amount, "ADD_NUMBER");
  147. inv.setItem(inv, 1, air);
  148. inv.removeItem(inv, item_1);
  149. inv.setItem(inv, 6, item_0);
  150. }
  151. }
  152. goto("wait");