123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- dispenser_mat = material.get("DISPENSER");
- shroomlight_mat = material.get("SHROOMLIGHT");
- air_mat = material.getAir();
- tinted_glass_mat = material.get("TINTED_GLASS");
- gear = customitem.getGear();
- slabs_tag = block.getTag("minecraft:slabs");
- logs_tag = block.getTag("minecraft:logs");
- planks_tag = block.getTag("minecraft:planks");
- teleporter.setLayout();
- tp_list = list.new();
- tp_map = map.new();
- tp_set = set.new();
- piston_sound = sound.get("block.piston.extend");
- adv_tp_sound = sound.get("block.portal.travel");
- sound_category_ambient = sound.getCategory("AMBIENT");
- overworld = world.getOverWorld();
- random_tp_loc = loc.new(overworld, 134, 79, 5);
- event.load("block_click");
- msg.string("dev", "§bTeleporter §rloaded.");
- @main
- wait();
- ignoreGoto(event);
- goto("main");
- @block_click
- if(block == null) {
- goto("main");
- }
- if(slot.isOffHand(hand)) {
- goto("main");
- }
- block_loc = block.getLocation(block);
- if(block.getType(block) == dispenser_mat && action == "LEFT_CLICK_BLOCK") {
- if(!teleporter.isLayout(block_loc)) {
- goto("main");
- }
- list = list.new();
- list.add(list, text.new("Teleport"));
- list.add(list, text.new(world.getName(loc.getWorld(block_loc))));
- list.add(list, text.new(string.number(loc.getX(block_loc))));
- list.add(list, text.new(string.number(loc.getY(block_loc))));
- list.add(list, text.new(string.number(loc.getZ(block_loc))));
- tp_item = customitem.create("GEAR", 1, null, list);
- player.giveItem(player, tp_item);
- goto("main");
- }
- if(block.getType(block) == shroomlight_mat && action == "RIGHT_CLICK_BLOCK") {
- if(!teleporter.isLayout(block_loc)) {
- goto("main");
- }
- player_uuid = player.getUuid(player);
- clicked = map.getOrDefault(tp_map, player_uuid, 0);
- now_time = time.getMillis();
- if(now_time - clicked < 5000) {
- msg.prefix(player, "§5Teleport", "Wait 5 seconds!");
- goto("main");
- }
- map.add(tp_map, player_uuid, now_time);
- //Random-Teleport
- if(block_loc == random_tp_loc) {
- /*if(!player.isOnAdventure(player)) {
- if(!player.hasClearInventory(player)) {
- msg.prefix(player, "§5Adventure", "Your inventory needs to be empty!");
- goto("main");
- }*/
- disp_loc = loc.mod(block_loc, 0, 4, 0);
- alpha = math.random(0, 360);
- alpha *= math.pi() / 180;
- x = math.round(math.sin(alpha) * 5000) + 0.5;
- z = math.round(math.cos(alpha) * 5000) + 0.5;
- tp_loc = loc.getHighestPoint(loc.new(world.getOverWorld(), x, 0, z));
- setTpWallX(disp_loc, tinted_glass_mat);
- sound.spawn(disp_loc, piston_sound, sound_category_ambient);
- player_uuid = player.getUuid(player);
- array = array.new(4);
- array[0] = player_uuid;
- array[1] = disp_loc;
- array[2] = tp_loc;
- //array[3] = true;
- array[3] = false;
- list.add(tp_list, array);
- set.add(tp_set, player_uuid);
- sgoto(30, "tp_ticker");
- //}
- goto("main");
- }
- //Normaler Teleport
- temp = false;
- disp_loc = loc.mod(block_loc, 0, 4, 0);
- disp_block = block.get(disp_loc);
- inv = block.getInventory(disp_block);
- inv_size = inv.getSize(inv);
- for(i = 0; i < inv_size; i++) {
- item = inv.getItem(inv, i);
- if(customitem.isGear(item)) {
- temp = true;
- break;
- }
- }
- if(!temp) {
- msg.prefix(player, "§5Teleport", "No receiver found!");
- goto("main");
- }
-
- lore_list = item.getLore(item);
- if(list.getSize(lore_list) != 5) {
- msg.prefix(player, "§5Teleport", "No receiver found!");
- goto("main");
- }
- name = string.text(list.getIndex(lore_list, 0));
- if(string.removeFormat(name) != "Teleport") {
- msg.prefix(player, "§5Teleport", "No receiver found!");
- goto("main");
- }
- teleporter_world = loc.getWorld(disp_loc);
- if(!world.isSurvName(world.getName(teleporter_world))) {
- msg.prefix(player, "§5Teleport", "Not allowed in this world!");
- goto("main");
- }
- world = world.get(string.text(list.getIndex(lore_list, 1)));
- x = read.number(string.text(list.getIndex(lore_list, 2)));
- y = read.number(string.text(list.getIndex(lore_list, 3)));
- z = read.number(string.text(list.getIndex(lore_list, 4)));
- tp_loc = loc.new(world, x, y, z);
- if(!teleporter.isLayout(tp_loc)) {
- msg.prefix(player, "§5Teleport", "No receiver found!");
- goto("main");
- }
- loc.add(tp_loc, 0.5, -3, 0.5);
-
- setTpWallX(disp_loc, tinted_glass_mat);
- sound.spawn(disp_loc, piston_sound, sound_category_ambient);
- array = array.new(4);
- array[0] = player.getUuid(player);
- array[1] = disp_loc;
- array[2] = tp_loc;
- array[3] = false;
- list.add(tp_list, array);
- sgoto(30, "tp_ticker");
- }
- goto("main");
- @tp_ticker
- array = list.getIndex(tp_list, 0);
- list.removeIndex(tp_list, 0);
- block_loc = array[1];
- list.add(tp_list, array);
- setTpWallFull(block_loc, tinted_glass_mat);
- sound.spawn(block_loc, piston_sound, sound_category_ambient);
- sgoto(30, "tp_final");
- goto("main");
- @tp_final
- array = list.getIndex(tp_list, 0);
- list.removeIndex(tp_list, 0);
- player_uuid = array[0];
- block_loc = array[1];
- tp_loc = array[2];
- adventure = array[3];
- set.remove(tp_set, player_uuid);
- sound.spawn(block_loc, piston_sound, sound_category_ambient);
- setTpWallFull(block_loc, air_mat);
- player = player.get(player_uuid);
- if(player == null) {
- goto("main");
- }
- if(adventure) {
- //Party
- if(player.isInParty(player) && player.isPartyLeader(player)) {
- party_id = player.getPartyId(player);
- party_list = party.getList(party_id);
- iter = list.iterator(party_list);
- while(hasNext(iter)) {
- p = player.get(next(iter));
- p_name = player.getName(p);
- p_loc = entity.getLocation(p);
- if(!loc.isSameWorld(random_tp_loc, p_loc)) {
- msg.prefix(player, "§5Party", string.concat(p_name, "§c is in another world."));
- msg.prefix(p, "§5Party", "§cYou are in another world.");
- continue;
- }
- if(loc.distance(random_tp_loc, p_loc) > 5) {
- msg.prefix(player, "§5Party", string.concat(p_name, "§c is too far away."));
- msg.prefix(p, "§5Party", "§cYou are too far away.");
- continue;
- }
- if(player.hasMinigame(p)) {
- msg.prefix(player, "§5Party", string.concat(p_name, "§c is in a game."));
- msg.prefix(p, "§5Party", "§cYou are in a game.");
- continue;
- }
- if(player.hasQuest2(p)) {
- msg.prefix(player, "§5Party", string.concat(p_name, "§c is doing a quest."));
- msg.prefix(p, "§5Party", "§cYou are doing a quest.");
- continue;
- }
- if(player.isOnAdventure(p)) {
- msg.prefix(player, "§5Party", string.concat(p_name, "§c is already on an adventure."));
- msg.prefix(p, "§5Party", "§cYou are already on an adventure.");
- continue;
- }
- if(player.isAfk(p)) {
- msg.prefix(player, "§5Party", string.concat(p_name, "§c is afk."));
- msg.prefix(p, "§5Party", "§cYou are afk.");
- continue;
- }
- if(!player.hasClearInventory(p)) {
- msg.prefix(player, "§5Party", string.concat(p_name, "§c has no clear inventory."));
- msg.prefix(p, "§5Party", "§cYou have no clear inventory.");
- continue;
- }
- player.teleport(p, tp_loc, false);
- player.setAdventure(p, true);
- player.setAdventureStart(p, tp_loc);
- addAdventureDisplay(p, adventure_aim_loc);
- title.reset(p);
- title.setSub(p, "Have fun!");
- title.send(p, "§cAdventure");
- msg.prefix(p, "§5Adventure", "To complete your adventure, go to the survival spawn. You cannot teleport. If you die, you start again!");
- }
- goto("main");
- }
- if(!player.hasClearInventory(player)) {
- msg.prefix(player, "§5Adventure", "Your inventory needs to be empty!");
- goto("main");
- }
- player.teleport(player, tp_loc, false);
- player.setAdventure(player, true);
- player.setAdventureStart(player, tp_loc);
- addAdventureDisplay(player, adventure_aim_loc);
- sound.spawn(tp_loc, adv_tp_sound, sound_category_ambient);
- title.send(player, "§cAdventure", "Have fun!");
- msg.prefix(player, "§5Adventure", "To complete your adventure, go to the survival spawn. You cannot teleport. If you die, you start again!");
- goto("main");
- }
- player.teleport(player, tp_loc, false);
- sound.spawn(tp_loc, adv_tp_sound, sound_category_ambient);
- goto("main");
- function teleporter.setLayout() {
- a = array.new(58);
- a[0] = teleporter.getProp(0, 0, 0, null, $dispenser_mat);
- a[1] = teleporter.getProp(-1, 0, 0, $planks_tag, null);
- a[2] = teleporter.getProp(2, 0, 0, $planks_tag, null);
- a[3] = teleporter.getProp(-1, 0, -1, $planks_tag, null);
- a[4] = teleporter.getProp(0, 0, 2, $planks_tag, null);
- a[5] = teleporter.getProp(-1, 0, 0, $planks_tag, null);
- a[6] = teleporter.getProp(2, 0, 0, $planks_tag, null);
- a[7] = teleporter.getProp(0, 0, -2, $planks_tag, null);
- a[8] = teleporter.getProp(-2, 0, 0, $planks_tag, null);
- a[9] = teleporter.getProp(-1, 0, 0, $slabs_tag, null);
- a[10] = teleporter.getProp(0, 0, 1, $slabs_tag, null);
- a[11] = teleporter.getProp(0, 0, 1, $slabs_tag, null);
- a[12] = teleporter.getProp(1, 0, 1, $slabs_tag, null);
- a[13] = teleporter.getProp(1, 0, 0, $slabs_tag, null);
- a[14] = teleporter.getProp(1, 0, 0, $slabs_tag, null);
- a[15] = teleporter.getProp(1, 0, -1, $slabs_tag, null);
- a[16] = teleporter.getProp(0, 0, -1, $slabs_tag, null);
- a[17] = teleporter.getProp(0, 0, -1, $slabs_tag, null);
- a[18] = teleporter.getProp(-1, 0, -1, $slabs_tag, null);
- a[19] = teleporter.getProp(-1, 0, 0, $slabs_tag, null);
- a[20] = teleporter.getProp(-1, 0, 0, $slabs_tag, null);
- a[21] = teleporter.getProp(1, 1, 2, null, $shroomlight_mat);
- a[22] = teleporter.getProp(-2, -2, -2, $logs_tag, null);
- a[23] = teleporter.getProp(0, -1, 0, $logs_tag, null);
- a[24] = teleporter.getProp(0, -1, 0, $logs_tag, null);
- a[25] = teleporter.getProp(0, -1, 0, $logs_tag, null);
- a[26] = teleporter.getProp(0, 0, 4, $logs_tag, null);
- a[27] = teleporter.getProp(0, 1, 0, $logs_tag, null);
- a[28] = teleporter.getProp(0, 1, 0, $logs_tag, null);
- a[29] = teleporter.getProp(0, 1, 0, $logs_tag, null);
- a[30] = teleporter.getProp(4, 0, 0, $logs_tag, null);
- a[30] = teleporter.getProp(0, -1, 0, $logs_tag, null);
- a[31] = teleporter.getProp(0, -1, 0, $logs_tag, null);
- a[32] = teleporter.getProp(0, -1, 0, $logs_tag, null);
- a[33] = teleporter.getProp(0, 0, -4, $logs_tag, null);
- a[34] = teleporter.getProp(0, 1, 0, $logs_tag, null);
- a[35] = teleporter.getProp(0, 1, 0, $logs_tag, null);
- a[36] = teleporter.getProp(0, 1, 0, $logs_tag, null);
- a[37] = teleporter.getProp(1, -3, 0, $planks_tag, null);
- a[38] = teleporter.getProp(1, 0, 0, $planks_tag, null);
- a[39] = teleporter.getProp(1, 0, 0, $planks_tag, null);
- a[40] = teleporter.getProp(1, 0, 1, $planks_tag, null);
- a[41] = teleporter.getProp(0, 0, 1, $planks_tag, null);
- a[42] = teleporter.getProp(0, 0, 1, $planks_tag, null);
- a[43] = teleporter.getProp(-1, 0, 1, $planks_tag, null);
- a[44] = teleporter.getProp(-1, 0, 0, $planks_tag, null);
- a[45] = teleporter.getProp(-1, 0, 0, $planks_tag, null);
- a[46] = teleporter.getProp(-1, 0, -1, $planks_tag, null);
- a[47] = teleporter.getProp(0, 0, -1, $planks_tag, null);
- a[48] = teleporter.getProp(0, 0, -1, $planks_tag, null);
- a[49] = teleporter.getProp(1, 0, 0, $planks_tag, null);
- a[50] = teleporter.getProp(1, 0, 0, $planks_tag, null);
- a[51] = teleporter.getProp(1, 0, 0, $planks_tag, null);
- a[52] = teleporter.getProp(0, 0, 1, $planks_tag, null);
- a[53] = teleporter.getProp(0, 0, 1, $planks_tag, null);
- a[54] = teleporter.getProp(-1, 0, 0, $planks_tag, null);
- a[55] = teleporter.getProp(-1, 0, 0, $planks_tag, null);
- a[56] = teleporter.getProp(0, 0, -1, $planks_tag, null);
- a[57] = teleporter.getProp(1, 0, 0, null, $shroomlight_mat);
- setScriptVar("tp_layout", a);
- }
- function teleporter.getLayout() {
- return getScriptVar("tp_layout");
- }
- function teleporter.getProp(x, y, z, block_tag, block_mat) {
- a = array.new(5);
- a[0] = x;
- a[1] = y;
- a[2] = z;
- a[3] = block_tag;
- a[4] = block_mat;
- return a;
- }
- function teleporter.isLayout(clicked_loc) {
- clicked_mat = block.getType(block.get(clicked_loc));
- if(clicked_mat == $shroomlight_mat) {
- clicked_loc = loc.mod(clicked_loc, 0, 4, 0);
- }
- disp_block = block.get(clicked_loc);
- disp_mat = block.getType(block.get(clicked_loc));
- if(disp_mat != $dispenser_mat) {
- return false;
- }
- if(block.getDirectionalFace(disp_block) != "DOWN") {
- return false;
- }
- layout = teleporter.getLayout();
- loc = loc.mod(clicked_loc, 0, 0 ,0);
- for(i = 0; i < array.getSize(layout); i++) {
- a = layout[i];
- loc.add(loc, a[0], a[1], a[2]);
- tag = a[3];
- mat = a[4];
- block = block.get(loc);
- if(mat == null) {
- if(!block.hasTag(block, tag)) {
- return false;
- }
- } else {
- if(block.getType(block) != mat) {
- return false;
- }
- }
- }
- return true;
- }
- function setTpWallX(chest_loc, item_type) {
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -1, -1)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, 2, -1, 0)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -1, 1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -1, -1)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, -2, -1, 0)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -1, 1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -1, -1, 2)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, 0, -1, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 1, -1, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -1, -1, -2)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, 0, -1, -2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 1, -1, -2)), item_type);
-
- //block.setMaterial(block.get(loc.mod(chest_loc, 2, -2, -1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -2, 0)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, 2, -2, 1)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, -2, -2, -1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -2, 0)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, -2, -2, 1)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, -1, -2, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 0, -2, 2)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, 1, -2, 2)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, -1, -2, -2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 0, -2, -2)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, 1, -2, -2)), item_type);
-
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -3, -1)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, 2, -3, 0)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -3, 1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -3, -1)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, -2, -3, 0)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -3, 1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -1, -3, 2)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, 0, -3, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 1, -3, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -1, -3, -2)), item_type);
- //block.setMaterial(block.get(loc.mod(chest_loc, 0, -3, -2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 1, -3, -2)), item_type);
- }
- function setTpWallFull(chest_loc, item_type) {
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -1, -1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -1, 0)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -1, 1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -1, -1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -1, 0)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -1, 1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -1, -1, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 0, -1, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 1, -1, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -1, -1, -2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 0, -1, -2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 1, -1, -2)), item_type);
-
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -2, -1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -2, 0)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -2, 1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -2, -1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -2, 0)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -2, 1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -1, -2, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 0, -2, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 1, -2, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -1, -2, -2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 0, -2, -2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 1, -2, -2)), item_type);
-
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -3, -1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -3, 0)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 2, -3, 1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -3, -1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -3, 0)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -2, -3, 1)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -1, -3, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 0, -3, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 1, -3, 2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, -1, -3, -2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 0, -3, -2)), item_type);
- block.setMaterial(block.get(loc.mod(chest_loc, 1, -3, -2)), item_type);
- }
- function removeAdventureDisplay(player) {
- //display.remove(player, 10);
- }
- function addAdventureDisplay(player, location) {
- x = string.number(loc.getX(location));
- y = string.number(loc.getY(location));
- z = string.number(loc.getZ(location));
- //display.add(player, 10, string.concat("§2Adventure Target: §r", x, " ", y, " ", z));
- }
|