There is no n
parameter. The correct parameter you're looking for is name
. The wiki has a list of all valid parameters here.
testfor @p[1303,56,518,2,name=JAMES_the_camel]
For 1.11-1.12, which removes shorthand coordinates:
testfor @p[x=1303,y=56,z=518,r=2,name=JAMES_the_camel]
And for 1.13+, which overhauled the command system (where /testfor
has essentially been merged into /execute
):
execute if entity @p[x=1303,y=56,z=518,distance=..2,name=JAMES_the_camel]
As well, because your chain is unconditional, it's going to activate no matter what and open the door. If you set it to conditional, it will only run its command if the command block physically behind it was successful. You will want to set your chain block to conditional or otherwise activate another set of command blocks based on the success of /testfor
.
You will want to use CommandStats, which are a set of triggers stored on an entity that will modify a target's score based on the success of commands run by the entity.
For example, you will want to use the "SuccessCount" trigger, which stores the number of successful iterations of a command (and in the case of /testforblocks
, will either be 0 for failure or 1 for success). You could also use "AffectedBlocks", which returns the number of matched blocks (0 for failure or the number of blocks found via /testforblocks
).
Prerequisites
Objective to hold the return value from CommandStats triggers:
/scoreboard objectives add Results dummy
You have a couple options for applying the triggers to the entities. The most direct way would be to use the CommandStats
compound directly when summoning:
/summon ArmorStand ~ ~1 ~ {CustomName:"craft",CommandStats:{SuccessCountName:"@e[type=ArmorStand,c=1]",SuccessCountObjective:"Results"}}
Or you could use the /stats
command. The second selector is not translated in this command, and is stored as literally written in the CommandStats
compound like above:
/stats entity @e[type=ArmorStand,name=craft] set SuccessCount @e[type=ArmorStand,c=1] Results
In order for these triggers to modify a target's score, that target must be tracked in the objective prior.
/scoreboard players set @e[type=ArmorStand,name=craft] Results 0
Detection
Your initial command.
/execute @e[type=ArmorStand,name=craft] ~ ~ ~ /testforblocks -15 56 -225 -15 56 -225 ~ ~ ~
Now the armor stand will have a "Results" score of 1 if it succeeded or 0 if it failed. You can then target the relevant armor stands.
/execute @e[type=ArmorStand,name=craft,score_Results_min=1] ~ ~ ~ /blockdata ~ ~ ~ {Items:[0:{Slot:4b,id:"minecraft:spawn_egg",Count:1b,tag:{RepairCost:0,display:{Name:"Sponge"},EntityTag:{id:"Blaze"}},Damage:0s}]}
There is no need to reset their score to 0 because it will do so the next time /testforblocks
fails.
Best Answer
Sadly this is not possible. You need to write at least one command per possible state. Luckily, SethBling recently did something very similar, so you can use his commands and modify them to your needs: https://sethbling.s3-us-west-2.amazonaws.com/Downloads/DataPacks/minecraft_earth.zip
I recommend for example Notepad++, which can use search+replace for all files in a folder at once.