I figured it has something to do with using the /scoreboard command to create a scoreboard like this
/scoreboard objectives add example minecraft.used:minecraft.id "example name"but from there I don't really know where to go. Is there any way to store the location of the block placed? would summoning a tagged entity and placing blocks around that be easier?
11 Answer
I have not tested this method but it should work fine anyway.
Step 1: set up a scoreboard objective that detects when you place a block.
/scoreboard objectives add dirt minecraft.used:minecraft.dirtStep 2: let the commands know what block to target when you place a dirt block. We will do this by detecting the first four blocks for dirt, then summoning an armor stand at the dirt.
/execute as @a[scores={dirt=1}] at @s if block ^ ^ ^1 dirt run summon armor_stand ~ ~ ~ {CustomName:"\"this is a dirt block\""}Repeat this command four times, but replacing the third ^ number with 2 3 and 4, to reach four blocks.
Step 3: finish off the machine by resetting the player's dirt score.
/scoreboard players reset @a dirtDoes this help?
EDIT: If you use the machine above it will keep going past the block, not good for if you're not changing the block into something else. To avoid this, just run the commands like this:
/execute as @a[tag=!dirtscores={dirt=1}] at @s if block ^ ^ ^1 dirt run summon armor_stand ~ ~ ~ {CustomName:"\"this is a dirt block\""}
/execute as @a[scores={dirt=1}] at @s if block ^ ^ ^1 dirt run tag @s add dirtThat will tag the player with a tag that prevents the machine from going any further with detecting blocks. Just copy it four times and replace the 1 in the tildes with 2 3 and 4.