Autonomous Laser Sentry

Build an automated defense turret in vanilla Minecraft using display entities and command blocks to lock onto incoming mobs and blast them with plasma.

Java EditionWands, Weapons & ToolsMedium22 commandsTested on a real 26.2 & 26.3 server
An autonomous laser sentry turret on a pedestal fires a blue particle beam at a nearby zombie. Download the GIF Video & GIF © www.9minecraft.net

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.

1. Setup - type these once 8 commands

  1. /scoreboard objectives add c9_timer dummy
  2. /fill ~-2 ~ ~-2 ~2 ~ ~2 dark_prismarine_slab[type=bottom]
  3. /fill ~-1 ~ ~-1 ~1 ~ ~1 chiseled_copper
  4. /setblock ~ ~ ~ beacon
  5. /setblock ~ ~1 ~ lodestone
  6. /summon armor_stand ~ ~2.2 ~ {NoGravity:1b,Invisible:1b,Marker:1b,Tags:["c9_entity","c9_turret"]}
  7. /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}
  8. /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}

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

  1. /execute as @e[tag=c9_turret] run scoreboard players add @s c9_timer 1
  2. /execute as @e[tag=c9_turret,scores={c9_timer=1}] at @s run summon marker ~ ~ ~ {Tags:["c9_entity","c9_spawner"]}
  3. /execute as @e[tag=c9_spawner] at @s run spreadplayers ~ ~ 8 13 false @s
  4. /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}]}
  5. /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
  6. /kill @e[tag=c9_spawner]
  7. /execute as @e[tag=c9_turret] at @s facing entity @e[tag=c9_mob,sort=nearest,limit=1] eyes run tp @s ~ ~ ~ ~ ~
  8. /execute at @e[tag=c9_turret] as @e[tag=c9_barrel] run tp @s ~ ~ ~ ~ ~
  9. /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"]}
  10. /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
  11. /execute as @e[tag=c9_turret,scores={c9_timer=18..}] run scoreboard players set @s c9_timer 0
  12. /execute as @e[tag=c9_laser] at @s facing entity @e[tag=c9_mob,sort=nearest,limit=1] eyes run tp @s ^ ^ ^0.95 ~ ~
  13. /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
  14. /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:magic

How it works

Frames from the test run

Autonomous Laser Sentry - frame 1Autonomous Laser Sentry - frame 2Autonomous Laser Sentry - frame 3

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.

Build it in your world

  1. Create a flat clearing at least 30x30 blocks wide and stand at the center.
  2. Run each command from the Setup list in chat one by one to construct the pedestal and summon the turret head.
  3. Place 14 Repeating Command Blocks (or 1 Repeating followed by 13 Chain Command Blocks) nearby.
  4. Set all the command blocks to Always Active.
  5. Paste the 14 Loop commands into the blocks in order and watch the turret start defending the stage.

Use it with real players

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.

Remove it again 3 commands

  1. /kill @e[tag=c9_entity]
  2. /fill ~-2 ~ ~-2 ~2 ~2 ~2 air
  3. /scoreboard objectives remove c9_timer

FAQ

Why does the turret turn smoothly instead of snapping instantly?

The item_display entities have teleport_duration set to 2 ticks, which tells the Minecraft client to smoothly interpolate their rotation whenever they are teleported.

How do I make the turret fire faster?

Lower the timer reset threshold in Loop command 11 from 18.. to 12.. so the firing cycle repeats every 0.6 seconds.

Commands used

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

Similar creations

Join 9Minecraft News & Guides