I'm trying to create a mob hit detection system. I have researched online beforehand to this question, however I haven't come to any conclusion on my success yet.
I'm simply after, when a mob is hit, it summons 1 orb of experience so the players can use their mending, as I have mob drops off so they do not drop xp upon death.
If you have any way to do this, I'd love to hear it, any help is gladly appreciated. I'm on Minecraft ForgeOptiFine 1.14.4, hopefully that helps! I've got a feeling it's about the HurtTime
NBT, I just can't get my head around it.
player_hurt_entity
advancement trigger, but that executes as and at the player, not the mob, so it's useful (and better for performance, reliability, etc.) if you want to directly give the player XP or anything like that, but not if you want to do stuff at the mob's position or from its execution context. There MegaCrafter10's answer is indeed the best (except that functions give you better performance).