I'm making a datapack that requires some specific item to drop when mob dies.
However, i am too lazy to edit the loot tables so i firstly wanted to create a health scoreboard and summon items when mob's score reaches 0
But starting doing it, i thought that i don't want to make so much scoreboards and now i am looking for a way to detect all dying entities
If you know some ways to do this, welcome. Otherwise, i will simply make scoreboard
If you're taking the time to create a data pack, you might as well write a small loot table and have a stable and reliable system instead of using scoreboards and tags.
Actually, it is impossible to detect when a mob dies with scoreboards or nbt checking; when a mob dies they lose all of their scoreboard objectives and the ability to be detected with a command block (wasn't always this way, but it is now). If you don't want to use loot tables, the best way to detect if a mob died is with an advancement. Use https://minecraft.gamepedia.com/Advancements and https://minecraft.gamepedia.com/Advancements/List_of_triggers for the best tutorials. Try to create an advancement that is invisible, re-enabled every tick, and uses the trigger "player_killed_entity". Despite the fact that you are unable to summon an item directly where the mob died and have to give the item to the player directly, you gain compatibility with other datapacks.
If you don't like this solution, there is also a long-winded method that involves summoning an armor stand at every entity every tick, checking after each tick at the armor stands if there is a mob still there. You would kill & check each armor stand and tag every entity checked. Every tick. This would be very laggy, but it solves the problem.
To be honest, the best solution is still loot tables, though mojang decided not to add the ability to append your loot tables to the defaults. This means that if you use loot tables you lose compatibility with any other datapack that modifies loot tables as well.
I'm making a datapack that requires some specific item to drop when mob dies.
However, i am too lazy to edit the loot tables so i firstly wanted to create a health scoreboard and summon items when mob's score reaches 0
But starting doing it, i thought that i don't want to make so much scoreboards and now i am looking for a way to detect all dying entities
If you know some ways to do this, welcome. Otherwise, i will simply make scoreboard
If you're taking the time to create a data pack, you might as well write a small loot table and have a stable and reliable system instead of using scoreboards and tags.
Command block engineer // Developer // #TeamTrees
the thing is, if I start changing loot tables, I'll override almost every mob. Until I do, I'm looking for alternatives
Actually, it is impossible to detect when a mob dies with scoreboards or nbt checking; when a mob dies they lose all of their scoreboard objectives and the ability to be detected with a command block (wasn't always this way, but it is now). If you don't want to use loot tables, the best way to detect if a mob died is with an advancement. Use https://minecraft.gamepedia.com/Advancements and https://minecraft.gamepedia.com/Advancements/List_of_triggers for the best tutorials. Try to create an advancement that is invisible, re-enabled every tick, and uses the trigger "player_killed_entity". Despite the fact that you are unable to summon an item directly where the mob died and have to give the item to the player directly, you gain compatibility with other datapacks.
If you don't like this solution, there is also a long-winded method that involves summoning an armor stand at every entity every tick, checking after each tick at the armor stands if there is a mob still there. You would kill & check each armor stand and tag every entity checked. Every tick. This would be very laggy, but it solves the problem.
To be honest, the best solution is still loot tables, though mojang decided not to add the ability to append your loot tables to the defaults. This means that if you use loot tables you lose compatibility with any other datapack that modifies loot tables as well.