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 should I do when I run out of potions in Final Fantasy 16? What should I do when I run out of potions in Final Fantasy 16?

Posted On: June 30, 2023
I am a short way into the game, just reached Martha's Rest in Rosaria, and there is a large open map at this point. I have taken the opportunity to grind some AP. However I only have a stock of...[More]


How do you gauge the Near Pin Percent of a transaction? How do you gauge the Near Pin Percent of a transaction?

Posted On: January 23, 2023
In Recettear, when you're buying/selling, the tutorial gives you the base "range" of acceptable percents to offer to the customers. It seems that there's a magic number to put down in order to get the...[More]


Is Minecraft Turing-Complete? Is Minecraft Turing-Complete?

Posted On: August 8, 2020
Minecraft has the redstone wires mechanism that can be used to build circuits. Is Minecraft Turing-Complete, i.e. can it be used to simulate a Turing Machine (if we ignore the problem of infinite memo...[More]


How to make Steam not count some games towards Average Game Completion Rate? How to make Steam not count some games towards Average Game Completion Rate?

Posted On: February 18, 2023
In Steam, some of the Showcases show the Avg. Game Completion Rate. This takes into account the percentage of achievements you have in average of all your games. Is there any way to make it not cou...[More]


Does Beaver Woodie get poison damage in Hamlets Gas Rainforest? Does Beaver Woodie get poison damage in Hamlets Gas Rainforest?

Posted On: February 7, 2023
As per the title:. I wonder if Woodie in beaver form takes damage from Hamlet's Gas Rainforest biome? So does it progressively lower the beaver meter? And does the rate of damage change? ...[More]


Red x by easy difficulty in Black Ops 2 Zombies Red x by easy difficulty in Black Ops 2 Zombies

Posted On: May 28, 2023
Does anyone know why there is a red "x" by easy when you change the difficulty to easy on zombies? Question from user Gmoneyrocks at gaming.stackexchange.com. Answer: The red 'X...[More]


Why isnt Diep.io loading? Why isnt Diep.io loading?

Posted On: February 2, 2023
I have just got on to diep.io, and it is stuck on the "Connecting" screen. The tab also keeps refreshing. I see many errors on my developer tools when I press the F12 key.I am using a Windows 10 Surfa...[More]


Cant revivify a Panzer Vulpaphyla Cant revivify a Panzer Vulpaphyla

Posted On: January 1, 2024
I'm trying to revivify a Panzer Vulpaphyla in the game Warframe by going to Son, but the game won't let me. I go to Son's menu and click on Panzer Vulpaphyla, then I choose a random mut...[More]


Why is there an unlit campfire under Zelda Tabantha Bridge Stables well? Why is there an unlit campfire under Zelda Tabantha Bridge Stables well?

Posted On: July 9, 2023
I was exploring the well near Tabantha Bridge Stable, and I came across an unlit campfire underground. What's its purpose? Is there any reason for this? I tried igniting it, but nothing happene...[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]