123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- event.load("entity_click");
- event.load("inv_click");
- event.load("inv_close");
- amber = item.getAmber();
- ruby = item.getRuby();
- air = item.getAir();
- arrow_right = read.item("km:arrow_right", 1, "§fConvert");
- prefix_commands = "§6Commands";
- hint_1 = read.item("minecraft:iron_chestplate", 1, "§fArmor Part");
- hint_2 = read.item("{id:\"km:flawless_gem_stone\",Count:1b,tag:{color:16632375,display:{Name:'{\"text\":\"§fGemstone\"}'}}}");
- hint_3 = read.item("km:copper_hammer", 1, "§fHammer");
- item.hide(hint_1, "attributes");
- item.hide(hint_2, "attributes");
- item.hide(hint_3, "attributes");
- slot_head = read.slot("head");
- slot_chest = read.slot("chest");
- slot_legs = read.slot("legs");
- slot_feet = read.slot("feet");
- tag_helmet = item.getTag("km:helmet");
- tag_chestplate = item.getTag("km:chestplate");
- tag_leggings = item.getTag("km:leggings");
- tag_boots = item.getTag("km:boots");
- tag_hammer = item.getTag("km:hammer");
- msg("dev", "§bGemstones §rloaded.");
- @wait
- wait();
- if(event == "entity_click") {
- if(hand == "OFF_HAND") {
- goto("wait");
- }
- entity_type = entity.getType(entity);
- if(entity_type != "human") {
- goto("wait");
- }
- entity_name = entity.getName(entity);
- if(entity_name != "Ludwig") {
- goto("wait");
- }
- inv = inv.new("011102010033300000");
- inv.setItem(inv, 3, arrow_right);
- inv.setItem(inv, 5, hint_1);
- inv.setItem(inv, 6, hint_2);
- inv.setItem(inv, 7, hint_3);
- inv.open(inv, player, "Gemstone-Anvil");
- goto("wait");
- }
- if(event == "inv_close") {
- player.safeGiveItem(player, inv.getItem(inv, 0));
- player.safeGiveItem(player, inv.getItem(inv, 1));
- player.safeGiveItem(player, inv.getItem(inv, 2));
- player.safeGiveItem(player, inv.getItem(inv, 4));
- waitfor(2);
- inv.update(player);
- goto("wait");
- }
- if(event == "inv_click") {
- if(inv_slot == 3) {
- //Ziel-slot muss leer sein
- item = inv.getItem(inv, 4);
- if(item.getType(item) != "minecraft:air") {
- msg.prefix(player, prefix_commands, "Fourth slot needs to be empty.");
- goto("wait");
- }
- //Quell-slots müssen belegt sein
- item_0 = inv.getItem(inv, 0);
- item_type = item.getType(item_0);
- if(item_type == "minecraft:air") {
- msg.prefix(player, prefix_commands, "First slot is empty.");
- goto("wait");
- }
- item_1 = inv.getItem(inv, 1);
- item_type = item.getType(item_1);
- if(item_type == "minecraft:air") {
- msg.prefix(player, prefix_commands, "Second slot is empty.");
- goto("wait");
- }
- item_2 = inv.getItem(inv, 2);
- if(!item.hasTag(tag_hammer, item_2)) {
- msg.prefix(player, prefix_commands, "Third slot is not a hammer.");
- goto("wait");
- }
- if(item.hasTag(tag_helmet, item_0)) {
- slot = slot_head;
- } elseif(item.hasTag(tag_chestplate, item_0)) {
- slot = slot_chest;
- } elseif(item.hasTag(tag_leggings, item_0)) {
- slot = slot_legs;
- } elseif(item.hasTag(tag_boots, item_0)) {
- slot = slot_feet;
- } else {
- msg.prefix(player, prefix_commands, "First slot is not an armor part.");
- goto("wait");
- }
- if(item.getAmount(item_0) != 1) {
- msg.prefix(player, prefix_commands, "Only one armor part allowed.");
- goto("wait");
- }
- max_damage = item.getMaxDamage(item_2);
- new_damage = item.getDamage(item_2) + 50;
- if(new_damage > max_damage + 1) {
- msg.prefix(player, prefix_commands, "Hammer has not enough durability.");
- goto("wait");
- }
- //which gemstone
- if(item.isRuby(item_1)) {
- att_type = "generic.max_health";
- att_amount = 2;
- }
- elseif(item.isSapphire(item_1)) {
- att_type = "generic.armor";
- att_amount = 1;
- }
- elseif(item.isAmber(item_1)) {
- att_type = "generic.movement_speed";
- att_amount = 0.02;
- } else {
- msg.prefix(player, prefix_commands, "Second slot needs to be one Gemstone (Amber, Ruby, ...).");
- goto("wait");
- }
- if(new_damage > max_damage) {
- inv.setItem(inv, 2, air);
- //playsound
- }
- item.setDamage(item_2, new_damage);
- if(!item.hasAttributes(item_0)) {
- item.addDefaultTags(item_0);
- }
- item.addAttribute(item_0, att_type, slot, att_amount, 0);
- inv.setItem(inv, 0, air);
- inv.setItem(inv, 1, air);
- inv.setItem(inv, 4, item_0);
- inv.update(player);
- }
- }
- goto("wait");
|