Build an automated defense tower in Minecraft using command blocks that tracks wandering monsters and zaps them with vibrant cyan particle beams.
Lasers & BeamsTechnologyMysticCyanGoldWhiteAdventure MapMini-gameMap MakingBlock displaysItem displaysSummoned mobsBlock building (fill/setblock/clone)Glowing outlinesRotation math21+ commands
The Autonomous Sentinel Turret is a self-operating defense structure built on a stone pedestal with a glowing beacon core. A floating golden crystal orbits above the base, rotating to lock onto nearby threats.
As wandering monsters approach the tower, the sentinel calculates the angle and fires a continuous cyan laser beam that zaps targets with magic particles and lightning bursts until they are defeated.
/scoreboard objectives add c9_timer dummy/fill ~-1 ~ ~-1 ~1 ~ ~1 polished_deepslate_slab[type=bottom]/setblock ~ ~ ~ chiseled_polished_blackstone/setblock ~ ~1 ~ polished_blackstone_wall/setblock ~ ~2 ~ beacon/summon block_display ~ ~3.3 ~ {Tags:["c9_turret"],Glowing:1b,glow_color_override:65535,block_state:{Name:"minecraft:sea_lantern"},transformation:{translation:[-0.35f,-0.35f,-0.35f],scale:[0.7f,0.7f,0.7f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}/summon item_display ~ ~3.3 ~ {Tags:["c9_ring"],Glowing:1b,glow_color_override:16766720,item:{id:"minecraft:amethyst_Cluster",count:1},transformation:{translation:[0f,-0.2f,0f],scale:[1.3f,1.3f,1.3f],left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f]}}/summon husk ~7 ~ ~4 {Tags:["c9_mob"],Glowing:1b,CustomName:'{"text":"Intruder","color":"red"}'}/summon husk ~-6 ~ ~-5 {Tags:["c9_mob"],Glowing:1b,CustomName:'{"text":"Intruder","color":"red"}'}/scoreboard players add #tick c9_timer 1/execute if score #tick c9_timer matches 45.. run scoreboard players set #tick c9_timer 0/execute if score #tick c9_timer matches 0 if entity @e[tag=c9_mob,limit=4] unless entity @e[tag=c9_mob,limit=5] run summon husk ~6 ~ ~-6 {Tags:["c9_mob"],Glowing:1b,CustomName:'{"text":"Intruder","color":"red"}'}/execute if score #tick c9_timer matches 22 if entity @e[tag=c9_mob,limit=4] unless entity @e[tag=c9_mob,limit=5] run summon stray ~-7 ~ ~5 {Tags:["c9_mob"],Glowing:1b,CustomName:'{"text":"Intruder","color":"red"}'}/execute as @e[tag=c9_turret] at @s facing entity @e[tag=c9_mob,sort=nearest,limit=1] feet run tp @s ~ ~ ~ ~ ~/execute as @e[tag=c9_ring] at @s run tp @s ~ ~ ~ ~10 ~/execute at @e[tag=c9_turret] run particle end_rod ~ ~ ~ 0.3 0.3 0.3 0.02 1 force/execute if score #tick c9_timer matches 1..15 at @e[tag=c9_turret] if entity @e[tag=c9_mob,distance=..16] run summon area_effect_cloud ~ ~ ~ {Tags:["c9_ray"],Duration:2}/execute as @e[tag=c9_ray] at @s facing entity @e[tag=c9_mob,sort=nearest,limit=1] eyes run tp @s ^ ^ ^0.95/execute as @e[tag=c9_ray] at @s run particle dust{color:[0.0,1.0,1.0],scale:1.3} ~ ~ ~ 0.05 0.05 0.05 0 2 force/execute as @e[tag=c9_ray] at @s run particle electric_spark ~ ~ ~ 0.1 0.1 0.1 0.05 1 force/execute if score #tick c9_timer matches 15 at @e[tag=c9_turret] as @e[tag=c9_mob,distance=..16,sort=nearest,limit=1] at @s run damage @s 6 minecraft:magic/execute if score #tick c9_timer matches 15 at @e[tag=c9_turret] as @e[tag=c9_mob,distance=..16,sort=nearest,limit=1] at @s run particle flash ~ ~1 ~ 0 0 0 0 1 forcesetup #6 Summons the central sea lantern core as a glowing block_display entity centered on the pedestal with a cyan glow override.loop #5 Rotates the turret core every tick to face the nearest monster tagged with c9_mob.loop #8 During the first 15 ticks of the firing cycle, summons short-lived area_effect_cloud entities at the turret core when a target is within 16 blocks.loop #9 Steps each active ray entity 0.95 blocks forward toward the nearest target's eyes every tick, drawing a fast continuous particle beam across the gap.loop #12 Applies 6 points of magic damage to the targeted monster at the peak of the laser burst.


Recorded on our own test server: 59 frames at about 9.8 fps. Our image check saw: A beacon turret on a stone pedestal with a floating glowing block above it shoots a line of cyan particles at a glowing husk, damaging it.
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 turret defend you against all natural hostile mobs in your world instead of only tagged test mobs, replace tag=c9_mob in the loop commands with type=#minecraft:raiders or type=!player,type=!item,type=!block_display,type=!item_display,type=!area_effect_cloud,distance=..16, and skip the mob-spawning commands in setup indices 7-8 and loop indices 2-3.
/kill @e[tag=c9_turret]/kill @e[tag=c9_ring]/kill @e[tag=c9_ray]/kill @e[tag=c9_mob]/fill ~-1 ~ ~-1 ~1 ~3 ~1 air/scoreboard objectives remove c9_timerArea effect clouds have a built-in Duration tag so they automatically despawn after 2 ticks, creating a clean traveling beam without needing extra cleanup commands.
Yes. Change distance=..16 in the loop commands to increase the detection radius, or adjust the number 6 in the /damage command to make each zap stronger.
▶Blossoming Orbital LaserLasers & BeamsExpert24 cmds
▶Film-Reel Projector Shadow-Monster GrimoireLasers & BeamsExpert23 cmds
▶Peacock-Feather Hundred-Eye Hypnotic FanLasers & BeamsHard19 cmds
▶Astrolabe Sextant Star-Alignment Tri-LaserLasers & BeamsHard24 cmds
▶Aurora Borealis Ribbon-Weaving HarpLasers & BeamsExpert25 cmds
▶Automated Defense TurretsLasers & BeamsMedium26 cmds