Search in sources :

Example 1 with MultiplayerScreen

use of net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen in project meteor-client by MeteorDevelopment.

the class DisconnectedScreenMixin method onRenderBackground.

@Inject(method = "init", at = @At("TAIL"))
private void onRenderBackground(CallbackInfo info) {
    if (Modules.get().get(AutoReconnect.class).lastServerInfo != null) {
        int x = width / 2 - 100;
        int y = Math.min((height / 2 + reasonHeight / 2) + 32, height - 30);
        reconnectBtn = addDrawableChild(new ButtonWidget(x, y, 200, 20, new LiteralText(getText()), button -> ConnectScreen.connect(new MultiplayerScreen(new TitleScreen()), client, ServerAddress.parse(Modules.get().get(AutoReconnect.class).lastServerInfo.address), Modules.get().get(AutoReconnect.class).lastServerInfo)));
    }
}
Also used : MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) AutoReconnect(meteordevelopment.meteorclient.systems.modules.misc.AutoReconnect) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) LiteralText(net.minecraft.text.LiteralText) TitleScreen(net.minecraft.client.gui.screen.TitleScreen) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with MultiplayerScreen

use of net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen in project KiwiClient by TangyKiwi.

the class MainMenu method mouseClicked.

public boolean mouseClicked(double mouseX, double mouseY, int button) {
    for (int i = 0; i < 6; i++) {
        String b = BUTTONS[i];
        GuiButton guiButton = buttonList.get(i);
        float x = guiButton.x;
        float y = guiButton.y;
        if (mouseX >= x - guiButton.width / 2 && mouseY >= y && mouseX <= x + guiButton.width / 2 && mouseY <= y + 60) {
            this.client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
            switch(b) {
                case "Singleplayer":
                    this.client.setScreen(new SelectWorldScreen(this));
                    break;
                case "Multiplayer":
                    Screen screen = this.client.options.skipMultiplayerWarning ? new MultiplayerScreen(this) : new MultiplayerWarningScreen(this);
                    this.client.setScreen(screen);
                    break;
                case "Realms":
                    this.client.setScreen(new RealmsMainScreen(this));
                    break;
                case "Options":
                    this.client.setScreen(new OptionsScreen(this, this.client.options));
                    break;
                case "Language":
                    this.client.setScreen(new LanguageOptionsScreen(this, this.client.options, this.client.getLanguageManager()));
                    break;
                case "Quit":
                    this.client.scheduleStop();
                    break;
            }
        }
    }
    return super.mouseClicked(mouseX, mouseY, button);
}
Also used : MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) InventoryScreen(net.minecraft.client.gui.screen.ingame.InventoryScreen) SelectWorldScreen(net.minecraft.client.gui.screen.world.SelectWorldScreen) MultiplayerWarningScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerWarningScreen) LanguageOptionsScreen(net.minecraft.client.gui.screen.option.LanguageOptionsScreen) OptionsScreen(net.minecraft.client.gui.screen.option.OptionsScreen) Screen(net.minecraft.client.gui.screen.Screen) MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) RealmsMainScreen(net.minecraft.client.realms.gui.screen.RealmsMainScreen) LanguageOptionsScreen(net.minecraft.client.gui.screen.option.LanguageOptionsScreen) OptionsScreen(net.minecraft.client.gui.screen.option.OptionsScreen) MultiplayerWarningScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerWarningScreen) RealmsMainScreen(net.minecraft.client.realms.gui.screen.RealmsMainScreen) SelectWorldScreen(net.minecraft.client.gui.screen.world.SelectWorldScreen) LanguageOptionsScreen(net.minecraft.client.gui.screen.option.LanguageOptionsScreen)

Example 3 with MultiplayerScreen

use of net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen in project Hypnotic-Client by Hypnotic-Development.

the class MinecraftClientMixin method onPreTick.

@Inject(at = @At("HEAD"), method = "tick")
private void onPreTick(CallbackInfo info) {
    BlockIterator.INSTANCE.onTick();
    EventTick event = new EventTick();
    event.call();
    if (ModuleManager.INSTANCE.getModule(DiscordRPCModule.class).isEnabled()) {
        if (mc.player == null) {
            if (mc.currentScreen instanceof HypnoticMainMenu)
                DiscordRPCModule.status = "In main menu";
            if (mc.currentScreen instanceof SelectWorldScreen)
                DiscordRPCModule.status = "Browsing worlds";
            if (mc.currentScreen instanceof MultiplayerScreen)
                DiscordRPCModule.status = "Browsing servers";
        } else {
            if (mc.isInSingleplayer())
                DiscordRPCModule.status = "Playing singlelplayer";
            if (mc.getCurrentServerEntry() != null && !mc.isInSingleplayer())
                DiscordRPCModule.status = ModuleManager.INSTANCE.getModule(DiscordRPCModule.class).serverpriv.isEnabled() ? "Playing multiplayer." : "Playing multiplayer on " + mc.getCurrentServerEntry().address;
        }
    }
}
Also used : DiscordRPCModule(dev.hypnotic.module.misc.DiscordRPCModule) MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) HypnoticMainMenu(dev.hypnotic.ui.HypnoticMainMenu) EventTick(dev.hypnotic.event.events.EventTick) SelectWorldScreen(net.minecraft.client.gui.screen.world.SelectWorldScreen) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with MultiplayerScreen

use of net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen in project tweakermore by Fallen-Breath.

the class SafeAfkHelper method onHealthUpdate.

public static void onHealthUpdate(MinecraftClient mc) {
    if (TweakerMoreConfigs.TWEAKM_SAFE_AFK.getBooleanValue()) {
        if (mc.player != null && mc.world != null && hasRecord()) {
            float health = mc.player.getHealth();
            float maxHealth = mc.player.getMaximumHealth();
            if (maxHealth > 0 && health < TweakerMoreConfigs.SAFE_AFK_HEALTH_THRESHOLD.getDoubleValue()) {
                String title = TweakerMoreMod.MOD_NAME + " " + TweakerMoreConfigs.TWEAKM_SAFE_AFK.getPrettyName();
                BaseText reason = new TranslatableText("tweakermore.config.tweakmSafeAfk.received_damage", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), String.format("%.1f / %.1f (%.0f%%)", health, maxHealth, health / maxHealth * 100));
                resetHurtTime();
                mc.execute(() -> {
                    mc.world.disconnect();
                    mc.disconnect();
                    mc.openScreen(new DisconnectedScreen(new MultiplayerScreen(new TitleScreen()), title, reason));
                });
            }
        }
    }
}
Also used : BaseText(net.minecraft.text.BaseText) TranslatableText(net.minecraft.text.TranslatableText) MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) DisconnectedScreen(net.minecraft.client.gui.screen.DisconnectedScreen) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) TitleScreen(net.minecraft.client.gui.screen.TitleScreen)

Example 5 with MultiplayerScreen

use of net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen in project BleachHack by BleachDrinker420.

the class BleachTitleScreen method init.

@Override
public void init() {
    super.init();
    addWindow(new Window(width / 8, height / 8, width - width / 8, height - height / 8 + 2, "BleachHack", new ItemStack(Items.MUSIC_DISC_CAT)));
    int w = getWindow(0).x2 - getWindow(0).x1;
    int h = getWindow(0).y2 - getWindow(0).y1;
    int maxY = MathHelper.clamp(h / 4 + 119, 0, h - 22);
    getWindow(0).addWidget(new WindowButtonWidget(w / 2 - 100, h / 4 + 38, w / 2 + 100, h / 4 + 58, I18n.translate("menu.singleplayer"), () -> client.setScreen(new SelectWorldScreen(client.currentScreen))));
    getWindow(0).addWidget(new WindowButtonWidget(w / 2 - 100, h / 4 + 62, w / 2 + 100, h / 4 + 82, I18n.translate("menu.multiplayer"), () -> client.setScreen(new MultiplayerScreen(client.currentScreen))));
    getWindow(0).addWidget(new WindowButtonWidget(w / 2 - 100, h / 4 + 86, w / 2 + 100, h / 4 + 106, I18n.translate("menu.online"), () -> client.setScreen(new RealmsMainScreen(this))));
    getWindow(0).addWidget(new WindowButtonWidget(w / 2 - 124, h / 4 + 86, w / 2 - 104, h / 4 + 106, "MC", () -> {
        customTitleScreen = !customTitleScreen;
        BleachFileHelper.saveMiscSetting("customTitleScreen", new JsonPrimitive(false));
        client.setScreen(new TitleScreen(false));
    }));
    getWindow(0).addWidget(new WindowButtonWidget(w / 2 - 100, maxY, w / 2 - 2, maxY + 20, I18n.translate("menu.options"), () -> client.setScreen(new OptionsScreen(client.currentScreen, client.options))));
    getWindow(0).addWidget(new WindowButtonWidget(w / 2 + 2, maxY, w / 2 + 100, maxY + 20, I18n.translate("menu.quit"), () -> client.scheduleStop()));
    // Main Text
    getWindow(0).addWidget(new WindowTextWidget(LiteralText.EMPTY, true, WindowTextWidget.TextAlign.MIDDLE, 3f, w / 2, h / 4 - 25, 0).withRenderEvent((widget, ms, wx, wy) -> {
        MutableText bhText = new LiteralText("");
        int i = 0;
        for (char c : "BleachHack".toCharArray()) {
            int fi = i++;
            bhText.append(new LiteralText(String.valueOf(c)).styled(s -> s.withColor(TextColor.fromRgb(UI.getRainbowFromSettings(fi)))));
        }
        ((WindowTextWidget) widget).setText(bhText);
    }));
    // Version Text
    getWindow(0).addWidget(new WindowTextWidget(BleachHack.VERSION, true, WindowTextWidget.TextAlign.MIDDLE, 1.5f, w / 2, h / 4 - 6, 0xffc050));
    // Splash
    getWindow(0).addWidget(new WindowTextWidget(LiteralText.EMPTY, true, WindowTextWidget.TextAlign.MIDDLE, 2f, -20f, w / 2 + 80, h / 4 + 6, 0xffff00).withRenderEvent((widget, ms, wx, wy) -> {
        if (splash != null) {
            WindowTextWidget windgetText = (WindowTextWidget) widget;
            windgetText.setText(new LiteralText(splash));
            windgetText.color = (windgetText.color & 0x00ffffff) | ((splashTicks * 17) << 24);
            float scale = 1.8F - MathHelper.abs(MathHelper.sin(Util.getMeasuringTimeMs() % 1000L / 1000.0F * 6.2831855F) * 0.1F);
            scale = scale * 66.0F / (textRenderer.getWidth(splash) + 32);
            windgetText.setScale(scale);
        }
    }));
    // Update Text
    JsonObject updateJson = BleachHack.getUpdateJson();
    if (updateJson != null && updateJson.has("version") && updateJson.get("version").getAsInt() > BleachHack.INTVERSION) {
        getWindow(0).addWidget(new WindowTextWidget("\u00a76\u00a7nUpdate\u00a76", true, 4, h - 12, 0xffffff).withClickEvent((widget, mx, my, wx, wy) -> client.setScreen(new UpdateScreen(client.currentScreen, updateJson))));
    }
}
Also used : Window(org.bleachhack.gui.window.Window) FabricLoader(net.fabricmc.loader.api.FabricLoader) JsonObject(com.google.gson.JsonObject) LiteralText(net.minecraft.text.LiteralText) SelectWorldScreen(net.minecraft.client.gui.screen.world.SelectWorldScreen) BodyHandlers(java.net.http.HttpResponse.BodyHandlers) Util(net.minecraft.util.Util) TranslatableText(net.minecraft.text.TranslatableText) BleachFileHelper(org.bleachhack.util.io.BleachFileHelper) Random(java.util.Random) ParticleManager(org.bleachhack.gui.effect.ParticleManager) WindowTextWidget(org.bleachhack.gui.window.widget.WindowTextWidget) ItemStack(net.minecraft.item.ItemStack) Window(org.bleachhack.gui.window.Window) MutableText(net.minecraft.text.MutableText) SharedConstants(net.minecraft.SharedConstants) JsonPrimitive(com.google.gson.JsonPrimitive) WindowScreen(org.bleachhack.gui.window.WindowScreen) I18n(net.minecraft.client.resource.language.I18n) UI(org.bleachhack.module.mods.UI) BleachHack(org.bleachhack.BleachHack) MatrixStack(net.minecraft.client.util.math.MatrixStack) Items(net.minecraft.item.Items) TextColor(net.minecraft.text.TextColor) WindowButtonWidget(org.bleachhack.gui.window.widget.WindowButtonWidget) OptionsScreen(net.minecraft.client.gui.screen.option.OptionsScreen) BleachOnlineMang(org.bleachhack.util.io.BleachOnlineMang) TitleScreen(net.minecraft.client.gui.screen.TitleScreen) List(java.util.List) MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) MathHelper(net.minecraft.util.math.MathHelper) RealmsMainScreen(net.minecraft.client.realms.gui.screen.RealmsMainScreen) MutableText(net.minecraft.text.MutableText) JsonPrimitive(com.google.gson.JsonPrimitive) OptionsScreen(net.minecraft.client.gui.screen.option.OptionsScreen) WindowTextWidget(org.bleachhack.gui.window.widget.WindowTextWidget) JsonObject(com.google.gson.JsonObject) WindowButtonWidget(org.bleachhack.gui.window.widget.WindowButtonWidget) TitleScreen(net.minecraft.client.gui.screen.TitleScreen) MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) RealmsMainScreen(net.minecraft.client.realms.gui.screen.RealmsMainScreen) ItemStack(net.minecraft.item.ItemStack) SelectWorldScreen(net.minecraft.client.gui.screen.world.SelectWorldScreen) LiteralText(net.minecraft.text.LiteralText)

Aggregations

MultiplayerScreen (net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen)6 TitleScreen (net.minecraft.client.gui.screen.TitleScreen)3 SelectWorldScreen (net.minecraft.client.gui.screen.world.SelectWorldScreen)3 LiteralText (net.minecraft.text.LiteralText)3 Screen (net.minecraft.client.gui.screen.Screen)2 OptionsScreen (net.minecraft.client.gui.screen.option.OptionsScreen)2 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)2 RealmsMainScreen (net.minecraft.client.realms.gui.screen.RealmsMainScreen)2 MatrixStack (net.minecraft.client.util.math.MatrixStack)2 TranslatableText (net.minecraft.text.TranslatableText)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 EventTick (dev.hypnotic.event.events.EventTick)1 DiscordRPCModule (dev.hypnotic.module.misc.DiscordRPCModule)1 HypnoticMainMenu (dev.hypnotic.ui.HypnoticMainMenu)1 BodyHandlers (java.net.http.HttpResponse.BodyHandlers)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 List (java.util.List)1