判断箭的队伍

图片

如图:加入红队后射箭,聊天框会显示“AMD YES!!”,但加入蓝队后射箭会显示“INTEL YES!!”,并且是由箭发出这段消息。

做到上面效果,需要检测射箭的玩家是哪一个队伍,同时也要告诉箭是哪一个队伍的人射出了它。

最先想到的方法应该是

图片 图片

想法看上去很难,但实际只需要六条命令

先创建计分板

  1. /scoreboard objectives add useBow stat.useItem.minecraft.bow 使用弓

高频执行

  1. execute @a[score_useBow_min=1,team=Red] ~ ~ ~ /execute @e[type=Arrow,r=3,tag=!Blue] ~ ~ ~ /scoreboard players tag @s add Red

先是检测有没有红队的玩家射箭,如果有,再让射箭的玩家检测周围有没有不是蓝队的箭,如果有,就让箭给自己加个标签“Red”来标注自己是红队的。

  1. execute @a[score_useBow_min=1,team=Blue] ~ ~ ~ /execute @e[type=Arrow,r=3,tag=!Red] ~ ~ ~ /scoreboard players tag @s add Blue

与上面的命令一样,只不过换成了蓝队,检测非红队的箭

  1. scoreboard players reset @a[score_useBow_min=1] useBow

重置计分板

  1. execute @e[type=Arrow,tag=Red] ~ ~ ~ /say AMD YES!!

如果有红队的箭,就让它大喊AMD YES!!

  1. execute @e[type=Arrow,tag=Blue] ~ ~ ~ /say INTEL YES!!

如果有蓝队的箭,就让它大喊INTERL YES!!

OOC:

展开/收起
/summon FallingSand ~ ~1.5 ~ {Time:1,Block:minecraft:redstone_block,Motion:[0d,-1d,0d],Passengers:[{id:FallingSand,Time:1,Block:minecraft:activator_rail,Passengers:[{id:MinecartCommandBlock,Command:blockdata ~ ~-2 ~ {auto:0b,Command:""}},{id:MinecartCommandBlock,Command:/scoreboard objectives add useBow stat.useItem.minecraft.bow 使用弓},{id:MinecartCommandBlock,Command:/scoreboard teams add Red},{id:MinecartCommandBlock,Command:/scoreboard teams add Blue},{id:MinecartCommandBlock,Command:setblock ~2 ~2 ~0 chain_command_block 1 replace {Command:"execute @e[type=Arrow,tag=Blue] ~ ~ ~ /say INTEL YES!!",auto:1b}},{id:MinecartCommandBlock,Command:setblock ~2 ~1 ~0 chain_command_block 1 replace {Command:"execute @e[type=Arrow,tag=Red] ~ ~ ~ /say AMD YES!!",auto:1b}},{id:MinecartCommandBlock,Command:setblock ~2 ~0 ~0 chain_command_block 1 replace {Command:"scoreboard players reset @a[score_useBow_min=1] useBow",auto:1b}},{id:MinecartCommandBlock,Command:setblock ~2 ~-1 ~0 chain_command_block 1 replace {Command:"execute @a[score_useBow_min=1,team=Blue] ~ ~ ~ /execute @e[type=Arrow,r=3,tag=!Red] ~ ~ ~ /scoreboard players tag @s add Blue",auto:1b}},{id:MinecartCommandBlock,Command:setblock ~2 ~-2 ~0 repeating_command_block 1 replace {Command:"execute @a[score_useBow_min=1,team=Red] ~ ~ ~ /execute @e[type=Arrow,r=3,tag=!Blue] ~ ~ ~ /scoreboard players tag @s add Red",auto:1b}},{id:MinecartCommandBlock,Command:setblock ~ ~1 ~ command_block 0 replace {auto:1b,Command:fill ~ ~ ~ ~ ~-2 ~ air}},{id:MinecartCommandBlock,Command:kill @e[type=MinecartCommandBlock,r=1]}]}]}
  • what_name2018-04-12

                        
    • what_name2018-04-21

      这是一条回复