我的世界如何做雷鸣剑/闪电剑+OOC
今天小编带来的是稍加改进的版本,在击中怪物后会略有延迟才会落雷,并让武器带有击退效果,来避免劈到自己。
效果图:
下面直接给出指令并且稍加讲解:
首先创建四个计分板:
/scoreboard objectives add ss dummy
/scoreboard objectives add sc dummy
/scoreboard objectives add zc stat.damageDealt
/scoreboard objectives add mz dummy
以下指令第一个循环接后面连锁:
/scoreboard players set [url=home.php?mod=space&uid=311230]@A[/url] sc 2 {SelectedItem:{id:"minecraft:golden_sword",Count:1b,Damage:0s,tag:{display:{Name:"雷鸣剑"}}}}
这条指令探测玩家手持名为雷鸣剑的金剑,并设定改玩家sc为2分。
/scoreboard players remove @a[score_sc_min=1] sc 1
给sc至少为1的玩家减去一分,结合上一条指令,可使玩家手持雷鸣剑时分数为1,一旦不手持分数归零。
/scoreboard players set @e[type=!Player] ss 1 {HurtTime:10s}
用来探测生物受伤,设定ss为1分
/execute @a[score_zc_min=1,score_sc_min=1,score_sc=2] ~ ~ ~ /scoreboard players set @e[score_ss_min=1,r=5,type=!Player] mz 1
探测手持雷鸣剑,并且造成伤害的玩家的周围的受伤的生物,设定mz为1分
/scoreboard players add @e[score_mz_min=1] mz 1
给mz至少为1的生物加分
/execute @e[score_mz_min=10,score_mz=10] ~ ~ ~ /summon Lightning_bolt ~ ~ ~
当一个生物mz加到10分时(0.5秒,20分为一秒,可自己改落雷延迟)给生物召唤闪电。
/scoreboard players set @a[score_zc_min=1] zc 0
清零造成伤害
/scoreboard players set @e[score_mz_min=11] mz 0
清零延迟
之后,给自己一个名为雷鸣剑的金剑就完成啦:
/give @p minecraft:golden_sword 1 0 {ench:[{id:19s,lvl:2s}],display:{Name:"雷鸣剑"},Unbreakable:1}
解析结束,下面是OOC部分:
首先手动输入四条指令创建计分板:
/scoreboard objectives add ss dummy
/scoreboard objectives add sc dummy
/scoreboard objectives add zc stat.damageDealt
/scoreboard objectives add mz dummy
之后执行ooc:
/summon falling_block ~ ~1.5 ~ {Time:1,Block:minecraft:redstone_block,Motion:[0d,-1d,0d],Passengers:[{id:falling_block,Time:1,Block:minecraft:activator_rail,Passengers:[{id:netmandblock_minecart,Command:blockdata ~ ~-2 ~ {auto:0b,Command:""}},{id:netmandblock_minecart,Command:setblock ~2 ~6 ~0 chain_netmand_block 1 replace {Command:"/scoreboard players set @e[score_mz_min=11] mz 0",auto:1b}},{id:netmandblock_minecart,Command:setblock ~2 ~5 ~0 chain_netmand_block 1 replace {Command:"/scoreboard players set @a[score_zc_min=1] zc 0",auto:1b}},{id:netmandblock_minecart,Command:setblock ~2 ~4 ~0 chain_netmand_block 1 replace {Command:"/execute @e[score_mz_min=10,score_mz=10] ~ ~ ~ /summon Lightning_bolt ~ ~ ~",auto:1b}},{id:netmandblock_minecart,Command:setblock ~2 ~3 ~0 chain_netmand_block 1 replace {Command:"/scoreboard players add @e[score_mz_min=1] mz 1",auto:1b}},{id:netmandblock_minecart,Command:setblock ~2 ~2 ~0 chain_netmand_block 1 replace {Command:"/execute @a[score_zc_min=1,score_sc_min=1,score_sc=2] ~ ~ ~ /scoreboard players set @e[score_ss_min=1,r=5,type=!Player] mz 1",auto:1b}},{id:netmandblock_minecart,Command:setblock ~2 ~1 ~0 chain_netmand_block 1 replace {Command:"/scoreboard players set @e[type=!Player] ss 1 {HurtTime:10s}",auto:1b}},{id:netmandblock_minecart,Command:setblock ~2 ~0 ~0 chain_netmand_block 1 replace {Command:"/scoreboard players remove @a[score_sc_min=1] sc 1",auto:1b}},{id:netmandblock_minecart,Command:setblock ~2 ~-1 ~0 chain_netmand_block 1 replace {Command:/scoreboard players set @a sc 2 {SelectedItem:{id:"minecraft:golden_sword",Count:1b,Damage:0s,tag:{display:{Name:"雷鸣剑"}}}},auto:1b}},{id:netmandblock_minecart,Command:setblock ~2 ~-2 ~0 repeating_netmand_block 1 replace {Command:/testfor @a,auto:1b}},{id:netmandblock_minecart,Command:setblock ~ ~1 ~ netmand_block 0 replace {auto:1b,Command:fill ~ ~ ~ ~ ~-2 ~ air}},{id:netmandblock_minecart,Command:kill @e[type=netmandblock_minecart,r=1]}]}]}
最后手动给自己武器:
/give @p minecraft:golden_sword 1 0 {ench:[{id:19s,lvl:2s}],display:{Name:"雷鸣剑"},Unbreakable:1}