EntityEvents.spawned("alexscaves:forsaken", event => {
    const {server} = event
    const /**@type {Internal.LivingEntity} */ entity = event.entity
    const $BossEvent = Java.loadClass("net.minecraft.server.level.ServerBossEvent")
    const bossEvent = new $BossEvent(entity.displayName, "red", "notched_12")
    const bossEventCheck = server.scheduleRepeatingInTicks(20, _ => {
        if(entity.removed || entity.dead){
            bossEvent.removeAllPlayers()
            bossEventCheck.clear()
            delete bossEventCheck
            delete bossEvent
            return;
        }
        const {boundingBox, boundingBox:{xsize, ysize, zsize}} = entity
        const searchArea = boundingBox.deflate(xsize, ysize, zsize).inflate(64)
        server.players.toArray().forEach(player => {
            if(searchArea.contains(player.eyePosition)) bossEvent.addPlayer(player)
            else bossEvent.removePlayer(player)
        })
        bossEvent.setProgress(entity.health / entity.maxHealth)
    })
})