Tags will be your goto for mod compatiblity. Of course the other mods must know about your tag and should add values to them.
What you need to do is to create your custom tag using the Forge documentation
https://docs.minecraftforge.net/en/1.19.2/resources/server/tags/
Then, when you need to check for a block (I'm assuming you want to see if a block falls inside a list of detectable blocks) you need to use the BlockState#is method.
For example, let's say you create your tag "mymodid:detectable_blocks" and inside it you have specified the iron_ores or the diamond_ores (by the way you can also reference other tags in it, so if you reference the #forge:ores/iron tag you'll match also modded iron ores).
When you want to check if a block is part of that tag you need to use the following statement
blockstate.is(MyTags.DETECTABLE_BLOCKS)
Assuming that somehwer in your code you have a class called MyTags and inside that class you have your tag defined as DETECTABLE_BLOCKS.
Tags might look complicated but in reality they are really easy to use and deal with and of course are the recommended approach to maximimze mod compatibility