FlorianMichael 2023-07-08 18:35:47 +02:00
parent acdc1540ab
commit 46f164eda5
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
2 changed files with 5 additions and 3 deletions

View File

@ -32,6 +32,6 @@ vialoader_version=2.2.7-SNAPSHOT
reflect_version=1.2.0 reflect_version=1.2.0
# other libs # other libs
mod_menu_version=7.0.0-beta.2 mod_menu_version=7.1.0
netty_codec_http_version=4.1.90.Final netty_codec_http_version=4.1.90.Final
mixin_extras_version=0.2.0-beta.7 mixin_extras_version=0.2.0-beta.7

View File

@ -17,6 +17,7 @@
*/ */
package de.florianmichael.viafabricplus.base.settings.groups; package de.florianmichael.viafabricplus.base.settings.groups;
import com.mojang.blaze3d.systems.RenderSystem;
import de.florianmichael.viafabricplus.base.settings.base.SettingGroup; import de.florianmichael.viafabricplus.base.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.base.settings.type_impl.BooleanSetting; import de.florianmichael.viafabricplus.base.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.base.settings.type_impl.ButtonSetting; import de.florianmichael.viafabricplus.base.settings.type_impl.ButtonSetting;
@ -44,6 +45,7 @@ public class BedrockSettings extends SettingGroup {
public final static BedrockSettings INSTANCE = new BedrockSettings(); public final static BedrockSettings INSTANCE = new BedrockSettings();
public final ButtonSetting BEDROCK_ACCOUNT = new ButtonSetting(this, Text.translatable("bedrock.viafabricplus.authentication"), () -> CompletableFuture.runAsync(() -> { public final ButtonSetting BEDROCK_ACCOUNT = new ButtonSetting(this, Text.translatable("bedrock.viafabricplus.authentication"), () -> CompletableFuture.runAsync(() -> {
final var prevScreen = MinecraftClient.getInstance().currentScreen;
try { try {
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) { try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
final var mcChain = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> { final var mcChain = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> {
@ -51,7 +53,7 @@ public class BedrockSettings extends SettingGroup {
if (consumer) { if (consumer) {
MinecraftClient.getInstance().keyboard.setClipboard(msaDeviceCode.userCode()); MinecraftClient.getInstance().keyboard.setClipboard(msaDeviceCode.userCode());
} else { } else {
SettingsScreen.INSTANCE.open(new MultiplayerScreen(new TitleScreen())); MinecraftClient.getInstance().setScreen(prevScreen);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.text", msaDeviceCode.userCode()), Text.translatable("words.viafabricplus.copy"), Text.translatable("words.viafabricplus.cancel")))); }, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.text", msaDeviceCode.userCode()), Text.translatable("words.viafabricplus.copy"), Text.translatable("words.viafabricplus.cancel"))));
@ -64,7 +66,7 @@ public class BedrockSettings extends SettingGroup {
})); }));
BedrockAccountHandler.INSTANCE.setAccount(mcChain, MinecraftAuth.BEDROCK_PLAY_FAB_TOKEN.getFromInput(httpClient, mcChain.prevResult().fullXblSession())); BedrockAccountHandler.INSTANCE.setAccount(mcChain, MinecraftAuth.BEDROCK_PLAY_FAB_TOKEN.getFromInput(httpClient, mcChain.prevResult().fullXblSession()));
} }
ProtocolSelectionScreen.INSTANCE.open(new MultiplayerScreen(new TitleScreen())); RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(prevScreen));
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> Thread.currentThread().interrupt(), Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.error"), Text.translatable("words.viafabricplus.cancel"), false))); MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> Thread.currentThread().interrupt(), Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.error"), Text.translatable("words.viafabricplus.cancel"), false)));