Search in sources :

Example 1 with MultiplayerScreen

use of net.minecraft.client.gui.screen.MultiplayerScreen in project ModernUI by BloCamLimb.

the class IngameMenuHome method confirmExit.

private void confirmExit(int callback) {
    if (minecraft.world == null || callback != ConfirmCallback.CONFIRM) {
        return;
    }
    boolean singleplayer = minecraft.isIntegratedServerRunning();
    boolean realmsConnected = minecraft.isConnectedToRealms();
    minecraft.world.sendQuittingDisconnectingPacket();
    if (singleplayer) {
        minecraft.unloadWorld(new DirtMessageScreen(new TranslationTextComponent("menu.savingLevel")));
    } else {
        minecraft.unloadWorld();
    }
    if (singleplayer) {
        minecraft.displayGuiScreen(new MainMenuScreen());
    } else if (realmsConnected) {
        RealmsBridgeScreen realmsBridge = new RealmsBridgeScreen();
        realmsBridge.func_231394_a_(new MainMenuScreen());
    } else {
        minecraft.displayGuiScreen(new MultiplayerScreen(new MainMenuScreen()));
    }
}
Also used : MultiplayerScreen(net.minecraft.client.gui.screen.MultiplayerScreen) DirtMessageScreen(net.minecraft.client.gui.screen.DirtMessageScreen) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) MainMenuScreen(net.minecraft.client.gui.screen.MainMenuScreen) RealmsBridgeScreen(net.minecraft.realms.RealmsBridgeScreen)

Example 2 with MultiplayerScreen

use of net.minecraft.client.gui.screen.MultiplayerScreen in project VariousOddities by Lyinginbedmon.

the class AbstractParalysisScreen method init.

