1
Need help with execute command
I have set up a scoreboard variable named Two1. In my command block I have this:
/execute @a[score_Two1=1,score_Two1_min=1] ~ ~ ~ /setblock ~ ~1 ~2 minecraft:redstone_block
If I manually do just the /setblock ~ ~1 ~2 minecraft:redstone_block command, the block is placed in the proper location.
However, if I set Two1's value to 1, I suddenly get a trail of redstone blocks following me. I do NOT want to program in specific coordinates in the first set of ~'s, because I'm duplicating this structure 8 times, and don't want to have to manually adjust each one. The whole point is that it should be relative to the command block itself.
Can anyone help with this?
/execute @a[score_Two1=1,score_Two1_min=1] ~ ~ ~ /setblock ~ ~1 ~2 minecraft:redstone_block
If I manually do just the /setblock ~ ~1 ~2 minecraft:redstone_block command, the block is placed in the proper location.
However, if I set Two1's value to 1, I suddenly get a trail of redstone blocks following me. I do NOT want to program in specific coordinates in the first set of ~'s, because I'm duplicating this structure 8 times, and don't want to have to manually adjust each one. The whole point is that it should be relative to the command block itself.
Can anyone help with this?
3
Superion's knowledge is superior!! Awesome! How long will this thing last? Will it "restart" when I reload the level, or do I have to re-generate it every time? Will it stay "forever" (which is what I want)?
Does it need to be done with only one command block? If not, could you have one command block run the command "testfor @a[score_Two1=1,score_Two1_min=1]", and have it pointing to a chain command block that runs the setblock command?
NOTE: This reply is for Minecraft 1.12.2. If you want the commands for a different version, let me know and I will do my best to help.
Unless you specify the coordinates, there isn't a way to make it relative to the command block again.
With that said, there is a workaround. You can summon an entity at the command blocks location and use the entity instead. I recommend using an area_effect_cloud because they don't cause as much lag as other entities do.
To demonstrate, Stand on the command block and use the following command to summon an area_effect_cloud with the tag "test".
You can now target "test" with a nested execute command.
Now obviously, you should use different tags for different command blocks unless you really want to select multiple at once. Also, I added c=1 to your command as it will only search for one entity this way making it less laggy.
If you need to remove the area_effect_cloud, you can use this kill command while standing next to it.
I hope this helps!
~SUPERIONtheKnight
Unless you specify the coordinates, there isn't a way to make it relative to the command block again.
With that said, there is a workaround. You can summon an entity at the command blocks location and use the entity instead. I recommend using an area_effect_cloud because they don't cause as much lag as other entities do.
To demonstrate, Stand on the command block and use the following command to summon an area_effect_cloud with the tag "test".
/summon minecraft:area_effect_cloud ~ ~-1 ~ {"Duration":2147483647,"Tags":["test"]}You can now target "test" with a nested execute command.
/execute @a[score_Two1=1,score_Two1_min=1,c=1] ~ ~ ~ execute @e[tag=test,c=1] ~ ~ ~ setblock ~ ~1 ~2 minecraft:redstone_blockNow obviously, you should use different tags for different command blocks unless you really want to select multiple at once. Also, I added c=1 to your command as it will only search for one entity this way making it less laggy.
If you need to remove the area_effect_cloud, you can use this kill command while standing next to it.
/kill @e[type=minecraft:area_effect_cloud,tag=test,r=5]I hope this helps!
~SUPERIONtheKnight
