In the map I'm making, players will have to choose which items to switch. In this case, I will clone the first block over to the side, clone the second block to the first block's position, and clone the first block to the second block's position. I know this works, however, players will choose which blocks to switch. In this case, whichever buttons they press will set up the command blocks to work. This means that I will need to add coordinates to a given command without removing the command. Is this possible?


Yes, this is possible. You can update the blockdata of the command block. Try something like this command:

/blockdata [X, Y and Z of the command block you want to change the command of] {Command:"/COMMAND_WITH_NEW_COORDINATES"}
  • But can the command you write to the new command block depend on the players position? – Joschua Mar 23 '19 at 21:34

I think you're going about this the wrong way. Instead of trying to change the hardcoded coordinates inside a command block, I'd suggest using relative coordinates and /execute. So when the player presses the first button, it summons an armor stand called Block1 at the location. When they press the second, it summons one called Block2. Then all you need to do is clone blocks relative to Block1 and Block2 and you've got what you need without modifying any commands at runtime :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.