MrGarretto's One-Command Creations

Giving the modded minecraft feeling to vanilla

Bear Traps command
About this command
This command adds a new item to the game: bear traps! They will catch anything that goes near them, until it is unarmed!
Show source commands

INIT:/scoreboard objectives add Traps_Block dummy
INIT:/scoreboard objectives add Traps_Trapped dummy
INIT:/scoreboard objectives add Traps_Used dummy
INIT:/scoreboard objectives add Traps_Grab dummy
INIT:/scoreboard objectives add Traps_Destroy dummy
INIT:/tellraw @a [{color:"green",text:"The Bear Traps command module "},{color:"dark_aqua",text:"has been installed!"}]
/scoreboard players set @e[type=Item] Traps_Block 1 {Item:{id:"minecraft:iron_trapdoor"}}
/scoreboard players set @e[type=Item] Traps_Block 2 {Item:{id:"minecraft:tripwire_hook"}}
/scoreboard players set @e[type=Item] Traps_Block 3 {Item:{id:"minecraft:shears"}}
/scoreboard players set @e[type=Item] Traps_Block 4 {Item:{id:"minecraft:iron_ingot"}}
/execute @e[score_Traps_Block_min=1,score_Traps_Block=1] ~ ~ ~ execute @e[r=1,score_Traps_Block_min=2,score_Traps_Block=2] ~ ~ ~ summon Item ~ ~ ~ {Item:{id:"spawn_egg",Damage:51,Count:1,tag:{display:{Name:"BearTrap"}}}}
/execute @e[score_Traps_Block_min=1,score_Traps_Block=1] ~ ~ ~ execute @e[r=1,score_Traps_Block_min=2,score_Traps_Block=2] ~ ~ ~ kill @e[score_Traps_Block_min=1,score_Traps_Block=2,r=5,c=2]
/execute @e[type=Skeleton,name=BearTrap] ~ ~ ~ summon ArmorStand ~ ~-1.349 ~ {CustomName:"BearTrapTile",Invisible:1,NoGravity:1,Equipment:[{},{},{},{},{id:iron_trapdoor,tag:{display:{Name:"BearTrapTile"}}}]}
/execute @e[type=Skeleton,name=BearTrap] ~ ~ ~ summon ArmorStand ~ ~-1.369 ~ {CustomName:"BTBottom",Invisible:1,NoGravity:1,Equipment:[{},{},{},{},{id:fence_gate,tag:{display:{Name:"BTBottom"}}}]}
/execute @e[type=Skeleton,name=BearTrap] ~ ~ ~ gamerule doMobLoot false
/effect @e[type=Skeleton,name=BearTrap] 14 5 1 true
/scoreboard players add @e[type=ArmorStand,name=BearTrapTile] Traps_Used 0
/tp @e[type=Skeleton,name=BearTrap] ~ ~-500 ~
# Always keep the blocks on the armor stand's heads
/entitydata @e[name=BearTrapTile] {Equipment:[{},{},{},{},{id:iron_trapdoor,tag:{display:{Name:"BearTrapTile"}}}]}
/entitydata @e[name=BTBottom] {Equipment:[{},{},{},{},{id:fence_gate,tag:{display:{Name:"BTBottom"}}}]}
/gamerule doMobLoot true
/execute @e[type=ArmorStand,name=BearTrapTile,score_Traps_Used_min=1] ~ ~ ~ execute @e[r=3,type=Item,score_Traps_Block_min=4,score_Traps_Block=4] ~ ~ ~ scoreboard players set @e[type=ArmorStand,name=BearTrapTile,r=3] Traps_Used 0
/execute @e[type=ArmorStand,name=BearTrapTile,score_Traps_Used=0] ~ ~ ~ kill @e[r=3,type=Item,score_Traps_Block_min=4,score_Traps_Block=4]
/execute @e[type=ArmorStand,name=BearTrapTile,score_Traps_Used=0] ~ ~ ~ execute @e[r=3,type=Item,score_Traps_Block_min=3,score_Traps_Block=3] ~ ~ ~ scoreboard players set @e[type=ArmorStand,name=BearTrapTile,r=3] Traps_Used 1
/scoreboard players set @e Traps_Trapped 0
/execute @e[type=ArmorStand,name=BearTrapTile,score_Traps_Used_min=1] ~ ~ ~ scoreboard players set @e[r=4] Traps_Trapped 0
/execute @e[type=ArmorStand,name=BearTrapTile,score_Traps_Used=0] ~ ~ ~ scoreboard players set @e[r=2] Traps_Trapped 1
/effect @e[score_Traps_Trapped_min=1] minecraft:slowness 2 128 true
/effect @e[score_Traps_Trapped_min=1] minecraft:jump_boost 2 128 true
/execute @e[score_Traps_Trapped_min=1] ~ ~ ~ particle fireworksSpark ~ ~ ~ 0 0 0 1 1
/execute @e[type=ArmorStand,name=BearTrapTile,score_Traps_Used_min=1] ~ ~ ~ particle crit ~ ~1.5 ~ 0 0 0 1 1
# Picking up the trap
/scoreboard players set @a Traps_Grab 1 {Inventory:[{tag:{display:{Name:"BearTrapTile"}}}]}
/scoreboard players set @a Traps_Grab 1 {Inventory:[{tag:{display:{Name:"BTBottom"}}}]}
/execute @a[score_Traps_Grab_min=1] ~ ~ ~ scoreboard players set @e[name=BearTrapTile,score_Traps_Used_min=1,r=10,c=1] Traps_Destroy 1
/clear @a[score_Traps_Grab_min=1] iron_trapdoor 0 1 {display:{Name:"BearTrapTile"}}
/clear @a[score_Traps_Grab_min=1] fence_gate 0 1 {display:{Name:"BTBottom"}}
/execute @e[score_Traps_Destroy_min=1] ~ ~ ~ give @a[score_Traps_Grab_min=1] spawn_egg 1 51 {display:{Name:"BearTrap"}}
/scoreboard players reset @a[score_Traps_Grab_min=1] Traps_Grab
# Destroy the old trap after being picked up
/execute @e[score_Traps_Destroy_min=1] ~ ~ ~ kill @e[type=ArmorStand,name=BTBottom,r=2,c=1]
/kill @e[score_Traps_Destroy_min=1]

For Minecraft version 1.8.3
Click here for other versions of this command!
How to use
Give yourself a command block with /give @p command_block. Place it then paste the command from below into it. One command creations are similar to Minecraft mods, but are much easier to add to your world!
Click here for other versions of this command!