Autonomous Target-Locking Sentries

Three glowing defense turrets swivel independently around a central outpost to lock onto approaching monsters and eliminate them with rapid-fire volleys.

Java EditionWands, Weapons & ToolsMedium24 commandsTested on a real 26.2 & 26.3 server
Three glowing Minecraft defense turrets on sea-lantern pedestals fire rapid orange plasma volleys at approaching husks. Download the GIF Video & GIF © www.9minecraft.net

Projectiles & MissilesTechnologyIndustrialCyanOrangeBlackMini-gameAdventure MapMap MakingBlock displaysSmooth animation (interpolation)Summoned mobsBlock building (fill/setblock/clone)Rotation math21+ commands

Three glowing defense cannons mounted on sea-lantern pedestals guard a central deepslate outpost. As husks approach from all directions, each turret smoothly turns on its own to track the nearest threat in its sector and fires rapid three-round plasma volleys.

The bolts streak across the platform with glowing orange dust trails, dealing arrow damage on impact and vanishing as soon as they strike a target or time out.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_t dummy
  2. /fill ~-3 ~-1 ~-3 ~3 ~-1 ~3 minecraft:deepslate_tiles
  3. /fill ~-1 ~-1 ~-1 ~1 ~-1 ~1 minecraft:crying_obsidian
  4. /summon minecraft:villager ~ ~ ~ {Tags:["c9_bait"],NoAI:1b,Invulnerable:1b,Silent:1b,PersistenceRequired:1b}
  5. /summon minecraft:marker ~ ~ ~ {Tags:["c9_spawner"]}
  6. /summon minecraft:block_display ~-7 ~2.35 ~-5 {Tags:["c9_turret"],block_state:{Name:"minecraft:dispenser",Properties:{facing:"south"}},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.35f,-0.35f,-0.35f],scale:[0.7f,0.7f,1.4f]},teleport_duration:2,Glowing:1b,glow_color_override:65535,brightness:{sky:15,block:15}}
  7. /summon minecraft:block_display ~7 ~2.35 ~-5 {Tags:["c9_turret"],block_state:{Name:"minecraft:dispenser",Properties:{facing:"south"}},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.35f,-0.35f,-0.35f],scale:[0.7f,0.7f,1.4f]},teleport_duration:2,Glowing:1b,glow_color_override:65535,brightness:{sky:15,block:15}}
  8. /summon minecraft:block_display ~0 ~2.35 ~7 {Tags:["c9_turret"],block_state:{Name:"minecraft:dispenser",Properties:{facing:"south"}},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.35f,-0.35f,-0.35f],scale:[0.7f,0.7f,1.4f]},teleport_duration:2,Glowing:1b,glow_color_override:65535,brightness:{sky:15,block:15}}
  9. /execute at @e[tag=c9_turret] run fill ~ ~-2 ~ ~ ~-1 ~ minecraft:polished_deepslate
  10. /execute at @e[tag=c9_turret] run setblock ~ ~-1 ~ minecraft:sea_lantern

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

  1. /scoreboard players add #c9_t c9_t 1
  2. /execute if score #c9_t c9_t matches 12.. run scoreboard players set #c9_t c9_t 0
  3. /execute store result score #c9_cnt c9_t if entity @e[tag=c9_target,nbt={DeathTime:0s}]
  4. /execute as @e[tag=c9_spawner] at @s run tp @s ~ ~ ~ ~37 ~
  5. /execute if score #c9_cnt c9_t matches ..3 if score #c9_t c9_t matches 1..2 at @e[tag=c9_spawner] run summon minecraft:husk ^ ^ ^12 {Tags:["c9_target"]}
  6. /execute as @e[tag=c9_turret] at @s if entity @e[tag=c9_target,nbt={DeathTime:0s},distance=..15] facing entity @e[tag=c9_target,nbt={DeathTime:0s},distance=..15,limit=1,sort=nearest] eyes run tp @s ~ ~ ~ ~ ~
  7. /execute as @e[tag=c9_turret] at @s if score #c9_t c9_t matches 1..3 if entity @e[tag=c9_target,nbt={DeathTime:0s},distance=..15] run summon minecraft:block_display ^ ^ ^1.1 {Tags:["c9_bolt"],block_state:{Name:"minecraft:shroomlight"},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.1f,-0.1f,-0.35f],scale:[0.2f,0.2f,0.7f]},teleport_duration:1,Glowing:1b,glow_color_override:16755200,brightness:{sky:15,block:15}}
  8. /execute as @e[tag=c9_bolt] unless score @s c9_t matches 1.. at @s facing entity @e[tag=c9_target,nbt={DeathTime:0s},distance=..18,limit=1,sort=nearest] eyes run tp @s ~ ~ ~ ~ ~
  9. /scoreboard players add @e[tag=c9_bolt] c9_t 1
  10. /execute as @e[tag=c9_bolt] at @s run tp @s ^ ^ ^1.5
  11. /execute as @e[tag=c9_bolt] at @s run particle minecraft:dust{color:[1.0,0.65,0.0],scale:1.2} ~ ~ ~ 0.05 0.05 0.05 0 2
  12. /execute as @e[tag=c9_bolt] at @s run damage @e[tag=c9_target,nbt={DeathTime:0s},distance=..1.4,limit=1,sort=nearest] 3 minecraft:arrow
  13. /execute as @e[tag=c9_bolt] at @s if entity @e[tag=c9_target,nbt={DeathTime:0s},distance=..1.4] run kill @s
  14. /kill @e[tag=c9_bolt,scores={c9_t=15..}]

