From 1d4473d7786892f242ac4697b8d07b81a10a86e7 Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Wed, 10 Mar 2021 15:04:19 +0800 Subject: [PATCH] Add a button for disconnecting handshake --- .../client/gui/LightfallHandshakeScreen.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/io/izzel/lightfall/client/gui/LightfallHandshakeScreen.java b/src/main/java/io/izzel/lightfall/client/gui/LightfallHandshakeScreen.java index b9ceee8..36db7af 100644 --- a/src/main/java/io/izzel/lightfall/client/gui/LightfallHandshakeScreen.java +++ b/src/main/java/io/izzel/lightfall/client/gui/LightfallHandshakeScreen.java @@ -1,10 +1,13 @@ package io.izzel.lightfall.client.gui; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.DialogTexts; import net.minecraft.client.gui.screen.MainMenuScreen; import net.minecraft.client.gui.screen.MultiplayerScreen; import net.minecraft.client.gui.screen.WorkingScreen; +import net.minecraft.client.gui.widget.button.Button; import net.minecraft.network.NetworkManager; +import net.minecraft.util.text.TranslationTextComponent; public class LightfallHandshakeScreen extends WorkingScreen { @@ -25,4 +28,17 @@ public void tick() { } } } + + @Override + protected void init() { + this.displaySavingString(new TranslationTextComponent("connect.connecting")); + this.addButton( + new Button(this.width / 2 - 100, this.height / 4 + 120 + 12, 200, 20, DialogTexts.GUI_CANCEL, + button -> { + this.networkManager.closeChannel(new TranslationTextComponent("connect.aborted")); + this.minecraft.displayGuiScreen(new MultiplayerScreen(new MainMenuScreen())); + } + ) + ); + } }