BossC2018

1 Cmd Gen 3/15/2017

Mar 16th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.10 KB | None | 0 0
  1. /*
  2. * One-Command block generator by BossC2018
  3. *
  4. *
  5. *
  6. * If you want commands in the system that only run once, type the command in without any hashes or characters shown below
  7. *
  8. *
  9. *
  10. * Key for setting command blocks:
  11. *
  12. * # is used in front of all command block commands to declare it as such
  13. *
  14. * Either 0, 1, and 2 or I, C and R define impulse, chain, and repeating command blocks in that order
  15. * If you are using I, C, and R to define command blocks, keep in mind that lowercase letters are unconditional command blocks while uppercase letters are conditional
  16. *
  17. * 1 and 0 define whether it is powered on or off
  18. *
  19. * It does not matter if you have one space inbetween the command block declaration and the start of the command
  20. * Having more than one space will have all following spaces appear in the beginning of the command, which will stop the command from working
  21. *
  22. *
  23. *
  24. * Examples of how this should be executed:
  25. *
  26. * #C1 kill @e[type=Zombie]
  27. *
  28. * ^ This command will create a conditional, powered chain command block that will have the command "kill @e[type=Zombie]" inside of it
  29. *
  30. *
  31. *
  32. * #i0 blockdata ~ ~ ~ {auto:0}
  33. *
  34. * ^This command will create an unconditional, unpowered impulse command block that will have the command "blockdata ~ ~ ~ {auto:0}" inside of it
  35. *
  36. *
  37. *
  38. * #r1 say Hello
  39. * #r1say Hello
  40. *
  41. * ^ Both commands will create an unconditional, powered repeating command block that will have the command "say Hello" inside of it
  42. *
  43. *
  44. *
  45. * When you are done entering commands, type "end" for it to summon the system
  46. *
  47. * Warning: As of right now, this system creates command blocks from down to up
  48. * That means having hundreds of command blocks will result in the command block line stopping at the sky limit, making your machine not 100% finished
  49. * To prevent this from happening with large projects, you can separate your system into multiple commands, but the majority shouldn't have this problem
  50. */
  51.  
  52.  
  53. //Fix the stupid space resolution I came up with
  54. import java.util.Scanner;
  55.  
  56. public class OneCommandBlock {
  57. public static void main(String[] arg) {
  58. Scanner keyboard = new Scanner(System.in);
  59. String[] command = new String[1000];
  60. String[] finishedCommand = new String[1000];
  61. String minecart = "commandblock_minecart";
  62. String falling = "falling_block";
  63. String customName[] = {"BC_Generator", "BC Generator"};
  64. String[] blockText = {"", "", ""};
  65. String space = "";
  66. int[] cap = {2, 5};
  67. int[] coordinate = {0, cap[0] - 1};
  68. String currentDirection = "up";
  69. int direction = 1;
  70.  
  71. System.out.println("Warning: Know that conditionals do not work when blocks turn.");
  72. System.out.println("Add the commands here, type in \"end\" to generate the command.");
  73.  
  74. /*for (int i = 0; i < 1000; i++) {
  75.  
  76. try {
  77. command[i] = keyboard.nextLine();
  78. } catch (Exception e) {
  79. command[i] = "end";
  80. break;
  81. }
  82.  
  83. if (command[i].equals(null)) {
  84. command[i] = "";
  85. i--;
  86. } else if (command[i].length() > 0 && (command[i].charAt(0) == '/' || command[i].charAt(0) == ' ')) {
  87. command[i] = "";
  88. i--;
  89. } else if (command[i].equalsIgnoreCase("end")) {
  90. i = 1000;
  91. }
  92.  
  93.  
  94. }*/
  95.  
  96. for (int i = 0; i < 1000; i++) {
  97. try {
  98. command[i] = keyboard.nextLine();
  99.  
  100. if (command[i].equals("")) {
  101. command[i] = " ";
  102. }
  103. } catch (Exception e) {
  104. command[i] = "end";
  105. break;
  106. }
  107. }
  108.  
  109.  
  110.  
  111.  
  112. for (int i = 0; i < 1000; i++) {
  113. direction = 1;
  114.  
  115. for (int n = 0; n < 3; n++) {
  116. blockText[n] = "";
  117. }
  118.  
  119. if (command[i].equalsIgnoreCase("end")) {
  120. finishedCommand[i] = "end";
  121. i = 1000;
  122. } else {
  123. blockText[0] += command[i].charAt(0);
  124.  
  125. if (blockText[0].equals("#")) {
  126. blockText[1] = "" + command[i].charAt(1);
  127. blockText[2] = "" + command[i].charAt(2);
  128.  
  129. for (int m = 0; m < 2; m++) {
  130. space = " ";
  131. for (int n = 0; n < 2; n++) {
  132. command[i] = command[i].replace("#I" + m + space, "");
  133. command[i] = command[i].replace("#i" + m + space, "");
  134. command[i] = command[i].replace("#0" + m + space, "");
  135. command[i] = command[i].replace("#C" + m + space, "");
  136. command[i] = command[i].replace("#c" + m + space, "");
  137. command[i] = command[i].replace("#1" + m + space, "");
  138. command[i] = command[i].replace("#R" + m + space, "");
  139. command[i] = command[i].replace("#r" + m + space, "");
  140. command[i] = command[i].replace("#2" + m + space, "");
  141. space = "";
  142. }
  143. }
  144.  
  145. if (currentDirection.equals("up")) {
  146. coordinate[1]++;
  147. direction = 1;
  148. } else {
  149. coordinate[1]--;
  150. direction = 0;
  151. }
  152.  
  153. if ((coordinate[1] == cap[0] && coordinate[0] != 0) || coordinate[1] == cap[1]) {
  154. direction = 5;
  155. }
  156.  
  157. if (coordinate[1] > cap[1]) {
  158. currentDirection = "down";
  159. coordinate[0]++;
  160. coordinate[1]--;
  161. direction = 0;
  162. } else if (coordinate[1] < cap[0]) {
  163. currentDirection = "up";
  164. coordinate[0]++;
  165. coordinate[1]++;
  166. direction = 1;
  167. }
  168.  
  169. if (blockText[1].equalsIgnoreCase("I") || blockText[1].equals("0")) {
  170. if (blockText[1].equals("I")) {
  171. direction += 8;
  172. }
  173.  
  174. blockText[1] = "command_block";
  175. } else if (blockText[1].equalsIgnoreCase("R") || blockText[1].equals("2")) {
  176. if (blockText[1].equals("R")) {
  177. direction += 8;
  178. }
  179.  
  180. blockText[1] = "repeating_command_block";
  181. } else {
  182. if (blockText[1].equals("C")) {
  183. direction += 8;
  184. }
  185.  
  186. blockText[1] = "chain_command_block";
  187. }
  188.  
  189. if (blockText[2].equals("0") == false) {
  190. blockText[2] = "1";
  191. }
  192.  
  193. finishedCommand[i] = "\t\t\t{id:" + minecart + ",CustomName:" + customName[0] + ",Command:setblock ~" + coordinate[0] + " ~" + coordinate[1] + " ~0 " + blockText[1] + " " + direction + " replace {auto:" + blockText[2] + ",Command:" + command[i] + "}},";
  194. } else {
  195. if (!command[i].equals(" ")) {//Part of resolution
  196. finishedCommand[i] = "\t\t\t{id:" + minecart + ",CustomName:" + customName[0] + ",Command:" + command[i] + "},";
  197. } else {//Part of resolution
  198. finishedCommand[i] = " ";
  199. }
  200. }
  201. }
  202. }
  203.  
  204. System.out.println("summon " + falling + " ~ ~0.55 ~ {");
  205. System.out.println("\tBlock:redstone_block,Time:1,Passengers:[");
  206. System.out.println("\t\t{id:" + falling + ",Block:activator_rail,Time:1,Passengers:[");
  207. System.out.println("\t\t\t{id:" + minecart + ",CustomName:" + customName[0] + ",Command:gamerule commandBlockOutput false},");
  208. System.out.println("\t\t\t{id:" + minecart + ",CustomName:" + customName[0] + ",Command:fill ~-1 ~1 ~-1 ~" + (coordinate[0] + 1) + " ~" + (cap[1] + 1) + " ~1 stained_glass 1},");
  209. System.out.println("");
  210.  
  211. for (int i = 0; i < finishedCommand.length; i++) {
  212. if (finishedCommand[i].equals(" ")) {//Part of resolution
  213.  
  214. }
  215. else if (finishedCommand[i].equalsIgnoreCase("end")) {
  216. break;
  217. } else {
  218. System.out.println(finishedCommand[i]);
  219. }
  220. }
  221.  
  222. System.out.println("\t\t\t");
  223. System.out.println("\t\t\t{id:" + minecart + ",CustomName:" + customName[0] + ",Command:setblock ~-2 ~2 ~ wall_sign 4 replace {Text1:\"{\\\\\\\"text\\\\\\\":\\\\\\\"BC Generator\\\\\\\",\\\\\\\"color\\\\\\\":\\\\\\\"red\\\\\\\",\\\\\\\"clickEvent\\\\\\\":{\\\\\\\"action\\\\\\\":\\\\\\\"run_command\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"/fill ~0 ~-1 ~-1 ~" + (coordinate[0] + 3) + " ~" + (cap[1] - 1) + " ~1 air \\\\\\\"},\\\\\\\"bold\\\\\\\":true}\",Text2:\"{\\\\\\\"text\\\\\\\":\\\\\\\"Right-click the\\\\\\\"}\",Text3:\"{\\\\\\\"text\\\\\\\":\\\\\\\"sign to remove the\\\\\\\"}\",Text4:\"{\\\\\\\"text\\\\\\\":\\\\\\\"command blocks.\\\\\\\"}\"}},");
  224. System.out.println("\t\t\t{id:" + minecart + ",CustomName:" + customName[0] + ",Command:setblock ~ ~-2 ~ command_block 1 replace {auto:1,Command:kill @e[name=" + customName[0] + ",type=" + minecart + "]}},");
  225. System.out.println("\t\t\t{id:" + minecart + ",CustomName:" + customName[0] + ",Command:setblock ~ ~-1 ~ command_block 1 replace {auto:1,Command:fill ~ ~-1 ~ ~ ~1 ~ air}}");
  226. System.out.println("\t\t]}");
  227. System.out.println("\t]");
  228. System.out.println("}");
  229. }
  230. }
Advertisement
Add Comment
Please, Sign In to add comment