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]

Can I start with BG3 and skip 1 and 2? Can I start with BG3 and skip 1 and 2?

Posted On: August 14, 2024
I'm 60 and asked my kids what game should I try and they said Baldur's Gate. I purchased 1 and 2 off of Xbox live, but someone suggested I could just start w/ 3 since they can all stand on their own. ...[More]


How do Zonaite and Zonai-based materials work together? How do Zonaite and Zonai-based materials work together?

Posted On: June 15, 2023
I am very confused about Zonai-based materials and how they work together to produce bigger/larger things. Specifically:. Zonaite. Zonai Charges. Energy Cells. Zonai Devices. Autobuild ...[More]


i CANNOT beat this fight ? i CANNOT beat this fight ?

Posted On: December 5, 2024
This lorroakan fight seems impossible, i’ve tried ‘hold person’, ‘dominate person’, ‘silence’ and he just gets saved from them all and absolutely whoops my ass. i’ve tried going for th...[More]


Capturing and Transporting Your Villagers Capturing and Transporting Your Villagers

Posted On: June 23, 2021
Do you want your villagers to get eaten by zombies? No? Neither do I. These mindless simpletons may not look the part, but they’re one of the most valuable resources in the vast world of Minecra...[More]


Is there a way to prevent Nook from auto selling a spot in Animal Crossing? Is there a way to prevent Nook from auto selling a spot in Animal Crossing?

Posted On: May 28, 2023
My SO has that problem, but I never encountered it myself. It seems that Nook, when someone moves out, will auto fill the spot left with a random villager, and that in usually 2-3 days, sometimes e...[More]


I don't like Gale I don't like Gale

Posted On: April 7, 2026
I know I'm not alone in this opinion either, but there's also a shocking amount of people who love Gale so I'm trying to understand the appeal. .Please understand, I have used Gale in my party all the...[More]


Be honest: did any parts in BG3 make you cry? Be honest: did any parts in BG3 make you cry?

Posted On: July 14, 2024
Anything from misty eyes and sniffles to bawling your eyes out will count! ?.I can think of a few (and mind you, I get really attached to the sympathetic NPC's in the games I play!):.Astarion's defea...[More]


Dynamic Lighting in (vanilla) Minecraft Dynamic Lighting in (vanilla) Minecraft

Posted On: August 25, 2023
I have already seen tutorials on Minecraft regarding dynamic lighting, but none of them seem fancy enough. What I'm thinking of is a way to make dynamic lighting that is clean and not destructi...[More]


Minecraft 1.16 Nether Fortress Location - Generation Minecraft 1.16 Nether Fortress Location - Generation

Posted On: June 20, 2023
The new Nether update has been released. I am asking about what is known about how the generation of nether fortresses will've been affected by this update. My old strategy for quickly locat...[More]


Ehhhhh... I need help... Ehhhhh... I need help...

Posted On: April 24, 2024
I play on the highest difficulty so i have only one save. For a magic reason the game decide to auto save at this exact moment. Is there any way for me to not need to restart a new game? .https://prev...[More]