add example mixin

This commit is contained in:
moehreag 2024-05-24 19:15:03 +02:00
parent df66596b5e
commit 798fc26fe4
2 changed files with 28 additions and 1 deletions

View file

@ -0,0 +1,25 @@
package org.ecorous.esnesnon.nonsense.loader.example.mixin;
import net.minecraft.client.gui.components.FocusableTextWidget;
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;
@Mixin(TitleScreen.class)
public abstract class TitleScreenMixin extends Screen {
protected TitleScreenMixin(Component title) {
super(title);
}
@Inject(method = "createNormalMenuOptions", at = @At("TAIL"), remap = false)
private void showExample(int y, int rowHeight, CallbackInfo ci) {
var widget = new FocusableTextWidget(200, Component.literal("<insert frog here!>"), this.font);
widget.setPosition(width / 2 - widget.getWidth(), 20);
addRenderableOnly(widget);
}
}

View file

@ -4,7 +4,9 @@
"package": "org.ecorous.esnesnon.nonsense.loader.example.mixin", "package": "org.ecorous.esnesnon.nonsense.loader.example.mixin",
"compatibilityLevel": "JAVA_21", "compatibilityLevel": "JAVA_21",
"mixins": [], "mixins": [],
"client": [], "client": [
"TitleScreenMixin"
],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1
} }