How it works

Frames from the test run

Autonomous Target-Locking Sentries - frame 1Autonomous Target-Locking Sentries - frame 2Autonomous Target-Locking Sentries - frame 3

Recorded on our own test server: 60 frames at about 9.9 fps. Our image check saw: Three cyan-glowing cannons on sea-lantern pedestals surround a central deepslate outpost with a villager and fire three-round glowing orange bolt volleys with orange dust trails at approaching husks.

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. Clear a flat 25x25 or larger open area and stand in the center where you want the outpost.
  2. Run each of the 10 setup commands in chat (or from impulse command blocks) to create the scoreboard, central pad, villager, spawner marker, and three turret cannons.
  3. Place 14 repeating command blocks in a row, set all of them to Always Active, and paste the 14 loop commands in exact order from 1 to 14.
  4. Make sure the command blocks stay in loaded chunks (or inside your spawn chunks) so the sentries continue running.
  5. Watch the three turrets automatically swivel toward incoming husks and eliminate them with rapid-fire volleys.

Use it with real players

To use these sentries to guard your own Survival base instead of running an automated demo, skip the c9_bait villager and c9_spawner marker in setup, omit loop commands 3, 4, and 5, and change tag=c9_target in the remaining loop commands to type=#minecraft:raiders or specific monster types such as type=minecraft:zombie or type=minecraft:skeleton so the turrets automatically target natural night monsters near your home.

Remove it again 8 commands

  1. /kill @e[tag=c9_turret]
  2. /kill @e[tag=c9_bolt]
  3. /kill @e[tag=c9_target]
  4. /kill @e[tag=c9_bait]
  5. /kill @e[tag=c9_spawner]
  6. /scoreboard objectives remove c9_t
  7. /fill ~-10 ~ ~-10 ~10 ~3 ~10 minecraft:air
  8. /fill ~-3 ~-1 ~-3 ~3 ~-1 ~3 minecraft:grass_block

FAQ

Can I add more than three turrets?

Yes. Summon extra block_display entities with the tag c9_turret anywhere within 18 blocks of your defense zone and build pedestals under them; every loop command targets @e[tag=c9_turret] automatically.

Why do the turrets stop shooting at a monster the instant it dies?

The target selectors check nbt={DeathTime:0s}, which immediately ignores monsters as soon as their death animation begins so turrets switch straight to the next live threat.

Commands used

/damage/execute/fill/kill/particle/scoreboard/setblock/summon/tp

Similar creations

Join 9Minecraft News & Guides