Build an automated defense turret in Minecraft Java Edition that tracks moving targets and launches smoke-trailing homing rockets that detonate on impact.
Projectiles & MissilesTechnologyIndustrialFireOrangeWhiteBlackPvPAdventure MapMap MakingBlock displaysItem displaysArmor standsFireworksBlock building (fill/setblock/clone)SoundsRotation math21+ commands
The Automated Homing Missile Sentry is a self-operating defense turret built with display entities and scoreboard timers. Placed at the center of your base, its glowing head swivels continuously to lock onto nearby threats and launches custom rockets that arc through the air.
In this self-running demo, a glowing target dummy orbits the platform while the turret tracks its movement. Every two seconds, the sentry fires a heat-seeking missile trailed by campfire smoke and bright sparks, culminating in a burst of lava and explosive particles when it hits the mark.
/scoreboard objectives add c9_timer dummy/fill ~-1 ~ ~-1 ~1 ~ ~1 polished_deepslate_slab[type=bottom]/setblock ~ ~ ~ lodestone/setblock ~ ~1 ~ hopper[facing=down]/summon block_display ~ ~2 ~ {Tags:["c9_all","c9_turret"],Glowing:1b,glow_color_override:65535,block_state:{Name:"minecraft:DISPENSER",Properties:{facing:"north"}},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],scale:[0.9f,0.9f,0.9f],translation:[-0.45f,-0.45f,-0.45f]}}/summon armor_stand ~ ~ ~-10 {Tags:["c9_all","c9_orbit"],Invisible:1b,NoGravity:1b,Marker:1b}/summon armor_stand ~ ~1 ~-10 {Tags:["c9_all","c9_target"],NoGravity:1b,Glowing:1b,CustomName:'{"text":"Target Dummy","color":"red"}',CustomNameVisible:1b,equipment:{head:{id:"minecraft:target",count:1},chest:{id:"minecraft:NETHERITE_CHESTPLATE",count:1}}}/scoreboard players add #main c9_timer 1/execute as @e[tag=c9_orbit] at @s facing ~ ~ ~ run tp @s ^-0.45 ^ ^-0.01 facing ~ ~ ~/execute at @e[tag=c9_orbit] run tp @e[tag=c9_target,limit=1] ~ ~1 ~/execute as @e[tag=c9_turret] at @s facing entity @e[tag=c9_target,limit=1] eyes run tp @s ~ ~ ~ ~ ~/execute at @e[tag=c9_turret] anchored eyes run particle dust{color:[1.0,0.1,0.1],scale:0.6} ^ ^ ^1.2 0 0 0 0 1 force/execute if score #main c9_timer matches 40.. at @e[tag=c9_turret] run summon item_display ~ ~0.6 ~ {Tags:["c9_all","c9_missile"],Glowing:1b,glow_color_override:16744192,item:{id:"minecraft:FIREWORK_ROCKET",count:1},transformation:{left_rotation:[0.707f,0f,0f,0.707f],right_rotation:[0f,0f,0f,1f],scale:[1.4f,1.4f,1.4f],translation:[0f,0f,0f]}}/execute if score #main c9_timer matches 40.. at @e[tag=c9_turret] run playsound entity.firework_rocket.launch master @a ~ ~ ~ 2 0.7/execute if score #main c9_timer matches 40.. run scoreboard players set #main c9_timer 0/execute as @e[tag=c9_missile] at @s facing entity @e[tag=c9_target,limit=1] eyes run tp @s ^ ^ ^0.65 ~ ~/execute as @e[tag=c9_missile] at @s run particle campfire_cosy_smoke ~ ~ ~ 0.05 0.05 0.05 0.01 2 force/execute as @e[tag=c9_missile] at @s run particle flame ~ ~ ~ 0.05 0.05 0.05 0.02 4 force/execute as @e[tag=c9_missile] at @s if entity @e[tag=c9_target,distance=..1.5] run particle explosion_emitter ~ ~ ~ 0 0 0 1 1 force/execute as @e[tag=c9_missile] at @s if entity @e[tag=c9_target,distance=..1.5] run playsound entity.generic.explode master @a ~ ~ ~ 1.5 1.2/execute as @e[tag=c9_missile] at @s if entity @e[tag=c9_target,distance=..1.5] run kill @ssetup #5 Summons a glowing <code>block_display</code> disguised as a dispenser. By offsetting its translation by <code>-0.45</code> on all axes, the block rotates smoothly around its exact center point when tracking targets.loop #2 Moves the invisible orbit marker sideways (<code>^-0.45</code>) every tick while constantly facing the center of the stage, causing the target dummy to walk in a clean circle around the sentry.loop #6 Every 40 ticks (2 seconds), summons a firework rocket <code>item_display</code> above the turret rotated 90 degrees forward so the tip of the rocket points toward its flight path.loop #9 Steers every active missile directly toward the target dummy's eyes and advances it <code>0.65</code> blocks forward per tick using local coordinates (<code>^ ^ ^0.65</code>).loop #12 Detects when a missile comes within 1.5 blocks of the target dummy and triggers a huge explosion particle effect before the final command removes the missile entity.


Recorded on our own test server: 50 frames at about 9.8 fps. Our image check saw: A small turret on a dark stone base fires projectiles leaving trails of fire and smoke particles toward a glowing white armor stand target in the distance at night.
Commands, video and screenshots: tested and recorded by www.9minecraft.net © 9Minecraft. Sharing a video or screenshot? Please credit www.9minecraft.net.
To make the sentry target survival players or hostile mobs instead of the demo dummy, replace every instance of @e[tag=c9_target,limit=1] and @e[tag=c9_target,distance=..1.5] in the loop commands with @e[type=#minecraft:raiders,limit=1,sort=nearest,distance=..24] for mobs or @a[gamemode=survival,limit=1,sort=nearest,distance=..24] for players, and add a /damage command right before the missile kills itself.
/kill @e[tag=c9_all]/scoreboard objectives remove c9_timer/fill ~-1 ~ ~-1 ~1 ~2 ~1 airThe turret head is a block_display entity rather than a solid block. By shifting its translation by minus half of its scale (-0.45), its pivot point is centered inside the entity, allowing smooth 360-degree pitch and yaw rotation.
In the demo, the target dummy never leaves the stage so every rocket hits within two seconds. If you adapt this for real mobs that might die early, add a lifetime scoreboard timer to each missile and kill any missile that stays alive longer than 100 ticks.
/execute/fill/kill/particle/playsound/scoreboard/setblock/summon/tp
▶Magnetic Rail-Track Javelin AssemblerProjectiles & MissilesExpert22 cmds
▶Steampunk Piston-Hammer Pilebunker GauntletProjectiles & MissilesMedium24 cmds
▶16-Way Automated ArtilleryProjectiles & MissilesHard25 cmds
▶Heat-Seeking Rocket LauncherProjectiles & MissilesMedium19 cmds
▶Homing Missile AirstrikeProjectiles & MissilesHard22 cmds
▶Nuclear Missile Launch and DetonationProjectiles & MissilesHard24 cmds