Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * One-Command block generator by BossC2018
- *
- *
- *
- * If you want commands in the system that only run once, type the command in without any hashes or characters shown below
- *
- *
- *
- * Key for setting command blocks:
- *
- * # is used in front of all command block commands to declare it as such
- *
- * Either 0, 1, and 2 or I, C and R define impulse, chain, and repeating command blocks in that order
- * 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
- *
- * 1 and 0 define whether it is powered on or off
- *
- * It does not matter if you have one space inbetween the command block declaration and the start of the command
- * Having more than one space will have all following spaces appear in the beginning of the command, which will stop the command from working
- *
- *
- *
- * Examples of how this should be executed:
- *
- * #C1 kill @e[type=Zombie]
- *
- * ^ This command will create a conditional, powered chain command block that will have the command "kill @e[type=Zombie]" inside of it
- *
- *
- *
- * #i0 blockdata ~ ~ ~ {auto:0}
- *
- * ^This command will create an unconditional, unpowered impulse command block that will have the command "blockdata ~ ~ ~ {auto:0}" inside of it
- *
- *
- *
- * #r1 say Hello
- * #r1say Hello
- *
- * ^ Both commands will create an unconditional, powered repeating command block that will have the command "say Hello" inside of it
- *
- *
- *
- * When you are done entering commands, type "end" for it to summon the system
- *
- * Warning: As of right now, this system creates command blocks from down to up
- * 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
- * To prevent this from happening with large projects, you can separate your system into multiple commands, but the majority shouldn't have this problem
- */
- //Fix the stupid space resolution I came up with
- import java.util.Scanner;
- public class OneCommandBlock {
- public static void main(String[] arg) {
- Scanner keyboard = new Scanner(System.in);
- String[] command = new String[1000];
- String[] finishedCommand = new String[1000];
- String minecart = "commandblock_minecart";
- String falling = "falling_block";
- String customName[] = {"BC_Generator", "BC Generator"};
- String[] blockText = {"", "", ""};
- String space = "";
- int[] cap = {2, 5};
- int[] coordinate = {0, cap[0] - 1};
- String currentDirection = "up";
- int direction = 1;
- System.out.println("Warning: Know that conditionals do not work when blocks turn.");
- System.out.println("Add the commands here, type in \"end\" to generate the command.");
- /*for (int i = 0; i < 1000; i++) {
- try {
- command[i] = keyboard.nextLine();
- } catch (Exception e) {
- command[i] = "end";
- break;
- }
- if (command[i].equals(null)) {
- command[i] = "";
- i--;
- } else if (command[i].length() > 0 && (command[i].charAt(0) == '/' || command[i].charAt(0) == ' ')) {
- command[i] = "";
- i--;
- } else if (command[i].equalsIgnoreCase("end")) {
- i = 1000;
- }
- }*/
- for (int i = 0; i < 1000; i++) {
- try {
- command[i] = keyboard.nextLine();
- if (command[i].equals("")) {
- command[i] = " ";
- }
- } catch (Exception e) {
- command[i] = "end";
- break;
- }
- }
- for (int i = 0; i < 1000; i++) {
- direction = 1;
- for (int n = 0; n < 3; n++) {
- blockText[n] = "";
- }
- if (command[i].equalsIgnoreCase("end")) {
- finishedCommand[i] = "end";
- i = 1000;
- } else {
- blockText[0] += command[i].charAt(0);
- if (blockText[0].equals("#")) {
- blockText[1] = "" + command[i].charAt(1);
- blockText[2] = "" + command[i].charAt(2);
- for (int m = 0; m < 2; m++) {
- space = " ";
- for (int n = 0; n < 2; n++) {
- command[i] = command[i].replace("#I" + m + space, "");
- command[i] = command[i].replace("#i" + m + space, "");
- command[i] = command[i].replace("#0" + m + space, "");
- command[i] = command[i].replace("#C" + m + space, "");
- command[i] = command[i].replace("#c" + m + space, "");
- command[i] = command[i].replace("#1" + m + space, "");
- command[i] = command[i].replace("#R" + m + space, "");
- command[i] = command[i].replace("#r" + m + space, "");
- command[i] = command[i].replace("#2" + m + space, "");
- space = "";
- }
- }
- if (currentDirection.equals("up")) {
- coordinate[1]++;
- direction = 1;
- } else {
- coordinate[1]--;
- direction = 0;
- }
- if ((coordinate[1] == cap[0] && coordinate[0] != 0) || coordinate[1] == cap[1]) {
- direction = 5;
- }
- if (coordinate[1] > cap[1]) {
- currentDirection = "down";
- coordinate[0]++;
- coordinate[1]--;
- direction = 0;
- } else if (coordinate[1] < cap[0]) {
- currentDirection = "up";
- coordinate[0]++;
- coordinate[1]++;
- direction = 1;
- }
- if (blockText[1].equalsIgnoreCase("I") || blockText[1].equals("0")) {
- if (blockText[1].equals("I")) {
- direction += 8;
- }
- blockText[1] = "command_block";
- } else if (blockText[1].equalsIgnoreCase("R") || blockText[1].equals("2")) {
- if (blockText[1].equals("R")) {
- direction += 8;
- }
- blockText[1] = "repeating_command_block";
- } else {
- if (blockText[1].equals("C")) {
- direction += 8;
- }
- blockText[1] = "chain_command_block";
- }
- if (blockText[2].equals("0") == false) {
- blockText[2] = "1";
- }
- 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] + "}},";
- } else {
- if (!command[i].equals(" ")) {//Part of resolution
- finishedCommand[i] = "\t\t\t{id:" + minecart + ",CustomName:" + customName[0] + ",Command:" + command[i] + "},";
- } else {//Part of resolution
- finishedCommand[i] = " ";
- }
- }
- }
- }
- System.out.println("summon " + falling + " ~ ~0.55 ~ {");
- System.out.println("\tBlock:redstone_block,Time:1,Passengers:[");
- System.out.println("\t\t{id:" + falling + ",Block:activator_rail,Time:1,Passengers:[");
- System.out.println("\t\t\t{id:" + minecart + ",CustomName:" + customName[0] + ",Command:gamerule commandBlockOutput false},");
- 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},");
- System.out.println("");
- for (int i = 0; i < finishedCommand.length; i++) {
- if (finishedCommand[i].equals(" ")) {//Part of resolution
- }
- else if (finishedCommand[i].equalsIgnoreCase("end")) {
- break;
- } else {
- System.out.println(finishedCommand[i]);
- }
- }
- System.out.println("\t\t\t");
- 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.\\\\\\\"}\"}},");
- 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 + "]}},");
- 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}}");
- System.out.println("\t\t]}");
- System.out.println("\t]");
- System.out.println("}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment