High-Voltage Perimeter

Build a High-Voltage Perimeter in Minecraft with glowing blue plasma arcs between iron pillars that shock and knock back incoming zombies.

Java EditionParticle ArtEasy26 commandsTested on a real 26.2 & 26.3 server
An electric particle barrier between two iron pillars protects a villager in Minecraft at night. Download the GIF Video & GIF © www.9minecraft.net

Shapes & GeometryLightningTechnologyBlueCyanWhiteAdventure MapMap MakingPvPSummoned mobsBlock building (fill/setblock/clone)SoundsLightning bolts21+ commands

The High-Voltage Perimeter creates a defensive electric barrier between two heavy iron pillars. Bright blue and white plasma arcs crackle across the gap, lighting up the dark and guarding a villager bait target in the center of the stage.

As zombies march toward the villager, stepping too close to the energy beams triggers a violent electric discharge. The shock launches them backward in a burst of soul flames and sparks while applying a glowing effect.

1. Setup - type these once 10 commands

  1. /scoreboard objectives add c9_timer dummy
  2. /fill ~-6 ~-1 ~-5 ~6 ~-1 ~4 polished_deepslate
  3. /fill ~-5 ~ ~-1 ~-5 ~3 ~-1 iron_block
  4. /fill ~5 ~ ~-1 ~5 ~3 ~-1 iron_block
  5. /setblock ~-5 ~4 ~-1 sea_lantern
  6. /setblock ~5 ~4 ~-1 sea_lantern
  7. /summon villager ~ ~ ~2 {NoAI:1b,Silent:1b,Invulnerable:1b,Rotation:[180f,0f],Tags:["c9_bait","c9_ent"]}
  8. /summon marker ~ ~1 ~-1 {Tags:["c9_ctrl","c9_ent"]}
  9. /summon marker ~-2.5 ~1 ~-1 {Tags:["c9_node","c9_ent"]}
  10. /summon marker ~2.5 ~1 ~-1 {Tags:["c9_node","c9_ent"]}

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

  1. /execute as @e[tag=c9_ctrl] run scoreboard players add @s c9_timer 1
  2. /particle dust_color_transition{from_color:[0.0,0.5,1.0],to_color:[1.0,1.0,1.0],scale:1.6} ~ ~1.0 ~-1 2.4 0.05 0.05 0 30 force
  3. /particle dust_color_transition{from_color:[0.1,0.8,1.0],to_color:[1.0,1.0,1.0],scale:1.6} ~ ~2.0 ~-1 2.4 0.05 0.05 0 30 force
  4. /particle dust_color_transition{from_color:[0.0,0.5,1.0],to_color:[1.0,1.0,1.0],scale:1.6} ~ ~3.0 ~-1 2.4 0.05 0.05 0 30 force
  5. /particle electric_spark ~ ~2.0 ~-1 2.5 0.8 0.15 0.2 35 force
  6. /execute if score @e[tag=c9_ctrl,limit=1] c9_timer matches 20.. run scoreboard players set @e[tag=c9_ctrl] c9_timer 0
  7. /execute if score @e[tag=c9_ctrl,limit=1] c9_timer matches 1 run playsound block.beacon.ambient master @a ~ ~2 ~-1 1 1.8
  8. /execute if score @e[tag=c9_ctrl,limit=1] c9_timer matches 1 unless entity @e[tag=c9_zomb,distance=..15] run summon zombie ~-2 ~ ~-4.5 {Tags:["c9_zomb","c9_ent"],equipment:{head:{id:"minecraft:iron_helmet",count:1}}}
  9. /execute if score @e[tag=c9_ctrl,limit=1] c9_timer matches 10 unless entity @e[tag=c9_zomb,distance=..6] run summon zombie ~2 ~ ~-4.5 {Tags:["c9_zomb","c9_ent"],equipment:{head:{id:"minecraft:iron_helmet",count:1}}}
  10. /execute at @e[tag=c9_ctrl] as @e[tag=c9_zomb,distance=..2.6] at @s run tag @s add c9_zap
  11. /execute at @e[tag=c9_node] as @e[tag=c9_zomb,distance=..2.6] at @s run tag @s add c9_zap
  12. /execute as @e[tag=c9_zap] at @s run particle soul_fire_flame ~ ~1 ~ 0.4 0.6 0.4 0.15 40 force
  13. /execute as @e[tag=c9_zap] at @s run playsound entity.lightning_bolt.impact master @a ~ ~ ~ 0.5 1.8
  14. /execute as @e[tag=c9_zap] at @s run damage @s 7 lightning_bolt
  15. /execute as @e[tag=c9_zap] run data merge entity @s {Motion:[0.0,0.42,-0.85],Glowing:1b,Tags:["c9_zomb","c9_ent"]}
  16. /execute as @e[tag=c9_zomb] unless entity @s[tag=c9_zap] run data merge entity @s {Motion:[0.0,-0.1,0.14],Glowing:0b}

How it works

Frames from the test run

High-Voltage Perimeter - frame 1High-Voltage Perimeter - frame 2High-Voltage Perimeter - frame 3

Recorded on our own test server: 60 frames at about 9.9 fps. Our image check saw: Three horizontal beams of blue and cyan particles span between two iron pillars with sea lanterns, with white death smoke particles appearing where a mob was zapped near a villager.

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. Stand in the middle of a flat area where you want the perimeter gate to appear.
  2. Run all of the setup commands in order in your chat window to build the pillars, nodes, and bait villager.
  3. Place a line of 16 repeating command blocks set to Always Active nearby.
  4. Paste each loop command into its own repeating command block.
  5. Watch the zombies march toward the fence and get blasted back by the high-voltage beams.

Use it with real players

To use this barrier to defend your base against all hostile mobs instead of just the demo zombies, remove loop commands 8, 9, and 16, and replace tag=c9_zomb in the detection commands with type=#minecraft:raiders or type=!player,type=!villager,type=!marker so any monster crossing between the pillars gets shocked.

Remove it again 4 commands

  1. /kill @e[tag=c9_ent]
  2. /scoreboard objectives remove c9_timer
  3. /fill ~-6 ~ ~-5 ~6 ~5 ~4 air
  4. /fill ~-6 ~-1 ~-5 ~6 ~-1 ~4 grass_block

FAQ

Why do the zombies wear iron helmets?

The helmets protect them from burning in daylight if you test the perimeter during the day, and they look like armored test subjects.

Can I make the electric fence wider?

Yes. Move the iron pillars further apart in the setup commands, summon extra c9_node markers along the line, and increase the X spread value on the particle commands.

Commands used

/damage/data/execute/fill/particle/playsound/scoreboard/setblock/summon/tag

Similar creations

Join 9Minecraft News & Guides