I was wondering if there was a way, using command blocks, to check whether a block is solid (meaning that you can stand on it) or when it is not (e.g. ladder, sign, torch). I did some digging around online but I could not find anything.
The reason that I ask is because I am making a custom item that detects when a player has a block above their head, and the current command that I am using is /execute at @a if block ~ ~2 ~ minecraft:air
, which does not differentiate between solid and transparent blocks.
I'm using version 1.14.
Best Answer
The best method I found is letting a snowball hit a block or not. The convenient thing about this is that the snowball disappears instantly when it hits a block, but otherwise keeps existing. The snowball is also the smallest entity that exists and still collides with other things (together with egg, baby chicken and baby rabbit).
The main principle is this:
This summons a snowball 2.7 blocks above the player that moves downwards with 0.6 block per tick. These values are chosen because of the collision box sizes of snowballs and players. 1 tick later you can then check whether the snowball still exists or not.
Here is a more complete setup:
test:collision_setup.mcfunction
test:collision_check.mcfunction
Details and problems:
0
for example with..0.01
.