Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
Add a button for disconnecting handshake
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Mar 10, 2021
1 parent c947568 commit 1d4473d
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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()));
}
)
);
}
}

0 comments on commit 1d4473d

Please sign in to comment.