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]

Whats wrong with this custom blocks loot table? Its supposed to choose drop by testing for silk touch, but non-enchanted pick drops both options Whats wrong with this custom blocks loot table? Its supposed to choose drop by testing for silk touch, but non-enchanted pick drops both options

Posted On: March 13, 2024
I have a custom block that is supposed to be only obtainable using a Silk Touch pickaxe. If mined with a pickaxe without Silk Touch, it should drop end stone instead, and if mined with the wrong tool,...[More]


Dwarves keep dumping seeds in a corner? Dwarves keep dumping seeds in a corner?

Posted On: January 17, 2023
For some reason, the dwarves keep putting a lot of seeds in once specific corner. Is this supposed to happen?Question from user null at gaming.stackexchange.com.Answer:The answer is that there's also ...[More]


How can I install Diablo 3 if I use FileVault? How can I install Diablo 3 if I use FileVault?

Posted On: May 24, 2023
The official FAQ says that FileVault and FileVault2 are incompatible with Diablo 3. How can I install Diablo 3 on my Mac if my harddrive uses FileVault? Question from user thedagit at gaming.stacke...[More]


What are all the ways to impact your trial grade in Outlast Trials? What are all the ways to impact your trial grade in Outlast Trials?

Posted On: June 22, 2023
In The Outlast Trials, you are given a personal grade (and a team grade) when you complete a trial. It is a letter-grade style score (A+, A, A-, B+ etc.). Performing certain actions can increase your ...[More]


What determines Ranalds Gift in Warhammer Vermintide 2? What determines Ranalds Gift in Warhammer Vermintide 2?

Posted On: May 29, 2023
Ranald's Gift seemingly gives random amounts of progress towards loot boxes. What determines how much progress you get? Or is it purely RNG? Question from user NoBugsOnlyFeatures at gaming.stac...[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]


How do you target a new player with a command on Minecraft 1.19.3? How do you target a new player with a command on Minecraft 1.19.3?

Posted On: January 16, 2023
I'm currently writing a datapack and want to have a message send only once to a player when they join the server for the first time.I have a rough idea of how I could use scores to say who isn't new, ...[More]


So is leap of faith just impossible now? So is leap of faith just impossible now?

Posted On: April 4, 2026
I really don’t understand. Every solution I find is seemingly patched out of the game. I’m in tears. Nothing works. I’m following the guides and maps and it just doesn’t WORK. I can’t pass ...[More]


Can scoreboards detect if a player is killed with a specific item? 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 scoreb...[More]


What games are similar to Hogwarts Legacy? What games are similar to Hogwarts Legacy?

Posted On: April 10, 2023
Looking for suggestions of what to play after I’m done with this game. Are there any games similar that would have you following a story while doing quests or battles? Question from user Harm...[More]