mirror of
https://github.com/JonasunderscoreJones/Microcraft.git
synced 2025-10-25 12:39:21 +02:00
fix: title screen button works!
This commit is contained in:
parent
35d8bbdcab
commit
4689a6fb6b
3 changed files with 35 additions and 52 deletions
|
|
@ -19,8 +19,6 @@ public class BoardScreen extends Screen {
|
|||
}
|
||||
|
||||
protected void init() {
|
||||
|
||||
|
||||
this.addRenderableWidget(Button.builder(Component.nullToEmpty("Configure Microcontrollers"), (button) -> {
|
||||
this.minecraft.setScreen(new SelectDevice(this));
|
||||
}).bounds(this.width / 2 - 155, this.height / 6 + 12, 150, 20).build());
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
package me.jonasjones.microcraft.mixin;
|
||||
|
||||
//import me.jonasjones.microcraft.gui.screens.BoardScreen;
|
||||
//import net.minecraft.client.gui.screen.Screen;
|
||||
//import net.minecraft.client.gui.screen.TitleScreen;
|
||||
//import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
//import net.minecraft.client.gui.widget.TexturedButtonWidget;
|
||||
//import net.minecraft.text.Text;
|
||||
//import net.minecraft.util.Identifier;
|
||||
//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 TitleScreenButtonMixin extends Screen {
|
||||
// protected TitleScreenButtonMixin(Text title) {
|
||||
// super(title);
|
||||
// }
|
||||
//
|
||||
// @Inject(at = @At("RETURN"), method = "initWidgetsNormal")
|
||||
// private void titleScreenButton(int y, int spacingY, CallbackInfo ci) {
|
||||
//
|
||||
// final Identifier ICON_TEXTURE = new Identifier(MOD_ID, "textures/gui/button_icon.png");
|
||||
//
|
||||
// int buttonX = this.width / 2 + 104;
|
||||
// int buttonY = y + spacingY * 2;
|
||||
//
|
||||
// this.addDrawableChild(ButtonWidget.builder( Text.of(""), (button) -> {
|
||||
// this.client.setScreen(new BoardScreen(this));
|
||||
// }).dimensions(buttonX, buttonY, 20, 20).build());
|
||||
// this.addDrawableChild( new TexturedButtonWidget(buttonX, buttonY, 20, 20, 0, 0, 0, ICON_TEXTURE, 20, 20,
|
||||
// (buttonWidget) -> this.client.setScreen(new BoardScreen(this))));
|
||||
// }
|
||||
//}
|
||||
|
|
@ -1,42 +1,63 @@
|
|||
package me.jonasjones.microcraft.mixin;
|
||||
|
||||
import me.jonasjones.microcraft.gui.screens.BoardScreen;
|
||||
import me.jonasjones.microcraft.gui.screens.GuiHome;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.ImageButton;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.intellij.lang.annotations.Identifier;
|
||||
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;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import static me.jonasjones.microcraft.Microcraft.MOD_ID;
|
||||
|
||||
@Mixin(TitleScreen.class)
|
||||
public abstract class TitleScreenMixin extends Screen {
|
||||
public class TitleScreenMixin extends Screen {
|
||||
// todo: find a way to get rid
|
||||
protected TitleScreenMixin(Component component) {
|
||||
super(component);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "init")
|
||||
private void gameMenuScreenButton(CallbackInfo ci) {
|
||||
final ResourceLocation ICON_TEXTURE = new ResourceLocation(MOD_ID, "gui/button_icon.png");
|
||||
|
||||
int buttonX = this.width / 2 + 108;
|
||||
int buttonY = this.height / 4 + 8;
|
||||
// @Inject(at = @At("HEAD"), method = "init")
|
||||
// private void gameMenuScreenButton(CallbackInfo ci) {
|
||||
// final ResourceLocation ICON_TEXTURE = new ResourceLocation(MOD_ID, "gui/button_icon.png");
|
||||
//
|
||||
// int buttonX = this.width / 2 + 108;
|
||||
// int buttonY = 3 * this.height / 4 + 8;
|
||||
//
|
||||
// this.addRenderableWidget(new Button.Builder(Component.empty(), (b) -> {
|
||||
// this.minecraft.setScreen(new GuiHome(this));
|
||||
// }).bounds(buttonX, buttonY, 20, 20).build());
|
||||
//
|
||||
//// this.addRenderableWidget(new ImageButton(buttonX, buttonY,
|
||||
//// 20, 20,
|
||||
//// 0, 0, 0,
|
||||
//// ICON_TEXTURE,
|
||||
//// 20, 20,
|
||||
//// (buttonWidget) -> this.minecraft.setScreen(new GuiHome(this))
|
||||
//// ));
|
||||
// }
|
||||
|
||||
this.addRenderableWidget(new ImageButton(buttonX, buttonY,
|
||||
20, 20,
|
||||
0, 0, 0,
|
||||
ICON_TEXTURE,
|
||||
20, 20,
|
||||
(buttonWidget) -> this.minecraft.setScreen(new GuiHome(this))
|
||||
));
|
||||
@Inject(at = @At("RETURN"), method = "createNormalMenuOptions")
|
||||
private void titleScreenButton(int y, int spacingY, CallbackInfo ci) {
|
||||
|
||||
final ResourceLocation ICON_TEXTURE = new ResourceLocation(MOD_ID, "textures/gui/button_icon.png");
|
||||
|
||||
int buttonX = this.width / 2 + 104;
|
||||
int buttonY = y + spacingY * 2;
|
||||
|
||||
// this.addRenderableWidget(new Button.Builder(Component.literal(""), (button) -> {
|
||||
// this.minecraft.setScreen(new BoardScreen(this));
|
||||
// }).bounds(buttonX, buttonY, 20, 20).build());
|
||||
|
||||
this.addRenderableWidget(new ImageButton(buttonX, buttonY, 20, 20, 0, 0, 0, ICON_TEXTURE, 20, 20,
|
||||
(buttonWidget) -> this.minecraft.setScreen(new BoardScreen(this))));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue