✔️ How To Use The Execute Command In Minecraft! ✔️

Video Summary
In this video I show you how to use the Minecraft execute command (1.15+) by breaking down execute at, execute if, and execute run. I demonstrate practical examples like replacing the block under you (grass to stone) and constantly checking for a block type to trigger an effect, like killing a player when they step on glass. I also explain execute as to run a command from an entity or player, and invite you to comment ideas for a more advanced execute tutorial.

Formatted Transcript

Hey everybody, it’s UnderMyCap, and welcome back to another Minecraft video. Today I’m going to show you how to use the /execute command in Minecraft 1.15 and above.

Before we start, thank you so much to TGIF for commenting and giving me the idea for this video—I honestly wasn’t sure what to make next. If you have any video ideas or questions, leave them in the comments. They don’t even have to be questions; they can be anything.

What We’re Covering

In this post, I’m going to focus on:

execute if, execute at, and execute run

These subcommands all interact with each other, so you’ll often see them combined in the same command. Sometimes a command will include all three, sometimes only one or two.

Using execute at

The execute at subcommand does exactly what it sounds like: it executes a command at a specific location—typically the location of an entity.

Here’s the basic structure:

/execute at <target> run <command>

I’m going to use myself as the target:

/execute at UnderMyCap run ...

If you’re on Minecraft Java Edition, you’d replace UnderMyCap with your own username. You can also target:

all entities, all players, a random player, the nearest player, yourself, and more. You can also filter targets by things like type, name, distance, etc.

Example: Replacing the Block Under You

In one of my previous videos (linked in the description of the original video), I showed how to execute particles at yourself to create a cape particle effect. This time, we’ll do something similar, but with blocks.

We’ll make it so that if I’m standing on a grass block, it replaces the block under me with stone.

Use this command:

/execute at UnderMyCap if block ~ ~-1 ~ minecraft:grass_block run setblock ~ ~-1 ~ minecraft:stone

Once you run it, you should see stone appear underneath you. The stone won’t “follow” you automatically, but every time you step onto grass, the command checks and replaces the block under you with stone.

I don’t personally find this specific example super useful on its own, but it can be used for mini-games (like painting the floor in games such as Block Party). It’s also a fun way to create effects where blocks change as you move.

Turning Off Command Spam

Since commands like this can constantly output messages, you can disable command block output with:

/gamerule commandBlockOutput false

This keeps the command working without clogging your chat or command output.

Making the Block Change Everywhere You Go

If you want blocks to change under you no matter what you’re standing on (not just grass), remove the if block part and only use execute at with setblock.

For example:

/execute at UnderMyCap run setblock ~ ~-1 ~ minecraft:stone

Now, wherever you move—even while flying—the block under you will be replaced with stone. Personally, I find this a bit annoying because it can be hard to get down afterward, but it’s the same idea used in those command block setups where something like a bookshelf appears under you wherever you walk.

What execute run Does

The execute run part is essentially how you attach the final command you want to execute. Think of it as the “do this now” portion of the execute chain.

In other words, run is where you place the command that actually happens (like setblock, kill, say, etc.).

Example: Standing on Glass Kills You

Let’s say you want to prevent players from entering an area, or you want to troll your friends. You can execute a command when someone stands on a specific block. For example, if a player stands on glass, they die.

Here’s the command:

/execute at UnderMyCap if block ~ ~-1 ~ minecraft:glass run kill UnderMyCap

When this is active, you won’t die until you step onto glass. As soon as you walk over a glass block, the command detects it and runs /kill on you.

This works with any block type, and it’s constantly checking if the condition is true—so it can get annoying if there’s lots of glass around, but it’s useful for traps, restricted zones, and mini-game mechanics.

Using execute as

The execute as subcommand executes a command as an entity—meaning it runs from that entity’s perspective.

For example:

/execute as UnderMyCap run say hi

This makes it look like UnderMyCap is the one saying “hi” in chat.

Wrapping Up

Thanks for watching this short guide on the execute command. If you want me to make a more advanced execute tutorial, leave a comment.

If you have any other video suggestions, put them in the comments. My social links are in the description of the original video, along with my website (UnderMyCap.com). If you haven’t checked it out yet, you can find it there.

Also, make sure to subscribe and like, because I post Minecraft content, unboxings, and I’ve pre-ordered Minecraft Dungeons—so when that comes out, I’ll be making videos on it and I’ll try to livestream as well so we can discover the game together.

Thank you so much for watching, and I hope to see you in the next video.

Video Thumbnail

Leave a Reply

Scroll to Top