Minecraft 1.12 testfor command conversion to 1.13
I was using the /testfor
command to have a command block open an iron door if there was a feather (or other item) in a nearby item frame. 1.13 doesn't seem to recognize it. Anybody know how this works in 1.13?
testfor @e[type=Item_Frame,r=5] {Item:{id:"minecraft:feather"}}
The /testfor command became obsolete in Minecraft 1.13, and has been replaced by the /execute command*.
Quoting user RecycledCap:
nbt data is a selector in the new update so you can do for example
execute at @e[nbt={<nbt>}]
You can do this to fix your problem:
/execute if entity @p[nbt={SelectedItem:{id:"<item>":}}] run <command>
It will do the same as typing
/testfor @e {SelectedItem:{id:"<item>"}}
and then putting a comparator to the command block with the command, and then running the command which you wanna run.
In your case, testfor @e[type=Item_Frame,r=5] {Item:{id:"minecraft:feather"}}
becomes something like /execute if entity @e[type=Item_Frame,r=5;nbt={SelectedItem:{id:"minecraft:feather":}}] run <command>
.
* Source is this thread on Minecraftforum.net
Joachim is close but the command will not succeed.
The testfor command has been removed and was replaced with the if option in the execute command.
The execute command equivalent:
execute if entity @e[type=minecraft:item_frame,distance=..5,nbt={Item:{id:"minecraft:feather"}}] run <chained command>
Replace chained command
with whatever command you want to execute if the conditions are true.