123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- //---map specific---
- creative_world = world.get("creative");
- edge1 = loc.new(creative_world, 2991, 54, 2956);
- edge2 = loc.new(creative_world, 3009, 72, 2974);
- x1 = math.min(loc.getX(edge1), loc.getX(edge2));
- x2 = math.max(loc.getX(edge1), loc.getX(edge2));
- y1 = math.min(loc.getY(edge1), loc.getY(edge2));
- y2 = math.max(loc.getY(edge1), loc.getY(edge2));
- z1 = math.min(loc.getZ(edge1), loc.getZ(edge2));
- z2 = math.max(loc.getZ(edge1), loc.getZ(edge2));
- mid_x = (x1+x2)/2;
- mid_y = (y1+y2)/2;
- mid_z = (z1+z2)/2;
- //------------------
- air_material = material.get("AIR");
- stone_material = material.get("STONE");
- box_iterator = loc.iterator(creative_world, x1,y1,z1,x2,y2,z2);
- grav_down = list.new();
- while(hasnext(box_iterator)){
- temp_block = block.get(next(box_iterator));
- temp_type = block.getType(temp_block);
- if(temp_type != air_material){
- temp_array = array.new(2);
- temp_array[0] = temp_block;
- temp_array[1] = temp_type;
- list.add(grav_down, temp_array);
- }
- }
- //grav_down
- grav_up = list.new();
- grav_north = list.new();
- grav_south = list.new();
- grav_west = list.new();
- grav_east = list.new();
- box.create_rotations();
- active_grav = "down";
- possible_names_map = list.new();
- list.add(possible_names_map, "down");
- list.add(possible_names_map, "up");
- list.add(possible_names_map, "north");
- list.add(possible_names_map, "south");
- list.add(possible_names_map, "west");
- list.add(possible_names_map, "east");
- //Playerinv
- uuid = "6cc9f8c7-9dfd-44f4-a3f2-af30054411a8";//"e41b5335-3c74-46e9-a6c5-dafc6334a477"; (marvinius)
- player = player.get(uuid);
- player_inv = player.getInv(player);
- item_down = item.new(material.get("purple_concrete"),1);
- item.setName(item_down, text.new("down"));
- item_up = item.new(material.get("yellow_concrete"),1);
- item.setName(item_up, text.new("up"));
- item_north = item.new(material.get("pink_concrete"),1);
- item.setName(item_north, text.new("north"));
- item_south = item.new(material.get("magenta_concrete"),1);
- item.setName(item_south, text.new("south"));
- item_west = item.new(material.get("red_concrete"),1);
- item.setName(item_west, text.new("west"));
- item_east = item.new(material.get("blue_concrete"),1);
- item.setName(item_east, text.new("east"));
- inv.setItem(player_inv, 0, item_down);
- inv.setItem(player_inv, 1, item_up);
- inv.setItem(player_inv, 2, item_north);
- inv.setItem(player_inv, 3, item_south);
- inv.setItem(player_inv, 4, item_west);
- inv.setItem(player_inv, 5, item_east);
- //---events---
- event.load("block_click");
- //event.load("entity_damage");
- //event.load("player_move");
- //------------
- @wait
- wait();
- if(event == "block_click"){
- if(player.getName(player) != "SirTerence7"){
- goto("wait");
- }
- if(action == "PHYSICAL"){
- goto("wait");
- }
- player_hand = living.getHand(player);
- if(!item.hasName(player_hand)){
- goto("wait");
- }
- item_name = string.text(item.getName(player_hand));
- if(!list.contains(possible_names_map, item_name)){
- goto("wait");
- }
- cancel = true;
- active_grav = box.rotate(active_grav, item_name);
- }
- goto("wait");
- //---functions---
- function box.create_rotations(){
- list_iterator = iterator($grav_down);
- a = 0;
- while(hasnext(list_iterator)){
- if(a++ > 75){
- waitfor(2);
- a = 0;
- }
- temp_array = next(list_iterator);
- temp_loc = block.getLocation(temp_array[0]);
- list.add($grav_up, array.create(block.get(box.rotate_location(temp_loc, "down", "up")), temp_array[1]));
- list.add($grav_north, array.create(block.get(box.rotate_location(temp_loc, "down", "north")), temp_array[1]));
- list.add($grav_south, array.create(block.get(box.rotate_location(temp_loc, "down", "south")), temp_array[1]));
- list.add($grav_west, array.create(block.get(box.rotate_location(temp_loc, "down", "west")), temp_array[1]));
- list.add($grav_east, array.create(block.get(box.rotate_location(temp_loc, "down", "east")), temp_array[1]));
- }
- }
- function array.create(arg1, arg2){
- temp_array = array.new(2);
- temp_array[0] = arg1;
- temp_array[1] = arg2;
- return temp_array;
- }
- function box.rotate(from_rotation, to_rotation){
- New_Motion = box.rotate_Rotation(box.rotate_Rotation(entity.getMotion($player), from_rotation), to_rotation);
- Look_Array = entity.getLook($player);
- New_Look = box.rotate_Rotation(box.rotate_Rotation(Look_Array, from_rotation), to_rotation);
- player_loc = entity.getLocation($player);
- teleport_location = box.rotate_location(player_loc, from_rotation, to_rotation);
- entity.setGravity($player, false);
- entity.setMotion($player, 0, 0, 0);
- box.place(from_rotation, true);//clear
- box.place(to_rotation, false);//place
- entity.teleport($player, teleport_location);
- entity.setGravity($player, true);
- entity.setMotion($player, New_Motion[0], New_Motion[1], New_Motion[2]);
- entity.setLook($player, New_Look[0], New_Look[1], New_Look[2]);
- return to_rotation;
- }
- function box.place(rotation, clear){
- if(rotation == "down"){
- list_iterator = iterator($grav_down);
- }elseif(rotation == "up"){
- list_iterator = iterator($grav_up);
- }elseif(rotation == "north"){
- list_iterator = iterator($grav_north);
- }elseif(rotation == "south"){
- list_iterator = iterator($grav_south);
- }elseif(rotation == "west"){
- list_iterator = iterator($grav_west);
- }elseif(rotation == "east"){
- list_iterator = iterator($grav_east);
- }
- while(hasnext(list_iterator)){
- temp_array = next(list_iterator);
- if(clear){
- block_type = $air_material;
- }else{
- block_type = temp_array[1];
- }
- block.setMaterial(temp_array[0], block_type, false);//block.getType(temp_block));
- }
- }
- function box.rotate_location(loc, from_rotation, to_rotation){
- abs_loc = loc.mod(loc, 0, 0, 0);
- if(from_rotation == to_rotation){
- return abs_loc;
- }
- Coord_Array = array.new(3);
- Coord_Array[0] = loc.getX(abs_loc)-$mid_x;//X
- Coord_Array[1] = loc.getY(abs_loc)-$mid_y;//Y
- Coord_Array[2] = loc.getZ(abs_loc)-$mid_z;//Z
-
- //Coord_Array = box.rotate_Rotation(Coord_Array, from_rotation);
- Coord_Array = box.rotate_Rotation(box.rotate_Rotation(Coord_Array, from_rotation), to_rotation);
-
- loc.set(abs_loc, Coord_Array[0] + $mid_x, Coord_Array[1] + $mid_y, Coord_Array[2] + $mid_z);
- return abs_loc;
- }
- function box.rotate_Rotation(Coord_Array, rotation){
- New_Coord_Array = array.new(3);
-
- if(rotation == "down"){
- return Coord_Array;
- }elseif(rotation == "up"){
- New_Coord_Array[0] = Coord_Array[0]; // X = X
- New_Coord_Array[1] = -Coord_Array[1]; // Y = -Y
- New_Coord_Array[2] = Coord_Array[2]; // Z = Z
- }elseif(rotation == "north"){
- New_Coord_Array[0] = Coord_Array[0]; // X = X
- New_Coord_Array[1] = Coord_Array[2]; // Y = Z
- New_Coord_Array[2] = Coord_Array[1]; // Z = Y
- }elseif(rotation == "south"){
- New_Coord_Array[0] = Coord_Array[0]; // X = X
- New_Coord_Array[1] = -Coord_Array[2]; // Y = -Z
- New_Coord_Array[2] = -Coord_Array[1]; // Z = -Y
- }elseif(rotation == "west"){
- New_Coord_Array[0] = Coord_Array[1]; // X = -Y
- New_Coord_Array[1] = Coord_Array[0]; // Y = X
- New_Coord_Array[2] = Coord_Array[2]; // Z = Z
- }elseif(rotation == "east"){
- New_Coord_Array[0] = -Coord_Array[1]; // X = Y
- New_Coord_Array[1] = -Coord_Array[0]; // Y = -X
- New_Coord_Array[2] = Coord_Array[2]; // Z = Z
- }
- return New_Coord_Array;
- }
- function box.rotate_look(){
- return;
- }
- function box.get_look(){
- return;
- }
|