event.load("quest_start"); event.load("quest_term"); event.load("entity_click"); event.load("player_toss"); event.load("player_pickup"); stage = 0; all_stages = 5; quest_name = "Tücher"; wool = 0; wool_tag = item.getTag("minecraft:wool"); loom_list = list.new(); loom_list_2 = list.new(); par = particle.get("minecraft:witch"); loom_coarse = 0; loom_cloth = 0; needed_amount = 4; @wait wait(); if(event == "living_death") { player = player.getFromDamageSource(damage_source); if(player == null) { goto("wait"); } } if(!player.isQuester(player, script)) { goto("wait"); } if(event == "quest_term") { //Hier Code einfügen... wait(); //Script wird von außen terminiert } if(event == "quest_start") { quest.display(player, quest_name, stage, all_stages); msg.prefix(player, "§dRolf", "Mh… Hallo. Ich brauche Tücher. Schere doch 8 Schafe, aber zackig!"); player.giveSingleItem(player, read.item("minecraft:shears"), false); goto("wait"); } label = concat("stage", text.number(stage)); goto(label); @stage0 if(event == "entity_click") { entity_type = entity.getType(entity); if(entity_type == "sheep") { if(!sheep.isSheared(entity)) { item = entity.getEquip(player, "hand"); item_type = item.getType(item); if(item_type == "minecraft:shears") { wool++; if(wool == 8) { stage.increase(player); } } } } } goto("wait"); @stage1 if(event == "entity_click" && hand == "MAIN_HAND" && entity.getType(entity) == "human") { entity_name = entity.getName(entity); if(entity_name == "Rolf") { msg.prefix(player, "§dRolf", "Ich brauch doch keine Wolle, ich will Tücher!"); scheduler.msgPrefix(30, player, concat("§5", player.getName(player)), "Und wie geht das?"); scheduler.msgPrefix(60, player, "§dRolf", "Siehst du den Webstuhl da? Schmeiß die Wolle einzeln darauf."); scheduler.msgPrefix(90, player, "§dRolf", "Schaue ihn direkt an und drücke Q (Drop-Taste) um ihn zu benutzen."); stage.increase(player); } } goto("wait"); @stage2 if(event == "player_pickup") { if(item.hasTag(wool_tag, item)) { loom_coarse -= item.getAmount(item); if(loom_coarse < 0) { loom_coarse = 0; } } goto("wait"); } if(event == "player_toss") { target_loc = player.getTarget(player, 5); block_type = block.getType(target_loc); if(block_type == "minecraft:loom") { cancel = true; if(!item.hasTag(wool_tag, item)) { player.giveItem(player, item); inv.update(player); goto("wait"); } item_entity = item.entity.new(loc.mod(target_loc, 0.5, 1.5, 0.5), item); item.entity.spawn(item_entity); a = array.new(3); a[0] = target_loc; a[1] = item_entity; a[2] = read.item("km:coarse_cloth"); list.add(loom_list, a); sgoto(40, "sloom"); } } goto("wait"); @sloom if(loom_coarse > 4) { goto("wait"); } a = list.getIndex(loom_list, 0); list.removeIndex(loom_list, 0); location = a[0]; input_item_entity = a[1]; output_item = a[2]; loom_coarse += loom(location, input_item_entity, output_item); if(loom_coarse >= 4) { if(msg_01 == null) { msg.prefix(player, "§dRolf", "Stop! Ich will doch nicht noch mehr raue Tücher! Wirf nun jeweils ein Wollstück und ein raues Tuch auf den Webstuhl."); msg_01 = true; stage.increase(player); } } goto("wait"); function loom(location, input_item_entity, output_item) { input_item = item.entity.get(input_item_entity); amount = item.getAmount(input_item); item.setAmount(output_item, amount); item.entity.set(input_item_entity, output_item); entity.throw(input_item_entity, 0, 0.3, 0); particle.spawn(loc.mod(location, 0.5, 1.4, 0.5), $par, 20, 0, 0.25, 0.25, 0.25); return amount; } @stage3 if(event == "player_pickup") { if(item.getType(item) == "km:cloth") { loom_cloth += item.getAmount(item); if(loom_cloth >= 4) { stage.increase(player); msg.prefix(player, "§dRolf", "Perfekt. Jetzt gib mir die Tücher."); } } goto("wait"); } if(event == "player_toss") { item_type = item.getType(item); if(item_type == "km:cloth") { loom_cloth -= item.getAmount(item); if(loom_cloth < 0) { loom_cloth = 0; } goto("wait"); } target_loc = player.getTarget(player, 5); block_type = block.getType(target_loc); if(block_type == "minecraft:loom") { cancel = true; if(!(item.hasTag(wool_tag, item) || item_type == "km:coarse_cloth")) { player.giveItem(player, item); inv.update(player); goto("wait"); } item_entity = item.entity.new(loc.mod(target_loc, 0.5, 1.5, 0.5), item); item.entity.spawn(item_entity); a = array.new(3); a[0] = target_loc; a[1] = item_entity; a[2] = read.item("km:cloth"); list.add(loom_list_2, a); sgoto(40, "sloom_2"); } } goto("wait"); @sloom_2 a = list.getIndex(loom_list_2, 0); list.removeIndex(loom_list_2, 0); location = a[0]; input_item_entity = a[1]; output_item = a[2]; loom2(location, input_item_entity, output_item); goto("wait"); function loom2(location, input_item_entity_1, output_item) { input_item_1 = item.entity.get(input_item_entity_1); amount_1 = item.getAmount(input_item_1); type_1 = item.getType(input_item_1); list = entity.near(input_item_entity_1, 0.2); list.add(list, input_item_entity_1); if(list.getSize(list) < 2) { return; } iter = list.iterator(list); while(hasNext(iter)) { input_item_entity_2 = next(iter); input_item_2 = item.entity.get(input_item_entity_2); type_2 = item.getType(input_item_2); if(type_1 == type_2) { continue; } if(item.hasTag($wool_tag, input_item_2) || type_2 == "km:coarse_cloth") { amount_2 = item.getAmount(input_item_2); break; } } if(amount_2 == null) { return; } if(amount_1 > amount_2) { amount = amount_2; amount_2 = 0; amount_1 -= amount; } else { amount = amount_1; amount_1 = 0; amount_2 -= amount; } item.setAmount(input_item_1, amount_1); item.setAmount(input_item_2, amount_2); item.entity.set(input_item_entity_1, input_item_1); item.entity.set(input_item_entity_2, input_item_2); item.setAmount(output_item, amount); item_entity_output = item.entity.new(loc.mod(location, 0.5, 1.1, 0.5), output_item); item.entity.spawn(item_entity_output); entity.throw(item_entity_output, 0, 0.2, 0); particle.spawn(loc.mod(location, 0.5, 1.4, 0.5), $par, 20, 0, 0.25, 0.25, 0.25); } @stage4 if(event == "entity_click" && hand == "MAIN_HAND" && entity.getType(entity) == "human") { entity_name = entity.getName(entity); if(entity_name == "Rolf") { rest_amount = human.giveItem(entity_name, player, "km:cloth", needed_amount); if(rest_amount == 0) { msg.prefix(player, "§dRolf", "Vielen Dank!"); money.addBoost(player, 8); msg(player, "§dQuest abgeschlossen. Belohnung: 8 Snuvis!"); quest.finish(script, player); } else { needed_amount = rest_amount; } } } goto("wait");