1

Need help with execute command

TheWebExpert 5/13/18 6:12 pm
196
5/15/2018 4:53 pm
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?
Posted by
TheWebExpert
Level 4 : Apprentice Miner
2

  Have something to say?

JoinSign in

3

TheWebExpert
05/15/2018 4:53 pm
Level 4 : Apprentice Miner
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)?
1
craftykids
05/14/2018 12:18 am
Level 53 : Grandmaster Pixel Painter
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?
1
SUPERIONtheKnight
05/13/2018 7:02 pm
Level 30 : Artisan System
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".

/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_block
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.

/kill @e[type=minecraft:area_effect_cloud,tag=test,r=5]
I hope this helps!
~SUPERIONtheKnight
1

Welcome