Is there a way to make something conditional in a function? For example
setblock 5 10 5 air
tellraw @a {"rawtext":[{"text":"Placed!"}]} # <--- Make this command conditional (only runs if the setblock worked)
give @p diamond_helmet # <-- this runs anyway
I know how to do certain things conditionally such as running a command if a creeper is there:
execute @e[type=creeper,c=1] ~~~ execute @p ~~~ say Hi!
but for things other than single entity detection I don't know how to approach this.
Best Answer
This is a bit of a workaround, but it does the job:
-1
is the Block ID. If set to -1 it will work with any Block ID. The execute command basically detects if what the previous setblock command was done.