Build an automated mechanical cannon in vanilla Minecraft that rotates smoothly, locks onto wandering monsters, and blasts them with glowing plasma rounds.
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.
/scoreboard objectives add c9_t dummy/fill ~-1 ~ ~-1 ~1 ~ ~1 polished_blackstone_slab[type=bottom]/setblock ~ ~ ~ lodestone/setblock ~ ~1 ~ hopper/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]}}]}/summon husk ~7 ~ ~7 {Tags:["c9_e","c9_mob"],Glowing:1b,ArmorItems:[{},{},{},{id:"minecraft:iron_helmet",count:1}]}/summon husk ~-7 ~ ~6 {Tags:["c9_e","c9_mob"],Glowing:1b,ArmorItems:[{},{},{},{id:"minecraft:iron_helmet",count:1}]}/summon husk ~6 ~ ~-7 {Tags:["c9_e","c9_mob"],Glowing:1b,ArmorItems:[{},{},{},{id:"minecraft:iron_helmet",count:1}]}/execute as @e[tag=c9_turret] at @s run scoreboard players add @s c9_t 1/execute as @e[tag=c9_turret] at @s facing entity @e[tag=c9_mob,sort=nearest,limit=1] eyes run tp @s ~ ~ ~ ~ ~/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/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/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/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]}}]}/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/execute as @e[tag=c9_turret,scores={c9_t=25..}] run scoreboard players set @s c9_t 0/execute as @e[tag=c9_bullet] at @s facing entity @e[tag=c9_mob,sort=nearest,limit=1] eyes run tp @s ^ ^ ^0.85 ~ ~/execute at @e[tag=c9_bullet] run particle flame ~ ~ ~ 0.05 0.05 0.05 0.02 3 force/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/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/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/execute as @e[tag=c9_TurretSpawn] run summon husk ~-8 ~ ~-7 {Tags:["c9_e","c9_mob"],Glowing:1b}setup #5 Summons the central turret marker at <code>~ ~1.8 ~</code> with three riding <code>block_display</code> entities scaled into an iron housing, a netherite cannon barrel, and a glowing sea lantern sensor.loop #2 Rotates the turret marker every tick so it faces the eyes of the nearest monster tagged <code>c9_mob</code>.loop #4 Copies the marker's yaw and pitch rotation directly into the riding <code>block_display</code> parts, which smoothly interpolate their movement over 2 ticks.loop #6 Every 25 ticks (1.25 seconds), if a monster is within 18 blocks, the sentry spawns a glowing magma projectile at the tip of the barrel using local coordinates <code>^ ^0.05 ^1.5</code>.loop #9 Guides active projectiles toward the nearest monster at 0.85 blocks per tick, creating a fast homing plasma bolt.loop #13 When a projectile comes within 1.6 blocks of a monster, it triggers an explosion particle burst and deals 12 explosion damage.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.
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.
/kill @e[tag=c9_e]/fill ~-1 ~ ~-1 ~1 ~1 ~1 air/scoreboard objectives remove c9_tThe block display entities have teleport_duration set to 2 ticks, which tells the Minecraft client to smoothly blend rotation changes every tick.
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.
/damage/data/execute/fill/particle/playsound/scoreboard/setblock/summon/tp
▶Magnetic Rail-Track Javelin AssemblerProjectiles & MissilesExpert22 cmds
▶Pachinko-Board Trick-Shot CrossbowProjectiles & MissilesExpert24 cmds
▶Steampunk Piston-Hammer Pilebunker GauntletProjectiles & MissilesMedium24 cmds
▶16-Way Automated ArtilleryProjectiles & MissilesHard25 cmds
▶Artillery Projectile SimulatorProjectiles & MissilesHard24 cmds
▶Automated Airstrike BombardmentProjectiles & MissilesMedium22 cmds