Search in sources :

Example 1 with SaveLevelScreen

use of net.minecraft.client.gui.screen.SaveLevelScreen in project AutoResetMod by DuncanRuns.

the class OptionsScreenMixin method addStopRunButtonMixin.

@Inject(method = "init", at = @At("TAIL"))
private void addStopRunButtonMixin(CallbackInfo info) {
    if (AutoReset.isPlaying) {
        // Get menu.stop_resets text or set to default
        Text text;
        if (Language.getInstance().get("menu.stop_resets").equals("menu.stop_resets")) {
            text = new LiteralText("Stop Resets & Quit");
        } else {
            text = new TranslatableText("menu.stop_resets");
        }
        // Add button to disable the auto reset and quit
        this.addButton(new ButtonWidget(0, this.height - 20, 100, 20, text, (buttonWidget) -> {
            AutoReset.isPlaying = false;
            buttonWidget.active = false;
            this.client.world.disconnect();
            this.client.disconnect(new SaveLevelScreen(new TranslatableText("menu.savingLevel")));
            this.client.openScreen(new TitleScreen());
        }));
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText) OptionsScreen(net.minecraft.client.gui.screen.options.OptionsScreen) Inject(org.spongepowered.asm.mixin.injection.Inject) TranslatableText(net.minecraft.text.TranslatableText) ButtonWidget(net.minecraft.client.gui.widget.ButtonWidget) AutoReset(me.duncanruns.autoreset.AutoReset) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) TitleScreen(net.minecraft.client.gui.screen.TitleScreen) Screen(net.minecraft.client.gui.screen.Screen) Language(net.minecraft.util.Language) Mixin(org.spongepowered.asm.mixin.Mixin) SaveLevelScreen(net.minecraft.client.gui.screen.SaveLevelScreen) Text(net.minecraft.text.Text) At(org.spongepowered.asm.mixin.injection.At) SaveLevelScreen(net.minecraft.client.gui.screen.SaveLevelScreen) LiteralText(net.minecraft.text.LiteralText) TranslatableText(net.minecraft.text.TranslatableText) Text(net.minecraft.text.Text) 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)

Aggregations

AutoReset (me.duncanruns.autoreset.AutoReset)1 SaveLevelScreen (net.minecraft.client.gui.screen.SaveLevelScreen)1 Screen (net.minecraft.client.gui.screen.Screen)1 TitleScreen (net.minecraft.client.gui.screen.TitleScreen)1 OptionsScreen (net.minecraft.client.gui.screen.options.OptionsScreen)1 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)1 LiteralText (net.minecraft.text.LiteralText)1 Text (net.minecraft.text.Text)1 TranslatableText (net.minecraft.text.TranslatableText)1 Language (net.minecraft.util.Language)1 Mixin (org.spongepowered.asm.mixin.Mixin)1 At (org.spongepowered.asm.mixin.injection.At)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 CallbackInfo (org.spongepowered.asm.mixin.injection.callback.CallbackInfo)1