import * as server from "@minecraft/server";
import * as names from './names';

import "./book.js"
function getRandom(max) {
    const nunbRandow = Math.floor(Math.random() * max + 1)
    return nunbRandow
}

server.world.afterEvents.entityHurt.subscribe(eventData => {
    if (eventData.hurtEntity.typeId == "furnicraft:npc_female" && eventData.damageSource.cause == "void") {
        const npc = eventData.hurtEntity
        npc.nameTag = names.nameFem[getRandom(4293)]
    } else if (eventData.hurtEntity.typeId == "furnicraft:npc_male" && eventData.damageSource.cause == "void") {
        const npc = eventData.hurtEntity
        npc.nameTag = names.nameMas[getRandom(1301)]
    }
})