If wanted to make a data pack that takes the block under me and then says:

"The block under me is [block]".

How would I do that?

If this was like a mix between Java and Minecraft then it would look something like this:

String blockUnderMe = block ~ ~-1 ~
tellraw @s {"text":"The block under me is" blockUnderMe}

But it isn't.

1 Answer 1


A rough sketch of an approach you could use to do this would be:

  • use /loot spawn ... mine ~ ~-1 ~ to spawn an item entity corresponding to the item that the block below your feet would drop when mined (you could include a tool with silk touch here, e.g. minecraft:shears{Enchantments:[{id:"minecraft:silk_touch",lvl:1}]} if you wanted to)

  • use a tellraw command with a selector component to get the name of that newly created item entity

Of course, this only works on blocks that drop themselves when mined (with silk touch), which might be enough for your particular application, but if you need this to work for literally every single block in the game, you're going to need to use a lookup table.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .