Search in sources :

Example 26 with ButtonWidget

use of net.minecraft.client.gui.widget.ButtonWidget in project JexClient by DustinRepo.

the class MixinMultiplayerScreen method init.

@Inject(method = "init", at = @At("RETURN"))
public void init(CallbackInfo ci) {
    this.addDrawableChild(new ButtonWidget(2, 2, 75, 20, new LiteralText("Alt Manager"), button -> {
        Wrapper.INSTANCE.getMinecraft().setScreen(new AccountManagerScreen());
    }));
    this.addDrawableChild(new ButtonWidget(79, 2, 75, 20, new LiteralText("TheAltening"), button -> {
        Wrapper.INSTANCE.getMinecraft().setScreen(new TheAlteningScreen((MultiplayerScreen) (Object) this));
    }));
    this.addDrawableChild(new ButtonWidget(156, 2, 75, 20, new LiteralText("MCLeaks"), button -> {
        Wrapper.INSTANCE.getMinecraft().setScreen(new MCLeaksScreen((MultiplayerScreen) (Object) this, false));
    }));
    this.addDrawableChild(new ButtonWidget(width - 77, 2, 75, 20, new LiteralText("Proxy"), button -> {
        Wrapper.INSTANCE.getMinecraft().setScreen(new ProxyScreen());
    }));
}
Also used : Wrapper(me.dustin.jex.helper.misc.Wrapper) LiteralText(net.minecraft.text.LiteralText) Inject(org.spongepowered.asm.mixin.injection.Inject) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) Screen(net.minecraft.client.gui.screen.Screen) Mixin(org.spongepowered.asm.mixin.Mixin) MultiplayerScreen(net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen) MCLeaksScreen(me.dustin.jex.gui.mcleaks.MCLeaksScreen) AccountManagerScreen(me.dustin.jex.gui.account.AccountManagerScreen) ProxyScreen(me.dustin.jex.gui.proxy.ProxyScreen) Text(net.minecraft.text.Text) TheAlteningScreen(me.dustin.jex.gui.thealtening.TheAlteningScreen) At(org.spongepowered.asm.mixin.injection.At) TheAlteningScreen(me.dustin.jex.gui.thealtening.TheAlteningScreen) ProxyScreen(me.dustin.jex.gui.proxy.ProxyScreen) AccountManagerScreen(me.dustin.jex.gui.account.AccountManagerScreen) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) LiteralText(net.minecraft.text.LiteralText) MCLeaksScreen(me.dustin.jex.gui.mcleaks.MCLeaksScreen) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 27 with ButtonWidget

use of net.minecraft.client.gui.widget.ButtonWidget in project JexClient by DustinRepo.

the class MixinSignEditScreen method init.

