Alternately, if there is a way to place a block so that it acts as if a player placed it, that would be even better... If not placeable it could just pop off and float, etc.
^ The above command targets the executors current position
Considering you are creating an .mcfunction file to do this, you will have created a datapack. Within this datapack you can create lists of blocks called block tags (more on block tags here). But essentailly, these blocks tags can be used in commands during if / unless statements to target multiple blocks.
If you create a block list within your datapack that contains blocks you don't want to place torches on called #invalidBlocks, the command will only succeed when it isn't on any blocks within this block list.
Hi,
I am attempting to write an mcfunction to place a field of torches down. But I don't want them floating in air if there is no block to put them on.
If floating torches were OK, I could just use a bunch of lines like:
setblock ~5 ~ ~-10 minecraft:torch keep
I'm having trouble finding examples that seem correct for this... in pseudocode, what I need is for example:
/execute detect ~5 ~ ~-10 down (not) minecraft:air /setblock ~5 ~ ~-10 minecraft:torch keep
Alternately, if there is a way to place a block so that it acts as if a player placed it, that would be even better... If not placeable it could just pop off and float, etc.
Does anyone have a solution?
Thanks in advance.
You could do something like this:
^ The above command targets the executors current position
Considering you are creating an .mcfunction file to do this, you will have created a datapack. Within this datapack you can create lists of blocks called block tags (more on block tags here). But essentailly, these blocks tags can be used in commands during if / unless statements to target multiple blocks.
If you create a block list within your datapack that contains blocks you don't want to place torches on called #invalidBlocks, the command will only succeed when it isn't on any blocks within this block list.
Hope this was helpful.
Good luck!