cloning.txt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. event.load("custom_command");
  2. event.load("block_click");
  3. event.load("player_leave");
  4. event.load("player_giveup");
  5. command.add("pos1");
  6. command.add("pos2");
  7. command.add("use");
  8. command.add("rg");
  9. list.new("undotype");
  10. list.new("undodata");
  11. list.new("undoloc");
  12. areapermanent = false;
  13. if(player == null) {
  14. term();
  15. }
  16. if(!perm.has(player, "isMod") || !perm.has(player, "isBuilder")) {
  17. player.speak(player, "§dClone", "§rNo perms for that");
  18. term();
  19. }
  20. player.speak(player, "§dClone", "§rHave fun");
  21. @wait
  22. wait();
  23. if(event == "player_leave" || event == "player_giveup") {
  24. term();
  25. }
  26. if(event == "custom_command") {
  27. if(command == "use") {
  28. temp = item.getType(entity.getEquip(player, "hand"));
  29. if(temp != "minecraft:air") {
  30. tool = temp;
  31. player.speak(player, "§dClone", "§rTool gesetzt");
  32. } else {
  33. player.speak(player, "§dClone", "§rMit Luft kannst du nichts anklicken");
  34. }
  35. removeVar("temp");
  36. goto("wait");
  37. }
  38. if(command == "pos1") {
  39. temploc = entity.getLocation(player);
  40. wepos1 = temploc;
  41. player.speak(player, "§dClone", "§rPos1 gesetzt");
  42. removeVar("temploc");
  43. areapermanent = false;
  44. goto("wait");
  45. }
  46. if(command == "pos2") {
  47. temploc = entity.getLocation(player);
  48. wepos2 = temploc;
  49. player.speak(player, "§dClone", "§rPos2 gesetzt");
  50. removeVar("temploc");
  51. areapermanent = false;
  52. goto("wait");
  53. }
  54. if(command == "rg") {
  55. i = -1;
  56. while(++i < list.getSize(undotype)) {
  57. block.set(list.getIndex(undoloc, i), read.item(concat(list.getIndex(undotype, i), ":", text.number(list.getIndex(undodata, i)))));
  58. reset();
  59. }
  60. player.speak(player, "§dClone", "§rÄnderungen rückgängig gemacht");
  61. goto("wait");
  62. }
  63. }
  64. if(event == "block_click") {
  65. p = player;
  66. bloc = block_loc;
  67. if(tool == item.getType(entity.getEquip(player, "hand"))) {
  68. if(!areapermanent) {
  69. if(wepos1 == null || wepos2 == null) {
  70. player.speak(player, "§dClone", "§rWähle zuerst einen Bereich aus!");
  71. goto("wait");
  72. }
  73. world1 = loc.getCoord(wepos1, "w");
  74. world2 = loc.getCoord(wepos2, "w");
  75. if(world1 != world2) {
  76. player.speak(player, "§dClone", "§rDie Welten der Koordinaten stimmen nicht überein!");
  77. goto("wait");
  78. }
  79. x1 = loc.getCoord(wepos1, "bx");
  80. y1 = loc.getCoord(wepos1, "by");
  81. z1 = loc.getCoord(wepos1, "bz");
  82. x2 = loc.getCoord(wepos2, "bx");
  83. y2 = loc.getCoord(wepos2, "by");
  84. z2 = loc.getCoord(wepos2, "bz");
  85. if(x1 > x2) {
  86. helper = x2;
  87. x2 = x1;
  88. x1 = helper;
  89. }
  90. if(y1 > y2) {
  91. helper = y2;
  92. y2 = y1;
  93. y1 = helper;
  94. }
  95. if(z1 > z2) {
  96. helper = z2;
  97. z2 = z1;
  98. z1 = helper;
  99. }
  100. removeVar("helper");
  101. copystartloc = read.location(concat(world1, ":", x1, ":", y1, ":", z1));
  102. xcopyedgedistance = x2 - x1;
  103. ycopyedgedistance = y2 - y1;
  104. zcopyedgedistance = z2 - z1;
  105. areapermanent = true;
  106. }
  107. counter = 0;
  108. list.clear(undotype);
  109. list.clear(undodata);
  110. list.clear(undoloc);
  111. bloc = loc.mod(bloc, 0, 1, 0);
  112. x = -1;
  113. while(inc("x") <= xcopyedgedistance) {
  114. y = -1;
  115. while(inc("y") <= ycopyedgedistance) {
  116. z = -1;
  117. while(inc("z") <= zcopyedgedistance) {
  118. relloc1 = loc.mod(copystartloc, x, y, z);
  119. relloc2 = loc.mod(bloc, x, y, z);
  120. list.add(undotype, block.getType(relloc2));
  121. list.add(undodata, block.getData(relloc2));
  122. list.add(undoloc, relloc2);
  123. if(block.getType(relloc1) != "minecraft:air") {
  124. block.clone(relloc1, relloc2);
  125. }
  126. if(inc("counter") == 1500) {
  127. waitfor(1);
  128. counter = 0;
  129. }
  130. reset();
  131. }
  132. }
  133. }
  134. player.speak(p, "§dClone", "§rBereich geklont");
  135. goto("wait");
  136. }
  137. }
  138. goto("wait");