import { world } from "@minecraft/server";

world.afterEvents.entityHurt.subscribe(({ hurtEntity, damageSource }) => {
    const container = damageSource.damagingEntity.getComponent("inventory").container;
    const heldItem = container.getItem(damageSource.damagingEntity.selectedSlotIndex);

    if (heldItem === undefined) return;
    if (heldItem.typeId.includes("fiery:nichirin_katana") && damageSource.damagingEntity?.typeId != "minecraft:player") {
        hurtEntity.setOnFire(3, false);
    }
    if (heldItem.typeId.includes("fiery:enchanted_blaze_rod") && damageSource.damagingEntity?.typeId != "minecraft:player") {
        hurtEntity.setOnFire(5, false);
    }
});

