I was wondering how to detect grass and dirt blocks under a player and summon a tnt under them. I tried some things on my own and managed to set off a tnt at the player location, but I cannot summon it when the player is on the grass.


Solution 1:

To do this command, have this command in an always active repeating command block:

/execute at @a if block ~ ~-1 ~ minecraft:grass_block run summon tnt ~ ~ ~

The @a part checks all players. The if block ~ ~-1 ~ minecraft:grass_block checks if a player is on a grass block. The last part, run summon tnt ~ ~ ~ summons a tnt at the player who was on a grass block. I hope this helps.