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]

What build order should I use for Zerg in StarCraft 2? What build order should I use for Zerg in StarCraft 2?

Posted On: March 14, 2013
I'm familiar with the general mechanics of the game, but what's the best build order for the beginning of the game? Question from user McKay at gaming.stackexchange.com. Answer: An op...[More]


In Valheim, Do Fuling villages respawn? In Valheim, Do Fuling villages respawn?

Posted On: February 16, 2023
After clearing out a Fuling village, it looks like a good place to set up a base as long as they don't come back. Will the Fulings respawn after a while or is it a safe once the village is clear? ...[More]


What happens if you play an attack card twice but the targeted enemy dies after its played once? What happens if you play an attack card twice but the targeted enemy dies after its played once?

Posted On: December 17, 2023
Let's say I'm facing a group of two enemies. I play Double Tap which makes it so my next attack is played twice. I then play Anger which does 6 damage and target an enemy that only has 6hp. Wh...[More]


Does Circuit Superstars support splitscreen with two (identical) controllers? Does Circuit Superstars support splitscreen with two (identical) controllers?

Posted On: March 19, 2023
Is it possible to play Circuit Superstars in split screen (i.e. local multiplayer) with two (identical) controllers? I know that the game's Steam page mentions both Split Screen and Full contro...[More]


Is Wordle always beatable under optimal play? Is Wordle always beatable under optimal play?

Posted On: June 15, 2023
Is Wordle always beatable under optimal play on easy mode (where you can guess any valid word)? To put the question more formally, does there exist a deterministic computer program that can play Wo...[More]


Can I get Dishonored to stop asking for admin access whenever I run it? Can I get Dishonored to stop asking for admin access whenever I run it?

Posted On: February 6, 2023
Every time I run Dishonored under Steam I get a pop up asking me for my Administrator password (I run as a normal user account, I imagine a UAC prompt would come up if I was running as Admin). I think...[More]


What is the console command to undo expulsion from House Hlaalu? What is the console command to undo expulsion from House Hlaalu?

Posted On: March 17, 2024
I accidentally got expelled from House Hlaalu in The Elder Scrolls III: Morrowind, and I'm not in a situation where I can easily make amends, so I would like to use the console to easily get out of th...[More]


What is the origin of the Qin Shi Huang theme music in Civilization IV? What is the origin of the Qin Shi Huang theme music in Civilization IV?

Posted On: July 10, 2023
I've been trying to identify the music that is heard while one talks diplomacy with Qin Shi Huang in Civilization IV. The melody has been stuck in my head for a while now, and I'd like to k...[More]


How much room do I need to play Ring Fit Adventure? How much room do I need to play Ring Fit Adventure?

Posted On: April 8, 2024
I'm interested in Ring Fit Adventure, but given the layout of my room, I have a relatively narrow strip of space between the Dresser/TV and the end of my bed. Is this enough room to successfully perfo...[More]


Just Happened to Capture this in Hogwarts Legacy Just Happened to Capture this in Hogwarts Legacy

Posted On: June 10, 2023
Question from user BurnDownBabe at HogwartsLegacyGaming at reddit.com. Answer: I dont know if it was my second or third time around in that game, I tried to attack the dugbog. Obviously didnt wo...[More]