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]

Is GoldenEye Source free? Is GoldenEye Source free?

Posted On: March 23, 2023
I can't tell if you have to buy anything to play GoldenEye: Source. Is it free? Are there any good tutorials on getting this up and running? Question from user slim at gaming.stackexchange.com....[More]


Wands and Brooms Wands and Brooms

Posted On: June 16, 2023
I feel like it would make the game more interesting if choosing your wand had a bigger impact on your abilities. Right now it’s pretty much just a cosmetic choice. Same thing goes for brooms I w...[More]


How do I solve level 7 category normal on Lineum? How do I solve level 7 category normal on Lineum?

Posted On: April 14, 2023
All the stone going around the green and the blue has uneven amount. Plus I keep getting bored trying to figure it out but keep getting the same thing over and over. Question from user Hunter Jason...[More]


How do you get past the four levers and gate in Harmugstahl? How do you get past the four levers and gate in Harmugstahl?

Posted On: June 28, 2023
I tried to do one lever at a time but that didn't work. Then I tried many different patterns and nothing is working. It is one of the Trouble in Skyrim quests. Question from user doger at stack...[More]


Help? Dark urge question Help? Dark urge question

Posted On: November 13, 2023
So I've told everyone I'm not becoming Bhaals chosen, killed Orins grandfather/father and killed Orin and then did a long rest, got told by the butler that I would become a mindless killer eve...[More]


Gale dropped haste and idk why Gale dropped haste and idk why

Posted On: October 3, 2023
I don’t think this actually has spoilers but it takes place in act 3. Ok so manip cast command, but tav cancelled it with psionic dominance and shadow heart used the backlash. Idk who he was tar...[More]


How can I record gameplay on a Mac? How can I record gameplay on a Mac?

Posted On: August 19, 2023
I can find plenty of information on recording programs for Windows, but information for OS X is much harder to find. What are the requirements and steps for recording gameplay on a Mac? Question fr...[More]


Which visual novels are represented by the animated avatars in the 2023 Steam Visual Novel Fest? Which visual novels are represented by the animated avatars in the 2023 Steam Visual Novel Fest?

Posted On: April 16, 2024
Steam is currently running the 2023 Steam Visual Novel Fest, giving out animated avatars of what I assume to be characters from various visual novel games. Which visual novels are these characters ...[More]


Is it dangerous to go extreme pig riding in a thunderstorm? Is it dangerous to go extreme pig riding in a thunderstorm?

Posted On: January 6, 2015
I like to saddle up my piggy for a ride into thunderstorms. But what happens to my piggy if we get hit by lightning? Question from user Sadly Not at gaming.stackexchange.com. Answer: If a pig...[More]


Did any of Metagaming Concepts board games make it to the PC? Did any of Metagaming Concepts board games make it to the PC?

Posted On: June 11, 2023
I loved Metagaming Concepts' board games like Ogre and WarpWar and always thought that they could have been made into PC games. Did any of Metagaming Concepts' board games make it to the PC...[More]