aboutsummaryrefslogtreecommitdiff
path: root/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java
blob: eac9ff42fa0f24b1be19d32c8329ed1c7fac591a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package dev.isxander.yacl.test.mixins;

import dev.isxander.yacl.test.config.GuiTest;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.network.chat.Component;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

/**
 * For testing purposes! If you are using this as
 * an example, ignore this class!
 */
@Mixin(TitleScreen.class)
public abstract class TitleScreenMixin extends Screen {
    protected TitleScreenMixin(Component title) {
        super(title);
    }

    @Inject(method = "init", at = @At("RETURN"))
    private void injectTestButton(CallbackInfo ci) {
        addRenderableWidget(Button.builder(Component.literal("YACL"), button -> minecraft.setScreen(GuiTest.getModConfigScreenFactory(minecraft.screen)))
                .pos(0, 0)
                .width(50)
                .build());
    }
}