Example1 : /execute at @e setblock ~~~ glass_block
places a glass block at the feet of all players, mobs, boats, minecarts, armour stands, ect..
Syntax:
/execute <target: selector (required)> <command (required)>
The target is the entity(s) to effect. The position is where to run the command from, according to target, so ~~~ means where the target is. The command is any command, even another /execute command, may be placed.
Example2 (Java Edition [1]): /execute as @a[hasitem={name=diamond}] run say @s Congratulations, you found diamonds!
Example2 (Bedrock Edition): /execute as @a[hasitem={name=diamond}] run tell @s Congratulations, you found diamonds!
This command will check every player's inventory, if he/she has a diamond. Every player that had a diamond in their inventory will get the message "congratulations, you found diamonds!".
- ↑ (I think, could be wrong?? I have no idea how this command works on java edition)