1
Help with coding
plz help me i am coding a mod, but when i try to run minecraft with this then it just crashes what am i doing wrong
final_command = (String) (("setblock ") + "" + ((createblockx)) + "" + (" ") + "" + ((createblocky)) + "" + (" ") + "" + ((createblockz))
+ "" + (" minecraft:repeating_command_block 0 replace {Command:\"/setblock ") + "" + (x) + "" + (" ") + "" + (y) + "" + (" ") + ""
+ (z) + "" + (" ") + "" + ((((((world.getBlockState(new BlockPos((int) x, (int) y, (int) z)))))))) + "" + ("\",TrackOutput:0,auto:1}"));
out1 = final_command.split("[");
out2 = out1[1].split("]");
it works fine without the last 2 things.
im trying to cut out a part that is surrounded by square brackets if you cant see that
final_command = (String) (("setblock ") + "" + ((createblockx)) + "" + (" ") + "" + ((createblocky)) + "" + (" ") + "" + ((createblockz))
+ "" + (" minecraft:repeating_command_block 0 replace {Command:\"/setblock ") + "" + (x) + "" + (" ") + "" + (y) + "" + (" ") + ""
+ (z) + "" + (" ") + "" + ((((((world.getBlockState(new BlockPos((int) x, (int) y, (int) z)))))))) + "" + ("\",TrackOutput:0,auto:1}"));
out1 = final_command.split("[");
out2 = out1[1].split("]");
it works fine without the last 2 things.
im trying to cut out a part that is surrounded by square brackets if you cant see that
1
final_command.replace("[", "").replace("]", "") will do the same thing without having to use split().
If that doesn't work, post the crashlog here using a pasting site such as paste.ubuntu.com. Either way, you need to clean up the first line where you assign final_command equal to the command string though. There should never be a time when you have six open parentheses and eight closing parentheses surrounding a function call, as doing so makes your code really hard to understand. Either remove unnecessary parentheses or break that assignment line up into a few separate lines.
If that doesn't work, post the crashlog here using a pasting site such as paste.ubuntu.com. Either way, you need to clean up the first line where you assign final_command equal to the command string though. There should never be a time when you have six open parentheses and eight closing parentheses surrounding a function call, as doing so makes your code really hard to understand. Either remove unnecessary parentheses or break that assignment line up into a few separate lines.
