To dynamically update a command block's command based on a name stored in a sign, follow these steps:
- Place a sign at coordinates (x, y, z) with the desired name on the first line.
- Set up a repeating command block with the following command to continuously update a storage with the sign's text:
/data modify storage minecraft:temp name set from block x y z Text1
- Set up a chain command block (conditional, always active) that runs after the repeating command block with the following commands to update the target command block's command:
/data modify block x2 y2 z2 Command set value "/player " append from storage minecraft:temp name
/data modify block x2 y2 z2 Command append value " spawn at -35.53 286.00 54.09 facing 1 1 in minecraft:overworld"
- The target command block at (x2, y2, z2) will now have its command updated whenever the sign's text changes.
This approach ensures that whenever the name on the sign is updated, the command in the target command block will also update accordingly.
For example, if the sign is at (100, 64, 200) and the target command block is at (101, 64, 200), the commands would be:
- Repeating command block at (100, 65, 200):
/data modify storage minecraft:temp name set from block 100 64 200 Text1
- Chain command block at (100, 65, 201):
/data modify block 101 64 200 Command set value "/player " append from storage minecraft:temp name
- Another chain command block at (100, 65, 202):
/data modify block 101 64 200 Command append value " spawn at -35.53 286.00 54.09 facing 1 1 in minecraft:overworld"
This setup allows you to change the name on the sign, and the command block's command will automatically update to reflect the new name.