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?

  • 2
    What are your restrictions? Could players just place command blocks or structure blocks that were prepared for them with data? Or use spawn eggs? Or throw snowballs? Dec 8 '18 at 15:24

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.dirt

Step 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 dirt

Does 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 dirt

That 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.