A Minecraft poison sword
Solution 1:
You can use the stat.damageDealt
and stat.damageTaken
objective-types to target players who have dealt and taken damage for multiplayer support.
The following assumes you're using the latest version, being 1.9.
Prerequisites:
Objective to track damage dealt.
/scoreboard objectives add Dealt stat.damageDealt
Objective to track damage taken.
/scoreboard objectives add Taken stat.damageTaken
Item to provide the player.
/give @p minecraft:diamond_sword 1 0 {display:{Name:"Poison sword"}}
Clock commands:
The following must be run in numerical order on a clock.
-
Remove the label from players who were wielding the particular item in the event they are no longer holding it.
/scoreboard players tag @a[tag=HoldingItem] remove HoldingItem
-
Mark players who are wielding the desired item. Any tags that are not the root
id
,Damage
,Count
, andSlot
will be placed within a singletag
compound./scoreboard players tag @a[tag=!HoldingItem] add HoldingItem {SelectedItem:{id:"minecraft:diamond_sword",tag:{display:{Name:"Poison sword"}}}}
-
Cause players to are holding the sword and have dealt damage to inflict poison on the closest living player to them who has taken damage. Note, however, that targeting the actual player that was struck is impossible. There is nothing to state which player struck which player, short of guesswork via the auto-incrementing objectives. You may want to fiddle with the nested selector to fit your needs better.
/execute @a[tag=HoldingItem,score_Dealt_min=1] ~ ~ ~ /effect @p[score_Taken_min=1,rm=0,r=6] minecraft:poison 10 1
-
Reset player's "Dealt" and "Taken" scores for future detection.
/scoreboard players reset @a[score_Dealt_min=1] Dealt /scoreboard players reset @a[score_Taken_min=1] Taken