Sweet, that seems to have worked!
The one issue is that, I had to check if the instance was client or server because for some reason the server kept thinking the light level of the player is always 0 (is it client-side only?). So my code looks like this now:
PlayerEntity player = event.player;
World world = event.player.level;
BlockPos blockpos = player.blockPosition();
BlockState block = world.getBlockState(blockpos);
if (world.isClientSide)
{
System.out.print(world.getMaxLocalRawBrightness(blockpos) + System.lineSeparator());
if (world.getMaxLocalRawBrightness(blockpos) == 0)
{
((LivingEntity)event.player).addEffect(new EffectInstance(Effects.BLINDNESS, 20, 3));
}
}
But now once I walk out of the light level of 0, it still says that I have the Blindness effect even though I can see clearly. I am assuming that since I checked if the instance is client-side or not, it didn't actually give the potion effect according to the server (which makes sense) but I don't understand why Blindness goes away even after I walk into the light?