@Inject(method = "init", at = @At("RETURN"))
public void init(CallbackInfo ci) {
    AutoSign autoSign = Feature.get(AutoSign.class);
    this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 4 + 142, 200, 20, new LiteralText("Set AutoSign Text"), (buttonWidget_1) -> {
        autoSign.signText[0] = sign.getTextOnRow(0, false);
        autoSign.signText[1] = sign.getTextOnRow(1, false);
        autoSign.signText[2] = sign.getTextOnRow(2, false);
        autoSign.signText[3] = sign.getTextOnRow(3, false);
        finishEditing();
    }));
}
Also used : Wrapper(me.dustin.jex.helper.misc.Wrapper) LiteralText(net.minecraft.text.LiteralText) SignEditScreen(net.minecraft.client.gui.screen.ingame.SignEditScreen) Inject(org.spongepowered.asm.mixin.injection.Inject) Feature(me.dustin.jex.feature.mod.core.Feature) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) Final(org.spongepowered.asm.mixin.Final) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) Screen(net.minecraft.client.gui.screen.Screen) Mixin(org.spongepowered.asm.mixin.Mixin) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) Shadow(org.spongepowered.asm.mixin.Shadow) Text(net.minecraft.text.Text) AutoSign(me.dustin.jex.feature.mod.impl.world.AutoSign) At(org.spongepowered.asm.mixin.injection.At) AutoSign(me.dustin.jex.feature.mod.impl.world.AutoSign) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) LiteralText(net.minecraft.text.LiteralText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 28 with ButtonWidget

use of net.minecraft.client.gui.widget.ButtonWidget in project ViaFabric by ViaVersion.

the class ViaConfigScreen method init.

@Override
protected void init() {
    int entries = 0;
    this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + entries % 2 * 160, this.height / 6 + 24 * (entries >> 1), 150, 20, getClientSideText(), this::onClickClientSide));
    entries++;
    this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + entries % 2 * 160, this.height / 6 + 24 * (entries >> 1), 150, 20, getHideViaButtonText(), this::onHideViaButton));
    entries++;
    protocolVersion = new TextFieldWidget(this.textRenderer, this.width / 2 - 155 + entries % 2 * 160, this.height / 6 + 24 * (entries >> 1), 150, 20, new TranslatableText("gui.protocol_version_field.name"));
    entries++;
    protocolVersion.setTextPredicate(ProtocolUtils::isStartOfProtocolText);
    protocolVersion.setChangedListener(this::onChangeVersionField);
    int clientSideVersion = ViaFabric.config.getClientSideVersion();
    protocolVersion.setText(ProtocolUtils.getProtocolName(clientSideVersion));
    this.addDrawableChild(protocolVersion);
    // noinspection ConstantConditions
    if (entries % 2 == 1) {
        entries++;
    }
    this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 24 * (entries >> 1), 200, 20, ScreenTexts.DONE, (buttonWidget) -> this.client.setScreen(this.parent)));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) ScreenTexts(net.minecraft.client.gui.screen.ScreenTexts) ConfirmScreen(net.minecraft.client.gui.screen.ConfirmScreen) AbstractViaConfigScreen(com.viaversion.fabric.common.config.AbstractViaConfigScreen) Environment(net.fabricmc.api.Environment) MatrixStack(net.minecraft.client.util.math.MatrixStack) TranslatableText(net.minecraft.text.TranslatableText) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) CompletableFuture(java.util.concurrent.CompletableFuture) ProtocolUtils(com.viaversion.fabric.common.util.ProtocolUtils) Screen(net.minecraft.client.gui.screen.Screen) ViaFabric(com.viaversion.fabric.mc119.ViaFabric) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) EnvType(net.fabricmc.api.EnvType) MinecraftClient(net.minecraft.client.MinecraftClient) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) ProtocolUtils(com.viaversion.fabric.common.util.ProtocolUtils) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget)

Example 29 with ButtonWidget

use of net.minecraft.client.gui.widget.ButtonWidget in project ViaFabric by ViaVersion.

the class ViaConfigScreen method onClickClientSide.

private void onClickClientSide(ButtonWidget widget) {
    if (!ViaFabric.config.isClientSideEnabled()) {
        MinecraftClient.getInstance().setScreen(new ConfirmScreen(answer -> {
            if (answer) {
                ViaFabric.config.setClientSideEnabled(true);
                // AUTO
                ViaFabric.config.setClientSideVersion(-2);
                ViaFabric.config.saveConfig();
                widget.setMessage(getClientSideText());
            }
            MinecraftClient.getInstance().setScreen(this);
        }, new TranslatableText("gui.enable_client_side.question"), new TranslatableText("gui.enable_client_side.warning"), new TranslatableText("gui.enable_client_side.enable"), new TranslatableText("gui.cancel")));
    } else {
        ViaFabric.config.setClientSideEnabled(false);
        ViaFabric.config.saveConfig();
    }
    widget.setMessage(getClientSideText());
}
Also used : ScreenTexts(net.minecraft.client.gui.screen.ScreenTexts) ConfirmScreen(net.minecraft.client.gui.screen.ConfirmScreen) AbstractViaConfigScreen(com.viaversion.fabric.common.config.AbstractViaConfigScreen) Environment(net.fabricmc.api.Environment) MatrixStack(net.minecraft.client.util.math.MatrixStack) TranslatableText(net.minecraft.text.TranslatableText) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) CompletableFuture(java.util.concurrent.CompletableFuture) ProtocolUtils(com.viaversion.fabric.common.util.ProtocolUtils) Screen(net.minecraft.client.gui.screen.Screen) ViaFabric(com.viaversion.fabric.mc119.ViaFabric) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) EnvType(net.fabricmc.api.EnvType) MinecraftClient(net.minecraft.client.MinecraftClient) TranslatableText(net.minecraft.text.TranslatableText) ConfirmScreen(net.minecraft.client.gui.screen.ConfirmScreen)

