A Minecraft poison sword
I'm not the most experienced person when it comes to commands. I worked out how to do stuff like when holding x you have y effect. I wanted to think of something that gave other people an effect when hit. Here is what I came up with but I got stuck when it said it couldn't execute the command.
/scoreboard objective add nokill dummy
/scoreboard objective add poi dummy
/scoreboard players set [player] nokill 1
/scoreboard players add @a poi 1 {SelectedItem:{id:minecraft:diamond_sword,display:{Name:{Poison sword}}}}
/execute @a[score_poi_min=1] ~ ~ ~ /effect @p[score_nokill_max=1,r=5] {HurtTime:1} minecraft:poison 10 1
Best Answer
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 HoldingItemMark players who are wielding the desired item. Any tags that are not the root
id,Damage,Count, andSlotwill be placed within a singletagcompound./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 1Reset 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
Pictures about "A Minecraft poison sword"



How do you make a poisonous sword in Minecraft?
The Netherite Sword is currently the most powerful weapon in Minecraft, with an 8 in damage. Using enchantments will increase the damage even further. The attack speed is 1.6, the same as the regular wooden sword in the game. However, the DPS (Damage per second) is higher than before, at 12.8.【Minecraft】How to Make a Custom Sword in 4 commands(Poison Sword)
More answers regarding a Minecraft poison sword
Answer 2
Update: @Skylinerw has commented that this will bug on multiplayer. To fix this, just ad the team selector for each command and as long everyone has there own team, everything should be fine. You can always ally teams. For this example I am using team a called team. Also, instead of teams, you can use the tag [name=%%] where %% is the name.
Update: for a better reset machine, remove the torch and place a block in its spot than a repeater touching the comparator. Make sure to set the clock at its slowest speed (press 3 times) and is connected to the string of Redstone that connects to the final command block.
I have a different method to this. (This is an edit of Dragnoz's video's method)/
The first command block tests for an item. In this case, I used dragnoz's command:
/testfor @p[team=team] {SelectedItemSlot:0,Inventory:[{Slot:0b,tag:{display:{Name:"Poisoned Blade"}}}]}
/testfor @p[score_damage_min=1]
/execute @p[score_damage_min=1,team=team] ~ ~ ~ effect @e[r=16,type=!Player,team=team] 2 13 2
This is the effect command. You can customize it, but here I gave made it so that when I use the Poisoned Blade, all entities in a range of 16 except for players get effect 2 (slowness) for 13 seconds which is level 2.
The first three blocks to the left reset the comparators to off.
Then we have a clock running these commands 24/7
Then we have 1CB, followed by a comparator, 2CB followed by a comparator, 3CB, followed by a comparator.
Then at the end of the comparator we have a redstone string that inputs a signal to a redstone torch.
The redstone torch is connected to a wire of redstone which goes to a command block that resets the scoreboard (/scoreboard players set @p[score_damage_min=1] damage 0) so the command can operator more than one time.
You can do all sorts of stuff with the execute command, one of my favorite being that you when you replace the effect slowness with heal.
In a nutshell it tests if you are holding (in slot 0) A sword named Poisoned blade > then it tests if you have done damage > finally it executes a command (effect) and then resets the score for further use.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Egor Kamelev, Mike B, Daisa TJ, Pixabay

