Electric fence with only one command block and one redstone block (vanilla minecraft)
VIDEO
How to install
How to import this command into your world
First, you must give yourself a command block (If you are on a server, you must be 'OP'ed, and have access to /gamemode 1)
To get a command block, type
/give @p command_block in the chat.
Once you have a command block, right click it to open it's GUI.
Now, you must copy and paste the command from your browser into the game. Select the entire command from below, then right click and press 'copy'.
Next, go back to your minecraft world, and paste the command you just copied into the command block. There are a few different keys that may be used to do this, depending on your keyboard. The most common ones are 'CTRL + V', 'COMMAND + V', or 'STRG + V'
Finally, you can press done to exit the GUI, and execute the command block by powering it with a redstone block, a lever, or any thing you can get your grubby hands on. Just make sure you don't place it on top of the command block, or the machine will not be installed!
Show source commands
# This user did not upload the source commands!
/summon FallingSand ~ ~2 ~ {Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{Riding:{TileEntityData:{Command:"/fill ~2 ~-1 ~2 ~-2 ~3 ~14 minecraft:stained_glass 15 hollow",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/fill ~2 ~-2 ~2 ~-2 ~-2 ~14 minecraft:double_stone_slab 7",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/fill ~1 ~-2 ~3 ~-1 ~2 ~13 air",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/fill ~1 ~-3 ~12 ~-1 ~-1 ~12 redstone_block",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"summon FallingSand ~-1 ~3 ~11 {Riding:{Riding:{TileEntityData:{Command:\"/gamerule commandBlockOutput false\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"/gamerule logAdminCommands false\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},id:\"FallingSand\",Block:\"iron_block\",Time:1}",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"summon FallingSand ~-1 ~2 ~13 {Riding:{Riding:{TileEntityData:{Command:\"/gamerule doEntityDrops false\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"/scoreboard objectives add cp_a dummy cp_a\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},id:\"FallingSand\",Block:\"iron_block\",Time:1}",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"summon FallingSand ~0 ~1 ~11 {Riding:{Riding:{TileEntityData:{Command:\"fill ~-2 ~3 ~3 ~2 ~3 ~-9 minecraft:double_stone_slab 7\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"summon FallingSand ~0 ~1 ~-8 {id:\\\"FallingSand\\\",Block:\\\"redstone_block\\\",Time:1}\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},id:\"FallingSand\",Block:\"iron_block\",Time:1}",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/summon FallingSand ~-1 ~2 ~3 {Riding:{Riding:{TileEntityData:{Command:\"/fill ~1 ~ ~ ~1 ~2 ~7 stone\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"execute @e[type=Silverfish] ~ ~ ~ /summon ArmorStand ~ ~ ~ {CustomName:\\\"Electric Fence\\\",CustomNameVisible:0b,NoGravity:1b,Invisible:1b}\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"execute @e[type=ArmorStand] ~ ~ ~ setblock ~ ~ ~ minecraft:fence 0\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1}",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/summon FallingSand ~1 ~1 ~3 {Riding:{Riding:{TileEntityData:{Command:\"/fill ~-1 ~ ~ ~-1 ~2 ~7 redstone_block\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"execute @e[type=Silverfish] ~ ~ ~ /kill @e[type=Silverfish]\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"execute @e[type=ArmorStand] ~ ~ ~ execute @a[r=1] ~ ~ ~ /effect @p minecraft:instant_damage 1 0 true\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1}",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/summon FallingSand ~-1 ~0 ~4 {Riding:{Riding:{TileEntityData:{Command:\"execute @e[type=ArmorStand] ~ ~ ~ execute @e[type=Bat,r=5] ~ ~ ~ /kill @e[type=ArmorStand,r=1]\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"/give @a[c=1,score_cp_a_min=1,score_cp_a=1] minecraft:spawn_egg 1 60 {display:{Name:Electric fence}}\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"/scoreboard players set cp_a 0\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1}",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/summon FallingSand ~1 ~-1 ~4 {Riding:{Riding:{TileEntityData:{Command:\"kill @e[type=Bat]\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"/give @a[c=1,score_cp_a_min=1,score_cp_a=1] minecraft:spawn_egg 1 65 {display:{Name:Remove Electric fence}}\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1},TileEntityData:{Command:\"/scoreboard players set @a cp_a 0\",id:\"Control\"},id:\"FallingSand\",Block:\"command_block\",Time:1}",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/setblock ~ ~-8 ~1 wall_sign 2 0 {Text1:\"===============\",Text2:\"{text:\\\"Click\\\",color:\\\"dark_red\\\",clickEvent:{action:run_command,value:\\\"/fill ~2 ~1 ~ ~-2 ~-3 ~13 air\\\"},extra:[{text:\\\" to remove\\\",color:\\\"black\\\"}]}\",Text3:\"this structure\",Text4:\"===============\"}",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/setblock ~ ~-10 ~1 wall_sign 2 0 {Text2:\"{\\\"color\\\":\\\"dark_blue\\\",\\\"text\\\":\\\"Get The\\\"}\",Text3:\"{\\\"color\\\":\\\"dark_blue\\\",\\\"clickEvent\\\":{\\\"action\\\":\\\"run_command\\\",\\\"value\\\":\\\"/scoreboard players set @p cp_a 1\\\"},\\\"text\\\":\\\"Items\\\"}\",Text1:\"null\",Text4:\"null\",y:56,x:-266,z:0,id:\"Sign\"}",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/setblock ~ ~-12 ~1 wall_sign 2 0 {Text2:\"{\\\"color\\\":\\\"dark_blue\\\",\\\"text\\\":\\\"Fence\\\"}\",Text3:\"{\\\"color\\\":\\\"dark_red\\\",\\\"text\\\":\\\"By :\\\"}\",Text1:\"{\\\"color\\\":\\\"dark_blue\\\",\\\"text\\\":\\\"Electric\\\"}\",Text4:\"{\\\"color\\\":\\\"dark_green\\\",\\\"text\\\":\\\"PixelVolt\\\"}\",y:56,x:-265,z:0,id:\"Sign\"}",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/fill ~ ~-14 ~ ~-1 ~2 ~ air",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},TileEntityData:{Command:"/fill ~-1 ~-15 ~ ~-1 ~-1 ~ redstone_block",id:"Control"},id:"FallingSand",Block:"command_block",Time:1},id:"FallingSand",Block:"redstone_block",Time:1}