mojira.dev
MC-124973

"/execute if block" doesn't print block id of compared block

The bug

The title may not be the most accurate description, or imply the best way to fix this. Here's my motivation:

In 1.12.2, you were able to print the block id and data value of a certain block into chat by using /testforblock with a different block id, and then with a different data value, on it. This was very useful for investigating client/server desync bugs (or features...), and I'm sure there are other use cases. The 1.13 equivalent of /testforblock, /execute if block, doesn't print such feedback into chat anymore.

To fix this issue, /execute if block could be given some appropriate chat output. If this is deemed to not be in the spirit of /execute, I suggest adding block id and block state output to /data get block.

Reproduction steps

  1. Place a snow layer at your location

    /setblock ~ ~ ~ snow[layers=1]
  2. Use /execute if block

    /execute if block ~ ~ ~ snow[layers=5]

    ❌ It only says "Test failed", expected would be something like: "Test failed, found minecraft:snow[layers=1] instead of the expected block" (possibly also including the expected block and coordinates)

Linked issues

Attachments

Comments 13

This is still an Issue in 1.14.4 and the 1.15-Snapshots.
This seems forgotten, as it wasn't updated in a long time and might be resolved as "invalid" or "won't fix".
Whatever, I hope we can get a way to store the id of a block somewhere. Right now in the game you would use hardcoding to relate scoreboard value to block (hardcoding) or use the loot command to store the drop of a block somewhere. If you're using "/loot" in your datapack it can potentially be unreliable because of block loot tables from other datapacks.
If the content of this report was in the game you could pair this with the upcoming storage (in 1.15-snaphots). Then you could have the id stored directly without hardcoding anything and with no potential conflicts between datapacks.

for some blocks, a workaround is to summon an arrow above the block and get the block id from inBlockState.Name and the block states from inBlockState.Properties of the arrow

Can confirm in 20w51a.

Can confirm in 21w03a.

Can confirm in 21w05a.

3 more comments

Can confirm in 1.17.

Can confirm in 1.17.1.

Can confirm in 1.19 and 22w24a.

Can confirm in 1.21.4. Also would like to request ownership of this report to maintain it.

[Mod] redstonehelper

sof

(Unassigned)

Confirmed

Commands

/execute-if-block

Minecraft 18w06a, 1.15.2, 20w08a, 20w51a, 21w03a, ..., 1.17.1, 1.19, 22w24a, 1.19.3, 1.21.4

Retrieved