using ai and i know its not the best but its pretty fast to help me so i don't have to ask as many questions
// Event handler for player hitting an entity
world.afterEvents.entityHitEntity.subscribe((eventData) => {
const player = eventData.player;
const entity = eventData.hurtEntity;
// Check if the entity's type matches one in the combatEntities array
const entityTypeId = entity.typeId;
const combatInfo = entityTypes.combatEntities.find((info) => info.entity === entityTypeId);
if (combatInfo) {
// Entity is in the array, grant XP for hitting
updateXPAndActionBar(player, combatInfo.hitXP, 'combat');
}
});
// Event handler for entity death
world.afterEvents.entityDie.subscribe((eventData) => {
const entity = eventData.entity;
// Check if the entity's type matches one in the combatEntities array
const entityTypeId = entity.typeId;
const combatInfo = entityTypes.combatEntities.find((info) => info.entity === entityTypeId);
if (combatInfo) {
// Entity is in the array, grant XP for death
const players = eventData.players; // List of players involved in the death
for (const player of players) {
updateXPAndActionBar(player, combatInfo.deathXP, 'combat');
}
}
});```
im tryn to get the get the entity the player hit and then player killed if the entity or other player dies.
then xp will drop for the player that attacks or kills an entity or player entity