public void init() {
    this.minecraft.keyboardListener.enableRepeatEvents(true);
    this.addButton(new Button(this.width / 2 - 102, this.height / 4 + 24 + -16, 204, 20, new TranslationTextComponent("gui." + Reference.ModInfo.MOD_ID + ".paralysed.resignation"), (button2) -> {
        PacketHandler.sendToServer(new PacketParalysisResignation());
    }));
    this.addButton(new Button(this.width / 2 - 102, this.height / 4 + 48 + -16, 98, 20, new TranslationTextComponent("gui.advancements"), (button2) -> {
        this.minecraft.displayGuiScreen(new AdvancementsScreen(this.minecraft.player.connection.getAdvancementManager()));
    }));
    this.addButton(new Button(this.width / 2 + 4, this.height / 4 + 48 + -16, 98, 20, new TranslationTextComponent("gui.stats"), (button2) -> {
        this.minecraft.displayGuiScreen(new StatsScreen(this, this.minecraft.player.getStats()));
    }));
    String s = SharedConstants.getVersion().isStable() ? "https://aka.ms/javafeedback?ref=game" : "https://aka.ms/snapshotfeedback?ref=game";
    this.addButton(new Button(this.width / 2 - 102, this.height / 4 + 72 + -16, 98, 20, new TranslationTextComponent("menu.sendFeedback"), (button2) -> {
        this.minecraft.displayGuiScreen(new ConfirmOpenLinkScreen((open) -> {
            if (open)
                Util.getOSType().openURI(s);
            this.minecraft.displayGuiScreen(this);
        }, s, true));
    }));
    this.addButton(new Button(this.width / 2 + 4, this.height / 4 + 72 + -16, 98, 20, new TranslationTextComponent("menu.reportBugs"), (button2) -> {
        this.minecraft.displayGuiScreen(new ConfirmOpenLinkScreen((open) -> {
            if (open)
                Util.getOSType().openURI("https://aka.ms/snapshotbugs?ref=game");
            this.minecraft.displayGuiScreen(this);
        }, "https://aka.ms/snapshotbugs?ref=game", true));
    }));
    this.addButton(new Button(this.width / 2 - 102, this.height / 4 + 96 + -16, 98, 20, new TranslationTextComponent("menu.options"), (button2) -> {
        this.minecraft.displayGuiScreen(new OptionsScreen(this, this.minecraft.gameSettings));
    }));
    Button button = this.addButton(new Button(this.width / 2 + 4, this.height / 4 + 96 + -16, 98, 20, new TranslationTextComponent("menu.shareToLan"), (button2) -> {
        this.minecraft.displayGuiScreen(new ShareToLanScreen(this));
    }));
    button.active = this.minecraft.isSingleplayer() && !this.minecraft.getIntegratedServer().getPublic();
    Button button1 = this.addButton(new Button(this.width / 2 - 102, this.height / 4 + 120 + -16, 204, 20, new TranslationTextComponent("menu.returnToMenu"), (button2) -> {
        boolean flag = this.minecraft.isIntegratedServerRunning();
        boolean flag1 = this.minecraft.isConnectedToRealms();
        button2.active = false;
        this.minecraft.world.sendQuittingDisconnectingPacket();
        if (flag)
            this.minecraft.unloadWorld(new DirtMessageScreen(new TranslationTextComponent("menu.savingLevel")));
        else
            this.minecraft.unloadWorld();
        if (flag)
            this.minecraft.displayGuiScreen(new MainMenuScreen());
        else if (flag1) {
            RealmsBridgeScreen realmsbridgescreen = new RealmsBridgeScreen();
            realmsbridgescreen.func_231394_a_(new MainMenuScreen());
        } else
            this.minecraft.displayGuiScreen(new MultiplayerScreen(new MainMenuScreen()));
    }));
    if (!this.minecraft.isIntegratedServerRunning())
        button1.setMessage(new TranslationTextComponent("menu.disconnect"));
}
Also used : MainMenuScreen(net.minecraft.client.gui.screen.MainMenuScreen) MultiplayerScreen(net.minecraft.client.gui.screen.MultiplayerScreen) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Util(net.minecraft.util.Util) RealmsBridgeScreen(net.minecraft.realms.RealmsBridgeScreen) SharedConstants(net.minecraft.util.SharedConstants) AdvancementsScreen(net.minecraft.client.gui.advancements.AdvancementsScreen) StatsScreen(net.minecraft.client.gui.screen.StatsScreen) Reference(com.lying.variousoddities.reference.Reference) PacketParalysisResignation(com.lying.variousoddities.network.PacketParalysisResignation) ConfirmOpenLinkScreen(net.minecraft.client.gui.screen.ConfirmOpenLinkScreen) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) PacketHandler(com.lying.variousoddities.network.PacketHandler) DirtMessageScreen(net.minecraft.client.gui.screen.DirtMessageScreen) Screen(net.minecraft.client.gui.screen.Screen) Button(net.minecraft.client.gui.widget.button.Button) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) OptionsScreen(net.minecraft.client.gui.screen.OptionsScreen) ShareToLanScreen(net.minecraft.client.gui.screen.ShareToLanScreen) DirtMessageScreen(net.minecraft.client.gui.screen.DirtMessageScreen) OptionsScreen(net.minecraft.client.gui.screen.OptionsScreen) PacketParalysisResignation(com.lying.variousoddities.network.PacketParalysisResignation) AdvancementsScreen(net.minecraft.client.gui.advancements.AdvancementsScreen) ConfirmOpenLinkScreen(net.minecraft.client.gui.screen.ConfirmOpenLinkScreen) RealmsBridgeScreen(net.minecraft.realms.RealmsBridgeScreen) ShareToLanScreen(net.minecraft.client.gui.screen.ShareToLanScreen) StatsScreen(net.minecraft.client.gui.screen.StatsScreen) MultiplayerScreen(net.minecraft.client.gui.screen.MultiplayerScreen) Button(net.minecraft.client.gui.widget.button.Button) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) MainMenuScreen(net.minecraft.client.gui.screen.MainMenuScreen)

Aggregations

DirtMessageScreen (net.minecraft.client.gui.screen.DirtMessageScreen)2 MainMenuScreen (net.minecraft.client.gui.screen.MainMenuScreen)2 MultiplayerScreen (net.minecraft.client.gui.screen.MultiplayerScreen)2 RealmsBridgeScreen (net.minecraft.realms.RealmsBridgeScreen)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 PacketHandler (com.lying.variousoddities.network.PacketHandler)1 PacketParalysisResignation (com.lying.variousoddities.network.PacketParalysisResignation)1 Reference (com.lying.variousoddities.reference.Reference)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 AdvancementsScreen (net.minecraft.client.gui.advancements.AdvancementsScreen)1 ConfirmOpenLinkScreen (net.minecraft.client.gui.screen.ConfirmOpenLinkScreen)1 OptionsScreen (net.minecraft.client.gui.screen.OptionsScreen)1 Screen (net.minecraft.client.gui.screen.Screen)1 ShareToLanScreen (net.minecraft.client.gui.screen.ShareToLanScreen)1 StatsScreen (net.minecraft.client.gui.screen.StatsScreen)1 Button (net.minecraft.client.gui.widget.button.Button)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 SharedConstants (net.minecraft.util.SharedConstants)1 Util (net.minecraft.util.Util)1 ITextComponent (net.minecraft.util.text.ITextComponent)1