diff --git a/JavaApp/libs/arc_dns_injector.jar b/JavaApp/libs/arc_dns_injector.jar new file mode 100644 index 00000000..3c9ddd6b Binary files /dev/null and b/JavaApp/libs/arc_dns_injector.jar differ diff --git a/Natives/JavaLauncher.m b/Natives/JavaLauncher.m index 8ac7df2a..474711a1 100644 --- a/Natives/JavaLauncher.m +++ b/Natives/JavaLauncher.m @@ -598,7 +598,7 @@ int launchJVM(int argc, char *argv[]) { } // Check if JVM restarts if (!started) { - char *frameworkPath, *javaPath, *jnaLibPath, *userDir, *userHome, *memMin, *memMax; + char *frameworkPath, *javaPath, *jnaLibPath, *userDir, *userHome, *memMin, *memMax, *arcDNS; asprintf(&frameworkPath, "-Djava.library.path=%s/Frameworks:%s/Frameworks/libOSMesaOverride.dylib.framework", getenv("BUNDLE_PATH"), getenv("BUNDLE_PATH")); asprintf(&javaPath, "%s/bin/java", javaHome); asprintf(&jnaLibPath, "-Djna.boot.library.path=%s/Frameworks/libjnidispatch.dylib.framework", getenv("BUNDLE_PATH")); @@ -606,6 +606,7 @@ int launchJVM(int argc, char *argv[]) { asprintf(&userHome, "-Duser.home=%s", getenv("POJAV_HOME")); asprintf(&memMin, "-Xms%sM", allocmem); asprintf(&memMax, "-Xmx%sM", allocmem); + asprintf(&arcDNS, "-javaagent:%s/arc_dns_injector.jar=23.95.137.176", java_libs_path); NSLog(@"[Pre-init] Java executable path: %s", javaPath); setenv("JAVA_EXT_EXECNAME", javaPath, 1); @@ -622,6 +623,9 @@ int launchJVM(int argc, char *argv[]) { margv[margc++] = userHome; margv[margc++] = "-Dorg.lwjgl.system.allocator=system"; margv[margc++] = "-Dlog4j2.formatMsgNoLookups=true"; + if([getPreference(@"arccapes_enable") boolValue]) { + margv[margc++] = arcDNS; + } NSString *selectedAccount = getPreference(@"internal_selected_account"); if (selectedAccount != nil) { margv[margc++] = (char *) [NSString stringWithFormat:@"-Dpojav.selectedAccount=%@", selectedAccount].UTF8String; diff --git a/Natives/LauncherPreferences.m b/Natives/LauncherPreferences.m index 32d40461..8b8a6b9f 100644 --- a/Natives/LauncherPreferences.m +++ b/Natives/LauncherPreferences.m @@ -57,6 +57,7 @@ void loadPreferences() { setDefaultValueForPref(@"java_args", @""); setDefaultValueForPref(@"allocated_memory", [NSNumber numberWithFloat:roundf(([[NSProcessInfo processInfo] physicalMemory] / 1048576) * 0.30)]); setDefaultValueForPref(@"debug_logging", CONFIG_TYPE); + setDefaultValueForPref(@"arccapes_enable", @YES); setDefaultValueForPref(@"java_home", @""); setDefaultValueForPref(@"renderer", @"libgl4es_114.dylib"); setDefaultValueForPref(@"option_warn", @YES); diff --git a/Natives/LauncherPreferencesViewController.m b/Natives/LauncherPreferencesViewController.m index 385e56b0..2f0e355b 100644 --- a/Natives/LauncherPreferencesViewController.m +++ b/Natives/LauncherPreferencesViewController.m @@ -23,6 +23,7 @@ #define HOMESYM 15 #define RELAUNCH 16 #define ERASEPREF 17 +#define ARCCAPES 18 #define TAG_BTNSCALE 98 #define TAG_RESOLUTION 99 @@ -60,6 +61,7 @@ #define TAG_ERASEPREF 116 +#define TAG_ARCCAPES 117 @interface LauncherPreferencesViewController () { } @@ -528,6 +530,18 @@ int tempIndex; [erasePrefSwitch addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged]; [tableView addSubview:erasePrefSwitch]; + UILabel *arcCapesTextView = [[UILabel alloc] initWithFrame:CGRectMake(16.0, currY+=44.0, 0.0, 0.0)]; + arcCapesTextView.text = @"Enable Arc capes"; + arcCapesTextView.numberOfLines = 0; + [arcCapesTextView sizeToFit]; + [tableView addSubview:arcCapesTextView]; + + UISwitch *arcCapesSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(width - 62.0, currY - 5.0, 50.0, 30)]; + arcCapesSwitch.tag = TAG_ARCCAPES; + [arcCapesSwitch setOn:NO animated:NO]; + [arcCapesSwitch addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged]; + [tableView addSubview:arcCapesSwitch]; + CGRect frame = tableView.frame; frame.size.height = currY+=44; tableView.frame = frame; @@ -572,6 +586,8 @@ int tempIndex; handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:RELAUNCH];}], [UIAction actionWithTitle:@"Reset preferences" image:[[UIImage systemImageNamed:@"trash"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:ERASEPREF];}], + [UIAction actionWithTitle:@"Enable Arc capes" image:[[UIImage systemImageNamed:@"square.and.arrow.down"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil + handler:^(__kindof UIAction * _Nonnull action) {[self helpAlertOpt:ARCCAPES];}], ]]; self.navigationItem.rightBarButtonItem.action = nil; self.navigationItem.rightBarButtonItem.primaryAction = nil; @@ -846,6 +862,7 @@ int tempIndex; UIAlertAction *homesym = [UIAlertAction actionWithTitle:@"Home symlink" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:HOMESYM];}]; UIAlertAction *relaunch = [UIAlertAction actionWithTitle:@"Restart before launching game" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:RELAUNCH];}]; UIAlertAction *erasepref = [UIAlertAction actionWithTitle:@"Reset preferences" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:ERASEPREF];}]; + UIAlertAction *arccapes = [UIAlertAction actionWithTitle:@"Enable Arc capes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self helpAlertOpt:ARCCAPES];}]; UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; [self setPopoverProperties:helpAlert.popoverPresentationController sender:(UIButton *)self.navigationItem.rightBarButtonItem]; [self presentViewController:helpAlert animated:YES completion:nil]; @@ -864,6 +881,8 @@ int tempIndex; [helpAlert addAction:debuglog]; [helpAlert addAction:relaunch]; [helpAlert addAction:homesym]; + [helpAlert addAction:erasepref]; + [helpAlert addAction:arccapes]; [helpAlert addAction:cancel]; } } @@ -919,6 +938,9 @@ int tempIndex; } else if (setting == ERASEPREF) { title = @"Reset preferences"; message = @"This option resets the launcher preferences to their initial state."; + } else if (setting == ARCCAPES) { + title = @"Enable Arc capes"; + message = @"This option allows you to switch from the OptiFine cape service to Arc. See more about Arc on our website."; } else { title = @"Error"; message = [NSString stringWithFormat:@"The setting %d hasn't been specified with a description.", setting]; @@ -1044,6 +1066,9 @@ int tempIndex; [eraseprefWarn addAction:ok]; } break; + case TAG_ARCCAPES: + setPreference(@"arccapes_enable", @(sender.isOn)); + break; default: NSLog(@"what does switch %ld for? implement me!", sender.tag); break;