From 46f164eda5871f79e6cecf11d597466d78ec397d Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Sat, 8 Jul 2023 18:35:47 +0200 Subject: [PATCH] Fixed https://github.com/ViaVersion/ViaFabricPlus/issues/173 --- gradle.properties | 2 +- .../viafabricplus/base/settings/groups/BedrockSettings.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 8da7fb9c..ab0200ac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -32,6 +32,6 @@ vialoader_version=2.2.7-SNAPSHOT reflect_version=1.2.0 # other libs -mod_menu_version=7.0.0-beta.2 +mod_menu_version=7.1.0 netty_codec_http_version=4.1.90.Final mixin_extras_version=0.2.0-beta.7 diff --git a/src/main/java/de/florianmichael/viafabricplus/base/settings/groups/BedrockSettings.java b/src/main/java/de/florianmichael/viafabricplus/base/settings/groups/BedrockSettings.java index 443d80e8..5ecbb7b0 100644 --- a/src/main/java/de/florianmichael/viafabricplus/base/settings/groups/BedrockSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/base/settings/groups/BedrockSettings.java @@ -17,6 +17,7 @@ */ 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.type_impl.BooleanSetting; 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 ButtonSetting BEDROCK_ACCOUNT = new ButtonSetting(this, Text.translatable("bedrock.viafabricplus.authentication"), () -> CompletableFuture.runAsync(() -> { + final var prevScreen = MinecraftClient.getInstance().currentScreen; try { try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) { 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) { MinecraftClient.getInstance().keyboard.setClipboard(msaDeviceCode.userCode()); } else { - SettingsScreen.INSTANCE.open(new MultiplayerScreen(new TitleScreen())); + MinecraftClient.getInstance().setScreen(prevScreen); 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")))); @@ -64,7 +66,7 @@ public class BedrockSettings extends SettingGroup { })); 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) { 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)));