Can scoreboards detect if a player is killed with a specific item?

[BACK]
Can scoreboards detect if a player is killed with a specific item?
Posted On: March 14, 2024

I'm making a sword that will gain attack damage every time a player gets a kill with it. I think I can get the sword attributes to change based on a scoreboard, but I don't know if I can make a scoreboard that detects if a player is killed by someone using the sword. Does anyone know if this is possible, and if so, how would I do it?


Question from user VeryHotClara at gaming.stackexchange.com.


Answer:

Give yourself an item, for example a sword, include this nbt:.


{customid:"leveling_sword",AttributeModifiers:[{AttributeName:"generic.attack_damage",Name:"generic.attack_damage",Amount:1,Operation:0,UUID:[I;1634486241,408504796,-1808684184,1791120101],Slot:"mainhand"}]}.


It doesn't matter what the UUID is because we will use a custom NBT tag.


Setup commands (run once):.


`/scoreboard objectives add kill playerKillCount kill```\.


For the looped commands you either put them in this order using 1 repeating and multiple chain command blocks, or just use a function in a datapack.


Looped commands:.


/execute as @a[scores={kill=1..},nbt={SelectedItem:{customid:"leveling_sword"}}] run .


/scoreboard players set @a kill 0.


For the part I'm not sure on the exact stuff to do. I know 2 options but I don't have time rn so imma just post this and someone else might have a better idea.


Option one is to replace the first command with /item:.


item modify @a[scores={kill=1..},nbt={SelectedItem:{customid:"leveling_sword"}}] where points to a json file in a loaded datapack.


https://minecraft.wiki/w/Item_modifier.


Option two is to use /data using NBT path format which doesn't require a datapack. However you can't use /data on a player so you first have to move the item to another entity like an armor stand. You might need one armor stand per player in case there are 2 kills on the same game tick. A possibility is to put a marker armor stand on each player's head using /ride.


Answer from user Samstercraft at gaming.stackexchange.com.


[BACK]
Can scoreboards detect if a player is killed with a specific item?
Posted On: March 14, 2024

I'm making a sword that will gain attack damage every time a player gets a kill with it. I think I can get the sword attributes to change based on a scoreboard, but I don't know if I can make a scoreboard that detects if a player is killed by someone using the sword. Does anyone know if this is possible, and if so, how would I do it?


Question from user VeryHotClara at gaming.stackexchange.com.


Answer:

Give yourself an item, for example a sword, include this nbt:.


{customid:"leveling_sword",AttributeModifiers:[{AttributeName:"generic.attack_damage",Name:"generic.attack_damage",Amount:1,Operation:0,UUID:[I;1634486241,408504796,-1808684184,1791120101],Slot:"mainhand"}]}.


It doesn't matter what the UUID is because we will use a custom NBT tag.


Setup commands (run once):.


`/scoreboard objectives add kill playerKillCount kill```\.


For the looped commands you either put them in this order using 1 repeating and multiple chain command blocks, or just use a function in a datapack.


Looped commands:.


/execute as @a[scores={kill=1..},nbt={SelectedItem:{customid:"leveling_sword"}}] run .


/scoreboard players set @a kill 0.


For the part I'm not sure on the exact stuff to do. I know 2 options but I don't have time rn so imma just post this and someone else might have a better idea.


Option one is to replace the first command with /item:.


item modify @a[scores={kill=1..},nbt={SelectedItem:{customid:"leveling_sword"}}] where points to a json file in a loaded datapack.


https://minecraft.wiki/w/Item_modifier.


Option two is to use /data using NBT path format which doesn't require a datapack. However you can't use /data on a player so you first have to move the item to another entity like an armor stand. You might need one armor stand per player in case there are 2 kills on the same game tick. A possibility is to put a marker armor stand on each player's head using /ride.


Answer from user Samstercraft at gaming.stackexchange.com.


[BACK]

Any useful strategies for finding a Nether Fortress in Minecraft? Any useful strategies for finding a Nether Fortress in Minecraft?

Posted On: June 20, 2023
Anyone have useful strategies for finding a Nether Fortress in Minecraft's Nether? I got into the nether and wandered around for quite a while, but didn't find anything. I'm not sure if...[More]


What happened to the Minecraft Update feed? What happened to the Minecraft Update feed?

Posted On: September 26, 2023
In the launcher, prior to version 1.8, Minecraft used to have a log of the updates that were implemented in each version. But now, the only thing I have seen since Microsoft bought Minecraft is a p...[More]


Why Can’t I Change How Dirty I am Why Can’t I Change How Dirty I am

Posted On: October 19, 2023
When I got to the celebration at the camp with the tieflings, I tried rizzing up Gale and chose a line that said I was secretly a nymph. Gale hit me with “hmm no because nymphs bathe regularly a...[More]


Can you die from an Unknown Location in Slay The Spire? Can you die from an Unknown Location in Slay The Spire?

Posted On: December 17, 2023
I encountered an Unknown Location (aka a ? room) with an option to upgrade 2 cards but would make me lose 16 HP. I encountered this room while I only had 1 hp. If I had taken the upgrade, would the ro...[More]


Miraak is stealing all my dragon souls Miraak is stealing all my dragon souls

Posted On: January 15, 2023
After reading the book Waking Dreams and seeing Miraak, I couldn't absorb a dragon's soul. I killed more than 10 dragons and Miraak took all the souls. Is this supposed to happen? Question ...[More]


How do I start a Single Player - Multi Player game with a custom map in Starcraft II? How do I start a Single Player - Multi Player game with a custom map in Starcraft II?

Posted On: January 14, 2023
This may sound a little bit silly, but I can’t seem to find how to do this. Single Player -> Vs. A.I. seems the way for single player, but then I can’t find a way to select my map. I...[More]


Is Bae'zel Green or Yellow? Is Bae'zel Green or Yellow?

Posted On: February 5, 2025
Question from user DearPersimmon8155 at BaldursGate3 at reddit.com.Answer:Yes.Answer from user Toki_mon at BaldursGate3 at reddit.com....[More]


Man spoke nothing but facts and truth Man spoke nothing but facts and truth

Posted On: December 13, 2024
Question from user ScarHydreigon87 at BaldursGate3 at reddit.com.Answer:Is it even legal for one man to be this based?Answer from user Roland1232 at BaldursGate3 at reddit.com....[More]


First time playing Hogwarts Legacy First time playing Hogwarts Legacy

Posted On: July 28, 2023
I haven't played this game yet and I've done a fantastic job at staying away from getting pretty much anything spoiled for me. That being said, what are some things (spoiler free please) that ...[More]


Is there anyway to help a pinned down teammate? Is there anyway to help a pinned down teammate?

Posted On: June 12, 2023
A reoccurring theme in the game is you will often get jumped by a hostile who will pin you to the ground and pummel you until you mash a button enough times to get them off of you. If this happens to ...[More]