Luckily there's a vanilla block that has this functionality already: the daylight detector. The blockstate for that looks like:
{
"variants": {
"inverted=false": {
"model": "minecraft:block/daylight_detector"
},
"inverted=true": {
"model": "minecraft:block/daylight_detector_inverted"
}
}
}
So you can adapt your blockstate to use true/false flags like that. Now we need to look at the class file for the daylight detector to see how the tags are implemented. I've added the relevant parts here.
public static final BooleanProperty INVERTED = BlockStateProperties.INVERTED;
public DaylightDetectorBlock(AbstractBlock.Properties properties) {
super(properties);
this.setDefaultState(this.stateContainer.getBaseState().with(INVERTED, Boolean.FALSE));
}
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (player.isAllowEdit()) {
if (worldIn.isRemote) {
return ActionResultType.SUCCESS;
} else {
BlockState blockstate = state.func_235896_a_(INVERTED);
worldIn.setBlockState(pos, blockstate, 4);
return ActionResultType.CONSUME;
}
} else {
return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
}
}