1

Execute command help! (replacing blocks under you)

CassisDrinker •6/26/14 12:40 pm
•
928
•
6/27/2014 10:08 am
Hello! my name's CassisDrinker, owner of a build team named ProjectZer0
in our newest map, I'm experiencing technical difficulties with redstone.
I'm making a (very difficult) maze with a little twist, and in the "difficult" level when you walk over a block from the correct route to get out, the block underneath you gets replaced with an emerald block. one problem: I don't know the exact syntax to make this happen. What I currently have is this:

/execute @p[r=1] x y z setblock x y z minecraft:emerald_block 0 replace minecraft:grass_block

when I run this command using the "type" function in minecraft, it works perfectly fine. but when I run the command using the command blocks it says that [r=1], the region at said coords, is not a correct number. how can I fix this and why is this not a problem when I type it in the normal minecraft chat?

p.s. the block that's to replaced isn't a grass block and it isn't so either in the syntax, but I made it a grass block in order to protect the originality of my map.

The person with the right answer will be credited when I upload the map on PMC.

Thank you very much,
A very frustrated CassisDrinker
Posted by
CassisDrinker
Level 8 : Apprentice Architect
2

  Have something to say?

Join • Sign in

4

Skylinerw
• 06/27/2014 10:08 am
• Level 16 : Journeyman System
CassisDrinker
Skylinerw

/execute @a ~ ~ ~ fill ~ ~-1 ~ ~ ~-1 ~ minecraft:emerald_block 0 replace minecraft:grass_block


Do the command blocks positively need to have the coordinates ~ ~ ~ or can I replace the "~" with x y z?


The ~ indicates relative coordinates, meaning at the players' location. If you'd rather fill a single block in at a specific location, you'd insert exact coordinates.
1
CassisDrinker
• 06/27/2014 9:49 am
• Level 8 : Apprentice Architect
Skylinerw

/execute @a ~ ~ ~ fill ~ ~-1 ~ ~ ~-1 ~ minecraft:emerald_block 0 replace minecraft:grass_block


Do the command blocks positively need to have the coordinates ~ ~ ~ or can I replace the "~" with x y z?
1
Skylinerw
• 06/26/2014 5:46 pm
• Level 16 : Journeyman System
CassisDrinker/execute @p[r=1] x y z setblock x y z minecraft:emerald_block 0 replace minecraft:grass_block


TheRedSkorpion is correct concerning the radius; the player selector concerns what's going on around the initiator, which is the command block.

The /setblock command does not support replacing specific blocks. You'll have to use /fill for that:

/execute @a ~ ~ ~ fill ~ ~-1 ~ ~ ~-1 ~ minecraft:emerald_block 0 replace minecraft:grass_block
1
TheRedSkorpion
• 06/26/2014 5:40 pm
• Level 20 : Expert System
Hi CassisDrinker,
So the problem is simple to fix:
When you run your command in a cmd block, it will only apply to the nearest player to the cmdblock BUT in a 1 block radius from it. That's why it work when you type it yourself.

By the way, I think you don't have the good setblock command. For example, if I type this command in chat:
/setblock ~ ~-1 ~ minecraft:emerald_block 0 replace minecraft:grass_block
It'll transform any block that I'm standing on in emerald block.

I can see that with the context, your syntax of the command and what you say in the p.s., you might think that only grass block will be transformed into emerald block but it's not the case. With what I know, this is the setblock syntax:
/setblock <x> <y> <z> <TileName> [dataValue] [oldBlockHandling] [dataTag]
the data tag is not the block that is replaced.

In other words, "replace" doesn't mean "replace that ype of block with that type of block". It means "replace that block at x y z with that type of block (that you mention)" whatever if the block is solid, air, water, etc at x y z.


Generaly my explaination are bad but I hope they are understandable and that I helped for your project!
1

Welcome