Example 30 with ButtonWidget

use of net.minecraft.client.gui.widget.ButtonWidget in project ViaFabric by ViaVersion.

the class ViaConfigScreen method init.

@Override
protected void init() {
    int entries = 0;
    this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + entries % 2 * 160, this.height / 6 + 24 * (entries >> 1), 150, 20, getClientSideText(), this::onClickClientSide));
    entries++;
    this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + entries % 2 * 160, this.height / 6 + 24 * (entries >> 1), 150, 20, getHideViaButtonText(), this::onHideViaButton));
    entries++;
    protocolVersion = new TextFieldWidget(this.textRenderer, this.width / 2 - 155 + entries % 2 * 160, this.height / 6 + 24 * (entries >> 1), 150, 20, new TranslatableText(VERSION_TRANSLATE_ID));
    entries++;
    protocolVersion.setTextPredicate(ProtocolUtils::isStartOfProtocolText);
    protocolVersion.setChangedListener(this::onChangeVersionField);
    int clientSideVersion = ViaFabric.config.getClientSideVersion();
    protocolVersion.setText(ProtocolUtils.getProtocolName(clientSideVersion));
    this.addDrawableChild(protocolVersion);
    // noinspection ConstantConditions
    if (entries % 2 == 1) {
        entries++;
    }
    this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 24 * (entries >> 1), 200, 20, ScreenTexts.DONE, (buttonWidget) -> this.client.setScreen(this.parent)));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) ScreenTexts(net.minecraft.client.gui.screen.ScreenTexts) ConfirmScreen(net.minecraft.client.gui.screen.ConfirmScreen) AbstractViaConfigScreen(com.viaversion.fabric.common.config.AbstractViaConfigScreen) ViaFabric(com.viaversion.fabric.mc118.ViaFabric) Environment(net.fabricmc.api.Environment) MatrixStack(net.minecraft.client.util.math.MatrixStack) TranslatableText(net.minecraft.text.TranslatableText) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) CompletableFuture(java.util.concurrent.CompletableFuture) ProtocolUtils(com.viaversion.fabric.common.util.ProtocolUtils) Screen(net.minecraft.client.gui.screen.Screen) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) EnvType(net.fabricmc.api.EnvType) MinecraftClient(net.minecraft.client.MinecraftClient) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) ProtocolUtils(com.viaversion.fabric.common.util.ProtocolUtils) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget)

Aggregations

ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)114 Screen (net.minecraft.client.gui.screen.Screen)84 MatrixStack (net.minecraft.client.util.math.MatrixStack)70 LiteralText (net.minecraft.text.LiteralText)67 TranslatableText (net.minecraft.text.TranslatableText)54 MinecraftClient (net.minecraft.client.MinecraftClient)42 TextFieldWidget (net.minecraft.client.gui.widget.TextFieldWidget)41 Text (net.minecraft.text.Text)30 GLFW (org.lwjgl.glfw.GLFW)27 Inject (org.spongepowered.asm.mixin.injection.Inject)25 ConfirmScreen (net.minecraft.client.gui.screen.ConfirmScreen)20 EnvType (net.fabricmc.api.EnvType)19 Environment (net.fabricmc.api.Environment)19 ScreenTexts (net.minecraft.client.gui.screen.ScreenTexts)19 Mixin (org.spongepowered.asm.mixin.Mixin)19 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)18 ArrayList (java.util.ArrayList)18 At (org.spongepowered.asm.mixin.injection.At)18 CallbackInfo (org.spongepowered.asm.mixin.injection.callback.CallbackInfo)18 Wrapper (me.dustin.jex.helper.misc.Wrapper)17