Getting the name/id of a block using commands

Getting the name/id of a block using commands - Crop mother and daughter sitting on bed while using laptop

I want to make a scale datapack in Minecraft, however to do that I need to know which block is currently being 'scanned'. Assuming there was a /whatblock command, I could then ideally do /execute as @e[tag=Small] store result entity @s HandItems string 1 run whatblock ~ ~ ~

Unfortunately, of course basically none of that works, both because Minecraft seems to hate string datatypes and because the /whatblock command doesn't seem to exist. I was playing with the idea of getting an Enderman to pick up the block, thus making it NBT data, but a. I don't know how to force an Enderman to do that and b. The Enderman would then need to pick up pretty much any block, including obsidian, making them extremely dangerous.

Currently, the only other option I can see is to make a giant list for every single block in Minecraft, then go If block ~ ~ ~ stone then set handitem to stone. If block ~ ~ ~ dirt then set handitem to dirt... etc As you can imagine, for each of the 3172 blocks in the game, I'd need a line of code, which would need to run for every single block in the reference build.

As such, any alternative would be greatly appreciated.






Pictures about "Getting the name/id of a block using commands"

Getting the name/id of a block using commands - Cheerful black manager looking at smartphone while walking down street
Getting the name/id of a block using commands - Crop joiner working with wooden block using sharp tool
Getting the name/id of a block using commands - Student with documents and laptop happy about getting into university



How do you get a command Block name?

Minecraft Windows 10 EditionDescription (Minecraft ID Name)Minecraft IDCommand Block (minecraft:command_block)137

What is the ID for a command block?

The blank is for the particular block you are looking for. Let's say you're lost in the Nether and need to find your Nether Portal, you could type : /locateblock obsidian, and get the coordinates for the nearest obsidian, most likely being your, said, Portal.



18 Items You Can ONLY Get With COMMANDS In Minecraft (1.13-1.17+)




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Tatiana Syrikova, Ono Kosuki, Ono Kosuki, Ketut Subiyanto