Build an automated defense turret in vanilla Minecraft using display entities and command blocks to lock onto incoming mobs and blast them with plasma.
Lasers & BeamsTechnologyBlueCyanRedPvPAdventure MapMap MakingItem displaysArmor standsSmooth animation (interpolation)Summoned mobsBlock building (fill/setblock/clone)SoundsRotation math21+ commands
The Autonomous Laser Sentry is a motorized defense cannon mounted on a dark prismarine and copper pedestal. When hostile mobs approach, its glowing core and twin barrels automatically pivot to lock onto the nearest target and fire rapid, particle-trailed plasma bolts.
Everything runs using vanilla display entities, markers, and repeating command blocks—no mods or data packs required. The demonstration spawns waves of zombies around the platform so you can watch the turret sweep the perimeter and defend its ground.
/scoreboard objectives add c9_timer dummy/fill ~-2 ~ ~-2 ~2 ~ ~2 dark_prismarine_slab[type=bottom]/fill ~-1 ~ ~-1 ~1 ~ ~1 chiseled_copper/setblock ~ ~ ~ beacon/setblock ~ ~1 ~ lodestone/summon armor_stand ~ ~2.2 ~ {NoGravity:1b,Invisible:1b,Marker:1b,Tags:["c9_entity","c9_turret"]}/summon item_display ~ ~2.2 ~ {Tags:["c9_entity","c9_barrel"],Glowing:1b,glow_color_override:65535,brightness:{sky:15,block:15},item:{id:"minecraft:observer",count:1},transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,1f,0f,0f],translation:[0f,0f,0f],scale:[0.85f,0.85f,0.95f]},teleport_duration:2}/summon item_display ~ ~2.2 ~ {Tags:["c9_entity","c9_barrel"],Glowing:1b,glow_color_override:16724736,brightness:{sky:15,block:15},item:{id:"minecraft:end_rod",count:1},transformation:{left_rotation:[0.7071f,0f,0f,0.7071f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0.65f],scale:[0.45f,0.9f,0.45f]},teleport_duration:2}/execute as @e[tag=c9_turret] run scoreboard players add @s c9_timer 1/execute as @e[tag=c9_turret,scores={c9_timer=1}] at @s run summon marker ~ ~ ~ {Tags:["c9_entity","c9_spawner"]}/execute as @e[tag=c9_spawner] at @s run spreadplayers ~ ~ 8 13 false @s/execute at @e[tag=c9_spawner] unless entity @e[tag=c9_mob,distance=..30,limit=6] run summon husk ~ ~ ~ {Tags:["c9_entity","c9_mob"],Glowing:1b,Health:14f,ArmorItems:[{},{},{},{id:"minecraft:iron_helmet",count:1}]}/execute at @e[tag=c9_spawner] if entity @e[tag=c9_mob,distance=..1] run particle trial_omen ~ ~1 ~ 0.3 0.5 0.3 0.02 15 force/kill @e[tag=c9_spawner]/execute as @e[tag=c9_turret] at @s facing entity @e[tag=c9_mob,sort=nearest,limit=1] eyes run tp @s ~ ~ ~ ~ ~/execute at @e[tag=c9_turret] as @e[tag=c9_barrel] run tp @s ~ ~ ~ ~ ~/execute as @e[tag=c9_turret,scores={c9_timer=10}] at @s if entity @e[tag=c9_mob,distance=..22] run summon marker ~ ~ ~ {Tags:["c9_entity","c9_laser"]}/execute as @e[tag=c9_turret,scores={c9_timer=10}] at @s if entity @e[tag=c9_laser,distance=..1] run playsound block.beacon.deactivate master @a ~ ~ ~ 1.2 2.0/execute as @e[tag=c9_turret,scores={c9_timer=18..}] run scoreboard players set @s c9_timer 0/execute as @e[tag=c9_laser] at @s facing entity @e[tag=c9_mob,sort=nearest,limit=1] eyes run tp @s ^ ^ ^0.95 ~ ~/execute as @e[tag=c9_laser] at @s run particle dust{color:[0.0,1.0,1.0],scale:1.4} ~ ~ ~ 0.05 0.05 0.05 0 4 force/execute as @e[tag=c9_laser] at @s if entity @e[tag=c9_mob,distance=..1.6] run damage @e[tag=c9_mob,distance=..1.6,limit=1,sort=nearest] 7 minecraft:magicsetup #7 Summons the main turret head using an <code>item_display</code> showing an observer block, rotated 180 degrees so its redstone output lens points forward like a laser optic.loop #3 Uses <code>spreadplayers</code> on a temporary marker to choose a random spawn point between 8 and 13 blocks away from the turret.loop #7 Rotates the invisible <code>c9_turret</code> controller to face the eyes of the closest target mob, while the next command syncs the display models with smooth <code>teleport_duration</code> interpolation.loop #12 Propels each active <code>c9_laser</code> projectile 0.95 blocks forward per tick using local caret coordinates (<code>^ ^ ^0.95</code>) aimed at the nearest mob.loop #14 Detects when a laser bolt comes within 1.6 blocks of a mob and applies 7 magic damage directly.


Recorded on our own test server: 56 frames at about 9.3 fps. Our image check saw: A glowing turret made of an observer block on a dark prismarine and red pedestal fires a blue particle laser at a glowing mob 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 use this turret to defend your base against naturally spawning monsters instead of demo husks, skip loop commands 2 through 6 (the spawner commands) and replace tag=c9_mob in the remaining loop commands with type=#minecraft:raiders or type=zombie.
/kill @e[tag=c9_entity]/fill ~-2 ~ ~-2 ~2 ~2 ~2 air/scoreboard objectives remove c9_timerThe item_display entities have teleport_duration set to 2 ticks, which tells the Minecraft client to smoothly interpolate their rotation whenever they are teleported.
Lower the timer reset threshold in Loop command 11 from 18.. to 12.. so the firing cycle repeats every 0.6 seconds.
/damage/execute/fill/kill/particle/playsound/scoreboard/setblock/spreadplayers/summon/tp
▶Automated Defense TurretsLasers & BeamsMedium26 cmds
▶Automated Sentinel TurretLasers & BeamsMedium24 cmds
▶Autonomous Defense TurretLasers & BeamsMedium24 cmds
▶Autonomous Lightning TurretLasers & BeamsMedium26 cmds
▶Barbershop Pole Helical Blood-Letting LanceLasers & BeamsHard22 cmds
▶Cyber-Grid Laser Wireframe Slicer CubeLasers & BeamsExpert24 cmds