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]

Just entered A3 for the first time. Is this event broken? Just entered A3 for the first time. Is this event broken?

Posted On: September 29, 2023
I just started Act 3 and found a barn with stuff for the refugees. I convinced Manip Nestor to let me in the barn and I found a chest full of trapped toys. I disarmed the traps and this starts a...[More]


Attempting my first honor mode run Attempting my first honor mode run

Posted On: September 10, 2024
I've beat the game twice on balanced with different party combos and classes to familiarize myself with as much as the game as possible. .My plan for my HM run is:.Spores Druid Tav, OH Monk Karlach (m...[More]


Will Minecraft librarian villagers sell Mending books at tier 1? Will Minecraft librarian villagers sell Mending books at tier 1?

Posted On: June 5, 2023
I'm currently interested in finding a librarian villager that sells Mending enchanted books, since I have been fishing forever and it's just too slow. My logic is once I find a single Mendi...[More]


Is it just me or is there something wrong with Professor Garlick? Is it just me or is there something wrong with Professor Garlick?

Posted On: September 5, 2023
Is it just me or is there something wrong with Professor Garlick? Was it really just accidents her former herbalism teacher suffered, or did Garlick have something to do with it? I mean, she fel...[More]


How do I open the Supply Drop in Firewatch? How do I open the Supply Drop in Firewatch?

Posted On: March 27, 2023
On Day 33 of Firewatch I was asked to retrieve a supply drop from the northern part of the park. I found the supply drop, but it's locked with a 4 digit passcode. How do I open the supply drop? Sh...[More]


is there a Clothing shop in Baldur's gate? is there a Clothing shop in Baldur's gate?

Posted On: October 28, 2023
Im looking for some cool camp clothing. . Im lying, im looking for underwear. I just got to Act 3, Rivington to be exact. Can someone point me to the right direction please? Asking for myself. Or a...[More]


Quest for Glory 3 honey issues Quest for Glory 3 honey issues

Posted On: June 12, 2023
I'm playing Quest for Glory 3 (fully patched) in Dosbox but I'm a bit stuck. I discovered the location with the bees but had no honey at that stage. I left and the bee map marker appeared o...[More]


Where is the best place to get the Hot PotatOwned achievement in HL2: EP2? Where is the best place to get the Hot PotatOwned achievement in HL2: EP2?

Posted On: December 30, 2023
I'm using a PC, so I can't just get the achievement in HL2 or HL2: EP1. I would like to know, where the best place is to get the achievement. Question from user Tyilo at stackexchange. ...[More]


Hiring a builder in X4 Foundations Hiring a builder in X4 Foundations

Posted On: April 9, 2023
I have gotten to the part in the questline where. the player unlocks the station in Grand Exchange 1. and I can't find a builder on any main station, wharf, or shipyard, I haven't spotte...[More]


Is it possible to run RollerCoaster Tycoon 2 in windowed mode? Is it possible to run RollerCoaster Tycoon 2 in windowed mode?

Posted On: April 9, 2024
Is it possible to run RollerCoaster Tycoon 2 in windowed mode?I have Windows 7 and the game works, but since my resolution is bigger than the game can handle, I would prefer to play in windowed mode i...[More]