How do I make a block trail for the player?

In Roblox, certain games implement trails, which basically is an effect where a player's trail basically follows them in their own material. Some are Rainbow, Basic Colors, etc. Also, in a given period of time, the last bit of the trail fades and is removed.

So I have made the basic concept of blocks under them to be placed, then to be replaced with air. The block has to be the one they are holding. So if I want an Oak Wood Planks trail, I will hold the material then while walking, it changes air to that block, and given a period of time, it disappears.

Can we do something similar in Minecraft Bedrock?


There are certain things you can and cannot do with your question. To make an actual trail, it is possible to make a block trail, but it would be extremely complex.

The Block Trail

A particle trail would simply use /particle, but since you want to use blocks, it's a bit more of a chore. What you need is a repeating command block with the command

execute <player> ~ ~ ~ detect ~ ~-1 ~ grass 0 summon armor_stand

into a sequence of chain command blocks with

execute @e[type=armor_stand] ~ ~ ~ setblock ~ ~-1 ~ wool 14
effect @e[type=armor_stand] invisibility 10 0 true
scoreboard players add @e[type=armor_stand] test 1
execute @e[type=armor_stand,scores={test=40}] ~ ~ ~ setblock ~ ~-1 ~ grass
execute @e[type=armor_stand,scores={test=40}] ~ ~ ~ kill @s

There are a few issues with this design; first, the armor stands when killed with have their particle (unless there is a way to do that and I don't know it). Additionally, it is extremely unflexable in the blocks, as this will only work with grass underneath a player. This works by summoning an armor stand on a target when they are stepping on a grass block. A timer is then run on the armor stand, and when it reaches 2 seconds, or 40 ticks, it kills the armorstand after replacing the block under it with grass. As well, the armorstand means you cannot do anything when you stop moving, but you could just replace it with an endermite or something.

Enchantment Trail Detection

As for the other part of your question, with a specific item being held, it can sort of be done. It can't be done with blocks, as a /replaceitem command or /clear command would not work or be inefficient respectively (but who said this was efficient). The way you can do it is with enchant ability. There's a genius technique I found on the internet that makes it so you can detect a certain item in someones inventory if it's enchantable. Let's say we have a Diamond Sword representing a netherite block per se. Then, before giving it to the player, enchant it with something. It needs to be something unique, so in this case it would be a smite 1 diamond sword. Then in a repeating commandblock, you would have

/enchant @a smite 1

If this succeeds, then we know the player has this tool out. If this represents a netherite block, then in a conditional chain command block you would have

/setblock <x> <y> <z> redstone_block

This location would set off the chain mentioned above. In a command block next to this, but not part of the chain, you would have a command block that does the same thing, but with air:

/setblock <x> <y> <z> air

thus clearing the location so that as soon as the player is no longer holding the sword it would stop the trail. There is an issue with this as well, and that's obviously that this will only work on one player at a time. Additionally, the trail will not delete itself after the item is no longer held.

Item Trail Detection

As an alternative to holding an item, you could swap trails using blocks and dropping them. This means a trail is always active, and thus gets rid of the worry that the trail won't disappear. This would use tags, as tags are amazing. When you drop an item, let's say planks as you say, you would have a repeating command block with

/execute @e[type=item,name="Oak Wood Planks"] ~ ~ ~ tag @p[r=2] add oakReset

This is to reset a player's tag, as if they have two tags for two different blocks, then that's an issue. After that have chain conditional command blocks that remove the player's tags, so if there was a blackstone trail,

/tag @a[tag=oakReset] remove blackstoneTrail

Continue this until you have covered every trail, then in the second to last chain conditional block put

/tag @a[tag=oakReset] add oakTrail

And in the last one, put

/tag @a[tag=oakReset,tag=oakTrail] remove oakReset

Then back in the original chain, it would be

/execute @a[tag=oakTrail] ~ ~ ~ detect ~ ~-1 ~ grass 0 summon armor_stand

I hope this answers your question in enough detail, if clarification needs to be done or I overlooked something because it was a fun challenge, then you can ask.