1

Help with coding

spychicken123 3/30/20 11:33 pm
214
3/31/2020 1:35 am
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
Posted by
spychicken123
Level 43 : Master Taco
26

  Have something to say?

JoinSign in

1

Geforce
03/31/2020 1:35 am
Level 64 : High Grandmaster Modder
history
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.
2

Welcome