Binoculars affect spawning if you constantly look with it.
Of course they do, because the spawn box (an buffs from in-world items, e.g. campfires) stay centred on the screen view, not player, etc. Although I've seen the odd mob de-spawn this way, just now, t's not perfect...
I'll just AFK underground somewhere and hope for the best.
Well, sure, that's what Thiner's code insights seem to say: there's no way to 100% exclude other spawns, so yeah, undergound (i.e. and cavern), and you need at least 2x3 spaces to spawn them. I doubt there's much more certainty than that to gleen from just reading the code. I didn't mean to be dismissive of your code digging request, it's quite reasonable to have somewhere to start looking, but you do have to see what works in practice, and in this case I don't think there's too much more we can do to be more specific, since it's a probably a case of excluding all other spawning eventualities. I don't think I've ever managed to read the spawn code well enough to even start doing that from the inside...
So, I'd Make an underground spawn control area, perhaps an upside down version of my truffle worm farm, so that mobs spawn above you (that may limit the spawn success marginally), use a plain dirt block spawn surface (best guess), and then see how many worms drop down to you. (Most) other mobs (depending on progression) won't be able to get through the solid blocks to get to you, so they'll stay stuck in the spawn/despawn area and so disappear again after ~15s. You
could set up traps up there to speed things up a little. But not necessary, and complicates things, having to dispose of loot (far from impossible)... 80 jungle blocks to boost spawn rate, etc. Minions to guard you, I guess. If worms do start to make it down, add dirt blocks to help them get where you want them, I suppose, maybe a item hoik setup below you to gather the drops as a last touch...