Autonomous Tracking Sentry

Build an automated mechanical cannon in vanilla Minecraft that rotates smoothly, locks onto wandering monsters, and blasts them with glowing plasma rounds.

Java EditionWands, Weapons & ToolsMedium22 commandsTested on a real 26.2 & 26.3 server
A custom block turret fires a glowing, flaming projectile at a targeted mob at night. Download the GIF Video & GIF © www.9minecraft.net

Projectiles & MissilesTechnologyFireOrangeBlackWhiteMini-gameAdventure MapMap MakingBlock displaysSmooth animation (interpolation)Riding & passengersSummoned mobsBlock building (fill/setblock/clone)SoundsRotation math21+ commands

The Autonomous Tracking Sentry is a mechanical turret built using block display entities and an invisible marker brain. Sitting on a sleek netherite and iron pedestal at the center of the arena, the cannon swivels smoothly to lock onto nearby threats with a glowing red targeting laser before launching explosive plasma bolts.

In this self-running showcase, armored zombies spawn around the perimeter and march toward the turret. The sentry automatically prioritizes the closest monster, tracks its movement in real time, and blasts it away with fiery shockwaves.

1. Setup - type these once 8 commands

  1. /scoreboard objectives add c9_t dummy
  2. /fill ~-1 ~ ~-1 ~1 ~ ~1 polished_blackstone_slab[type=bottom]
  3. /setblock ~ ~ ~ lodestone
  4. /setblock ~ ~1 ~ hopper
  5. /summon marker ~ ~1.8 ~ {Tags:["c9_e","c9_turret"],Passengers:[{id:"minecraft:block_display",Tags:["c9_e","c9_part"],teleport_duration:2,block_state:{Name:"minecraft:iron_block"},transformation:{translation:[-0.4f,-0.4f,-0.4f],scale:[0.8f,0.8f,0.8f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}},{id:"minecraft:block_display",Tags:["c9_e","c9_part"],teleport_duration:2,block_state:{Name:"minecraft:netherite_block"},transformation:{translation:[-0.2f,-0.15f,0.2f],scale:[0.4f,0.4f,1.3f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}},{id:"minecraft:block_display",Tags:["c9_e","c9_part"],teleport_duration:2,block_state:{Name:"minecraft:sea_lantern"},transformation:{translation:[-0.25f,0.1f,-0.25f],scale:[0.5f,0.4f,0.6f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}]}
  6. /summon husk ~7 ~ ~7 {Tags:["c9_e","c9_mob"],Glowing:1b,ArmorItems:[{},{},{},{id:"minecraft:iron_helmet",count:1}]}
  7. /summon husk ~-7 ~ ~6 {Tags:["c9_e","c9_mob"],Glowing:1b,ArmorItems:[{},{},{},{id:"minecraft:iron_helmet",count:1}]}
  8. /summon husk ~6 ~ ~-7 {Tags:["c9_e","c9_mob"],Glowing:1b,ArmorItems:[{},{},{},{id:"minecraft:iron_helmet",count:1}]}

2. Loop - one repeating command block each (Always Active) 14 commands

  1. /execute as @e[tag=c9_turret] at @s run scoreboard players add @s c9_t 1
  2. /execute as @e[tag=c9_turret] at @s facing entity @e[tag=c9_mob,sort=nearest,limit=1] eyes run tp @s ~ ~ ~ ~ ~
  3. /execute as @e[tag=c9_turret] at @s rotated as @s run execute as @n[tag=c9_part,nbt={block_state:{Name:"minecraft:iron_block"}}] run data modify entity @s Rotation set from entity @e[tag=c9_turret,limit=1] Rotation
  4. /execute as @e[tag=c9_turret] at @s rotated as @s run execute as @e[tag=c9_part] run data modify entity @s Rotation set from entity @e[tag=c9_turret,limit=1] Rotation
  5. /execute at @e[tag=c9_turret] if entity @e[tag=c9_mob,distance=..18] positioned ~ ~ ~ run particle dust{color:[1.0,0.1,0.1],scale:0.7} ^ ^0.1 ^1.6 0 0 0 0 1 force
  6. /execute as @e[tag=c9_turret,scores={c9_t=25..}] at @s if entity @e[tag=c9_mob,distance=..18] run summon area_effect_cloud ^ ^0.05 ^1.5 {Tags:["c9_e","c9_bullet"],Duration:35,Radius:0f,Passengers:[{id:"minecraft:block_display",Tags:["c9_e"],Glowing:1b,glow_color_override:16755200,block_state:{Name:"minecraft:magma_block"},transformation:{translation:[-0.15f,-0.15f,-0.15f],scale:[0.3f,0.3f,0.3f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}]}
  7. /execute as @e[tag=c9_turret,scores={c9_t=25..}] at @s if entity @e[tag=c9_mob,distance=..18] run playsound minecraft:entity.blaze.shoot master @a ~ ~ ~ 1 1.4
  8. /execute as @e[tag=c9_turret,scores={c9_t=25..}] run scoreboard players set @s c9_t 0
  9. /execute as @e[tag=c9_bullet] at @s facing entity @e[tag=c9_mob,sort=nearest,limit=1] eyes run tp @s ^ ^ ^0.85 ~ ~
  10. /execute at @e[tag=c9_bullet] run particle flame ~ ~ ~ 0.05 0.05 0.05 0.02 3 force
  11. /execute as @e[tag=c9_bullet] at @s if entity @e[tag=c9_mob,distance=..1.6] run particle explosion ~ ~ ~ 0.2 0.2 0.2 0.1 5 force
  12. /execute as @e[tag=c9_bullet] at @s if entity @e[tag=c9_mob,distance=..1.6] run playsound minecraft:entity.generic.explode master @a ~ ~ ~ 0.7 1.3
  13. /execute as @e[tag=c9_bullet] at @s if entity @e[tag=c9_mob,distance=..1.6] run damage @e[tag=c9_mob,distance=..2.5,limit=1,sort=nearest] 12 minecraft:explosion
  14. /execute as @e[tag=c9_TurretSpawn] run summon husk ~-8 ~ ~-7 {Tags:["c9_e","c9_mob"],Glowing:1b}

How it works

Frames from the test run

Autonomous Tracking Sentry - frame 1Autonomous Tracking Sentry - frame 2Autonomous Tracking Sentry - frame 3

Recorded on our own test server: 57 frames at about 9.4 fps. Our image check saw: A small block turret on a dark stone base fires a glowing projectile with flame particles at a glowing mob on a grassy platform at night.

Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.

Build it in your world

  1. Create a flat clearing and stand where you want the sentry turret to sit.
  2. Run each command from the Setup list in chat once to build the base, summon the 3D turret display, and spawn test monsters.
  3. Place a line of 14 Repeating Command Blocks set to Always Active near your arena.
  4. Paste one Loop command into each repeating command block in order.
  5. Watch the cannon automatically swivel toward the glowing husks and fire homing explosive shots.
  6. When finished, run the Remove commands in chat to delete the turret, entities, and blocks.

Use it with real players

To make the sentry protect you against all hostile monsters in a survival or adventure world, replace tag=c9_mob in the loop commands with type=#minecraft:raiders or type=zombie, or target any mob except players by using type=!player,type=!marker,type=!block_display,type=!area_effect_cloud,type=!item.

Remove it again 3 commands

  1. /kill @e[tag=c9_e]
  2. /fill ~-1 ~ ~-1 ~1 ~1 ~1 air
  3. /scoreboard objectives remove c9_t

FAQ

Why does the turret barrel rotate so smoothly instead of snapping?

The block display entities have teleport_duration set to 2 ticks, which tells the Minecraft client to smoothly blend rotation changes every tick.

How do I change how fast the sentry fires?

Change the score check scores={c9_t=25..} in Loop commands 6, 7, and 8 to a smaller number like 10 for rapid fire, or 40 for a slower heavy cannon.

Commands used

/damage/data/execute/fill/particle/playsound/scoreboard/setblock/summon/tp

Similar creations

Join 9Minecraft News & Guides