change: migrated to mojmap

This commit is contained in:
ZtereoHYPE 2023-06-25 23:11:03 +02:00
parent 483a4a96fc
commit 3ba6a2917d
15 changed files with 199 additions and 217 deletions

View file

@ -3,6 +3,7 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
minecraft_version=1.19.3 minecraft_version=1.19.3
yarn_mappings=1.19.3+build.1
loader_version=0.14.11 loader_version=0.14.11
# Mod Properties # Mod Properties

View file

@ -3,7 +3,6 @@ package me.jonasjones.microcraft;
import me.jonasjones.microcraft.config.ModConfigs; import me.jonasjones.microcraft.config.ModConfigs;
import me.jonasjones.microcraft.config.ProfileConfig; import me.jonasjones.microcraft.config.ProfileConfig;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import org.json.simple.parser.ParseException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View file

@ -1,5 +1,5 @@
package me.jonasjones.microcraft.board; package me.jonasjones.microcraft.board;
import net.minecraft.util.Identifier; import net.minecraft.resources.ResourceLocation;
public record MicrocontrollerBoardIcon(Identifier boardTextureHorizontal, Identifier boardTextureVertical, int width, int height) {} public record MicrocontrollerBoardIcon(ResourceLocation boardTextureHorizontal, ResourceLocation boardTextureVertical, int width, int height) {}

View file

@ -1,15 +1,6 @@
package me.jonasjones.microcraft.config; package me.jonasjones.microcraft.config;
import me.jonasjones.microcraft.object.BoardData;
//import org.json.simple.JSONArray;
//import org.json.simple.JSONObject;
//import org.json.simple.parser.JSONParser;
//import org.json.simple.parser.ParseException;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class ProfileConfig { public class ProfileConfig {
public static void uwu() throws IOException { public static void uwu() throws IOException {

View file

@ -1,41 +1,41 @@
package me.jonasjones.microcraft.gui.screens; package me.jonasjones.microcraft.gui.screens;
import com.mojang.blaze3d.vertex.PoseStack;
import me.jonasjones.microcraft.gui.widget.BoardConfigwidget; import me.jonasjones.microcraft.gui.widget.BoardConfigwidget;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.screen.ScreenTexts; import net.minecraft.network.chat.Component;
import net.minecraft.text.Text;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class BoardScreen extends Screen { public class BoardScreen extends Screen {
private final Screen parent; private final Screen parent;
public BoardScreen (Screen parent) { public BoardScreen (Screen parent) {
super(Text.of("Microcraft Configuration")); super(Component.nullToEmpty("Microcraft Configuration"));
this.parent = parent; this.parent = parent;
} }
protected void init() { protected void init() {
this.addDrawableChild(ButtonWidget.builder(Text.of("Configure Microcontrollers"), (button) -> { this.addRenderableWidget(Button.builder(Component.nullToEmpty("Configure Microcontrollers"), (button) -> {
this.client.setScreen(new SelectDevice(this)); this.minecraft.setScreen(new SelectDevice(this));
}).dimensions(this.width / 2 - 155, this.height / 6 + 12, 150, 20).build()); }).bounds(this.width / 2 - 155, this.height / 6 + 12, 150, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.of("Configure Microcraft"), (button) -> { this.addRenderableWidget(Button.builder(Component.nullToEmpty("Configure Microcraft"), (button) -> {
this.client.setScreen(new ModSettings(this)); this.minecraft.setScreen(new ModSettings(this));
}).dimensions(this.width / 2 + 5, this.height / 6 + 12, 150, 20).build()); }).bounds(this.width / 2 + 5, this.height / 6 + 12, 150, 20).build());
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> { this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> {
this.client.setScreen(this.parent); this.minecraft.setScreen(this.parent);
}).dimensions(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build()); }).bounds(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build());
this.client.setScreen(new BoardConfigwidget(this.parent)); this.minecraft.setScreen(new BoardConfigwidget(this.parent));
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices); this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
} }
} }

View file

@ -1,40 +1,38 @@
package me.jonasjones.microcraft.gui.screens; package me.jonasjones.microcraft.gui.screens;
import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.chat.Component;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class GuiHome extends Screen { public class GuiHome extends Screen {
private final Screen parent; private final Screen parent;
public GuiHome (Screen parent) { public GuiHome (Screen parent) {
super(Text.of("Microcraft Configuration")); super(Component.nullToEmpty("Microcraft Configuration"));
this.parent = parent; this.parent = parent;
} }
protected void init() { 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());
this.addRenderableWidget(Button.builder(Component.nullToEmpty("Configure Microcraft"), (button) -> {
this.minecraft.setScreen(new ModSettings(this));
}).bounds(this.width / 2 + 5, this.height / 6 + 12, 150, 20).build());
this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> {
this.addDrawableChild(ButtonWidget.builder(Text.of("Configure Microcontrollers"), (button) -> { this.minecraft.setScreen(this.parent);
this.client.setScreen(new SelectDevice(this)); }).bounds(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build());
}).dimensions( this.width / 2 - 155, this.height / 6 + 12, 150, 20).build()); this.addRenderableWidget(new net.minecraft.client.gui.components.Checkbox(50, 50, 100, 20, Component.nullToEmpty("uwu checkbox"), false));
this.addDrawableChild(ButtonWidget.builder(Text.of("Configure Microcraft"), (button) -> {
this.client.setScreen(new ModSettings(this));
}).dimensions(this.width / 2 + 5, this.height / 6 + 12, 150, 20).build());
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
this.client.setScreen(this.parent);
}).dimensions(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build());
this.addDrawableChild(new net.minecraft.client.gui.widget.CheckboxWidget(50, 50, 100, 20, Text.of("uwu checkbox"), false));
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices); this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
} }
} }

View file

@ -1,15 +1,14 @@
package me.jonasjones.microcraft.gui.screens; package me.jonasjones.microcraft.gui.screens;
import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.ConfirmLinkScreen; import net.minecraft.Util;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.widget.*; import net.minecraft.client.gui.screens.ConfirmLinkScreen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.screen.ScreenTexts; import net.minecraft.network.chat.Component;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class ModCreditsScreen extends Screen { public class ModCreditsScreen extends Screen {
@ -17,64 +16,64 @@ public class ModCreditsScreen extends Screen {
private final Screen parent; private final Screen parent;
public ModCreditsScreen(Screen parent) { public ModCreditsScreen(Screen parent) {
super(Text.of("About Microcraft")); super(Component.nullToEmpty("About Microcraft"));
this.parent = parent; this.parent = parent;
} }
protected void init() { protected void init() {
this.addDrawableChild(ButtonWidget.builder(Text.of("Modrinth"), this::openModrinthPage).dimensions(this.width / 2 - 155, this.height / 6 + 12, 100, 20).build()); this.addRenderableWidget(Button.builder(Component.nullToEmpty("Modrinth"), this::openModrinthPage).bounds(this.width / 2 - 155, this.height / 6 + 12, 100, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.of("GitHub"), this::openGithubPage).dimensions(this.width / 2 - 50, this.height / 6 + 12, 100, 20).build()); this.addRenderableWidget(Button.builder(Component.nullToEmpty("GitHub"), this::openGithubPage).bounds(this.width / 2 - 50, this.height / 6 + 12, 100, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.of("Curseforge"), this::openCurseforgePage).dimensions(this.width / 2 + 55, this.height / 6 + 12, 100, 20).build()); this.addRenderableWidget(Button.builder(Component.nullToEmpty("Curseforge"), this::openCurseforgePage).bounds(this.width / 2 + 55, this.height / 6 + 12, 100, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.of("Homepage"), this::openHomepagePage).dimensions(this.width / 2 - 155, this.height / 6 + 35, 310, 20).build()); this.addRenderableWidget(Button.builder(Component.nullToEmpty("Homepage"), this::openHomepagePage).bounds(this.width / 2 - 155, this.height / 6 + 35, 310, 20).build());
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> { this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> {
this.client.setScreen(this.parent); this.minecraft.setScreen(this.parent);
}).dimensions(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build()); }).bounds(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build());
} }
private void openModrinthPage(ButtonWidget button) { private void openModrinthPage(Button button) {
this.client.setScreen(new ConfirmLinkScreen((confirmed) -> { this.minecraft.setScreen(new ConfirmLinkScreen((confirmed) -> {
if (confirmed) { if (confirmed) {
Util.getOperatingSystem().open("http://aka.jonasjones.me/microcraft-modrinth"); Util.getPlatform().openUri("http://aka.jonasjones.me/microcraft-modrinth");
} }
this.client.setScreen(this); this.minecraft.setScreen(this);
}, "http://aka.jonasjones.me/microcraft-modrinth", true)); }, "http://aka.jonasjones.me/microcraft-modrinth", true));
} }
private void openGithubPage(ButtonWidget button) { private void openGithubPage(Button button) {
this.client.setScreen(new ConfirmLinkScreen((confirmed) -> { this.minecraft.setScreen(new ConfirmLinkScreen((confirmed) -> {
if (confirmed) { if (confirmed) {
Util.getOperatingSystem().open("http://aka.jonasjones.me/microcraft-github"); Util.getPlatform().openUri("http://aka.jonasjones.me/microcraft-github");
} }
this.client.setScreen(this); this.minecraft.setScreen(this);
}, "http://aka.jonasjones.me/microcraft-github", true)); }, "http://aka.jonasjones.me/microcraft-github", true));
} }
private void openCurseforgePage(ButtonWidget button) { private void openCurseforgePage(Button button) {
this.client.setScreen(new ConfirmLinkScreen((confirmed) -> { this.minecraft.setScreen(new ConfirmLinkScreen((confirmed) -> {
if (confirmed) { if (confirmed) {
Util.getOperatingSystem().open("http://aka.jonasjones.me/microcraft-curseforge"); Util.getPlatform().openUri("http://aka.jonasjones.me/microcraft-curseforge");
} }
this.client.setScreen(this); this.minecraft.setScreen(this);
}, "http://aka.jonasjones.me/microcraft-curseforge", true)); }, "http://aka.jonasjones.me/microcraft-curseforge", true));
} }
private void openHomepagePage(ButtonWidget button) { private void openHomepagePage(Button button) {
this.client.setScreen(new ConfirmLinkScreen((confirmed) -> { this.minecraft.setScreen(new ConfirmLinkScreen((confirmed) -> {
if (confirmed) { if (confirmed) {
Util.getOperatingSystem().open("https://jonasjones.me/microcraft"); Util.getPlatform().openUri("https://jonasjones.me/microcraft");
} }
this.client.setScreen(this); this.minecraft.setScreen(this);
}, "https://jonasjones.me/microcraft", true)); }, "https://jonasjones.me/microcraft", true));
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices); this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
} }
} }

View file

@ -1,12 +1,12 @@
package me.jonasjones.microcraft.gui.screens; package me.jonasjones.microcraft.gui.screens;
import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.screen.ScreenTexts; import net.minecraft.network.chat.Component;
import net.minecraft.text.Text;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@ -14,24 +14,24 @@ public class ModSettings extends Screen {
private final Screen parent; private final Screen parent;
public ModSettings (Screen parent) { public ModSettings (Screen parent) {
super(Text.of("MicrocontrollerMC Controls")); super(Component.nullToEmpty("MicrocontrollerMC Controls"));
this.parent = parent; this.parent = parent;
} }
protected void init() { protected void init() {
this.addDrawableChild(ButtonWidget.builder(Text.of("Configure Microcontrollers"), (button) -> { this.addRenderableWidget(Button.builder(Component.nullToEmpty("Configure Microcontrollers"), (button) -> {
this.client.setScreen(new SelectDevice(this)); this.minecraft.setScreen(new SelectDevice(this));
}).dimensions(this.width / 2 - 155, this.height / 6 + 12, 150, 20).build()); }).bounds(this.width / 2 - 155, this.height / 6 + 12, 150, 20).build());
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> { this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> {
this.client.setScreen(this.parent); this.minecraft.setScreen(this.parent);
}).dimensions(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build()); }).bounds(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build());
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices); this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
} }
} }

View file

@ -1,18 +1,18 @@
package me.jonasjones.microcraft.gui.screens; package me.jonasjones.microcraft.gui.screens;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.logging.LogUtils; import com.mojang.logging.LogUtils;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screen.world.CreateWorldScreen; import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.screen.world.SelectWorldScreen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screen.world.WorldListWidget; import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.screens.worldselection.SelectWorldScreen;
import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.gui.screens.worldselection.WorldSelectionList;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.screen.ScreenTexts; import net.minecraft.network.chat.Component;
import net.minecraft.text.OrderedText; import net.minecraft.util.FormattedCharSequence;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -24,16 +24,16 @@ public class SelectDevice extends Screen {
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
protected final Screen parent; protected final Screen parent;
@Nullable @Nullable
private List<OrderedText> tooltip; private List<FormattedCharSequence> tooltip;
private ButtonWidget deleteButton; private Button deleteButton;
private ButtonWidget selectButton; private Button selectButton;
private ButtonWidget editButton; private Button editButton;
private ButtonWidget recreateButton; private Button recreateButton;
protected TextFieldWidget searchBox; protected EditBox searchBox;
private WorldListWidget levelList; private WorldSelectionList levelList;
public SelectDevice(Screen parent) { public SelectDevice(Screen parent) {
super(Text.translatable("selectWorld.title")); super(Component.translatable("selectWorld.title"));
this.parent = parent; this.parent = parent;
} }
@ -47,32 +47,32 @@ public class SelectDevice extends Screen {
protected void init() { protected void init() {
//this.client.keyboard.setRepeatEvents(true); //this.client.keyboard.setRepeatEvents(true);
this.searchBox = new TextFieldWidget(this.textRenderer, this.width / 2 - 100, 22, 200, 20, this.searchBox, Text.translatable("selectWorld.search")); this.searchBox = new EditBox(this.font, this.width / 2 - 100, 22, 200, 20, this.searchBox, Component.translatable("selectWorld.search"));
this.searchBox.setChangedListener((search) -> { this.searchBox.setResponder((search) -> {
//this.levelList.filter(search); //this.levelList.filter(search);
}); });
SelectWorldScreen uwu = new SelectWorldScreen(this); SelectWorldScreen uwu = new SelectWorldScreen(this);
//this.levelList = new WorldListWidget(uwu, this.client, this.width, this.height, 48, this.height - 64, 36, this.getSearchFilter(), this.levelList); //this.levelList = new WorldListWidget(uwu, this.client, this.width, this.height, 48, this.height - 64, 36, this.getSearchFilter(), this.levelList);
this.addSelectableChild(this.searchBox); this.addWidget(this.searchBox);
this.addSelectableChild(this.levelList); this.addWidget(this.levelList);
this.selectButton = (ButtonWidget)this.addDrawableChild(ButtonWidget.builder(Text.translatable("selectWorld.select"), (button) -> { this.selectButton = (Button)this.addRenderableWidget(Button.builder(Component.translatable("selectWorld.select"), (button) -> {
this.levelList.getSelectedAsOptional().ifPresent(WorldListWidget.WorldEntry::play); this.levelList.getSelectedOpt().ifPresent(WorldSelectionList.WorldListEntry::joinWorld);
}).dimensions(this.width / 2 - 154, this.height - 52, 150, 20).build()); }).bounds(this.width / 2 - 154, this.height - 52, 150, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.translatable("selectWorld.create"), (button) -> { this.addRenderableWidget(Button.builder(Component.translatable("selectWorld.create"), (button) -> {
CreateWorldScreen.create(this.client, this); CreateWorldScreen.openFresh(this.minecraft, this);
}).dimensions(this.width / 2 + 4, this.height - 52, 150, 20).build()); }).bounds(this.width / 2 + 4, this.height - 52, 150, 20).build());
this.editButton = (ButtonWidget)this.addDrawableChild(ButtonWidget.builder(Text.translatable("selectWorld.edit"), (button) -> { this.editButton = (Button)this.addRenderableWidget(Button.builder(Component.translatable("selectWorld.edit"), (button) -> {
this.levelList.getSelectedAsOptional().ifPresent(WorldListWidget.WorldEntry::edit); this.levelList.getSelectedOpt().ifPresent(WorldSelectionList.WorldListEntry::editWorld);
}).dimensions(this.width / 2 - 154, this.height - 28, 72, 20).build()); }).bounds(this.width / 2 - 154, this.height - 28, 72, 20).build());
this.deleteButton = (ButtonWidget)this.addDrawableChild(ButtonWidget.builder(Text.translatable("selectWorld.delete"), (button) -> { this.deleteButton = (Button)this.addRenderableWidget(Button.builder(Component.translatable("selectWorld.delete"), (button) -> {
this.levelList.getSelectedAsOptional().ifPresent(WorldListWidget.WorldEntry::deleteIfConfirmed); this.levelList.getSelectedOpt().ifPresent(WorldSelectionList.WorldListEntry::deleteWorld);
}).dimensions(this.width / 2 - 76, this.height - 28, 72, 20).build()); }).bounds(this.width / 2 - 76, this.height - 28, 72, 20).build());
this.recreateButton = (ButtonWidget)this.addDrawableChild(ButtonWidget.builder(Text.translatable("selectWorld.recreate"), (button) -> { this.recreateButton = (Button)this.addRenderableWidget(Button.builder(Component.translatable("selectWorld.recreate"), (button) -> {
this.levelList.getSelectedAsOptional().ifPresent(WorldListWidget.WorldEntry::recreate); this.levelList.getSelectedOpt().ifPresent(WorldSelectionList.WorldListEntry::recreateWorld);
}).dimensions(this.width / 2 + 4, this.height - 28, 72, 20).build()); }).bounds(this.width / 2 + 4, this.height - 28, 72, 20).build());
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.CANCEL, (button) -> { this.addRenderableWidget(Button.builder(CommonComponents.GUI_CANCEL, (button) -> {
this.client.setScreen(this.parent); this.minecraft.setScreen(this.parent);
}).dimensions(this.width / 2 + 82, this.height - 28, 72, 20).build()); }).bounds(this.width / 2 + 82, this.height - 28, 72, 20).build());
this.worldSelected(false); this.worldSelected(false);
this.setInitialFocus(this.searchBox); this.setInitialFocus(this.searchBox);
} }
@ -81,27 +81,27 @@ public class SelectDevice extends Screen {
return super.keyPressed(keyCode, scanCode, modifiers) ? true : this.searchBox.keyPressed(keyCode, scanCode, modifiers); return super.keyPressed(keyCode, scanCode, modifiers) ? true : this.searchBox.keyPressed(keyCode, scanCode, modifiers);
} }
public void close() { public void onClose() {
this.client.setScreen(this.parent); this.minecraft.setScreen(this.parent);
} }
public boolean charTyped(char chr, int modifiers) { public boolean charTyped(char chr, int modifiers) {
return this.searchBox.charTyped(chr, modifiers); return this.searchBox.charTyped(chr, modifiers);
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.tooltip = null; this.tooltip = null;
//this.levelList.render(matrices, mouseX, mouseY, delta); //this.levelList.render(matrices, mouseX, mouseY, delta);
this.searchBox.render(matrices, mouseX, mouseY, delta); this.searchBox.render(matrices, mouseX, mouseY, delta);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 8, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 8, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
if (this.tooltip != null) { if (this.tooltip != null) {
this.renderOrderedTooltip(matrices, this.tooltip, mouseX, mouseY); this.renderTooltip(matrices, this.tooltip, mouseX, mouseY);
} }
} }
public void setTooltip(List<OrderedText> tooltip) { public void setTooltipForNextRenderPass(List<FormattedCharSequence> tooltip) {
this.tooltip = tooltip; this.tooltip = tooltip;
} }
@ -114,14 +114,14 @@ public class SelectDevice extends Screen {
public void removed() { public void removed() {
if (this.levelList != null) { if (this.levelList != null) {
this.levelList.children().forEach(WorldListWidget.Entry::close); this.levelList.children().forEach(WorldSelectionList.Entry::close);
} }
} }
public Supplier<String> getSearchFilter() { public Supplier<String> getSearchFilter() {
return () -> { return () -> {
return this.searchBox.getText(); return this.searchBox.getValue();
}; };
} }
} }

View file

@ -1,24 +1,24 @@
package me.jonasjones.microcraft.gui.screens.board; package me.jonasjones.microcraft.gui.screens.board;
import net.minecraft.client.gui.screen.Screen; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.text.Text; import net.minecraft.network.chat.Component;
public class AdvancedPinMappingScreen extends Screen { public class AdvancedPinMappingScreen extends Screen {
private final Screen parent; private final Screen parent;
public AdvancedPinMappingScreen(Screen parent) { public AdvancedPinMappingScreen(Screen parent) {
super(Text.of("Advanced Pin Mapping")); super(Component.nullToEmpty("Advanced Pin Mapping"));
this.parent = parent; this.parent = parent;
} }
protected void init() { protected void init() {
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices); this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
} }
} }

View file

@ -1,21 +1,21 @@
package me.jonasjones.microcraft.gui.screens.board; package me.jonasjones.microcraft.gui.screens.board;
import net.minecraft.client.gui.screen.Screen; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.text.Text; import net.minecraft.network.chat.Component;
public class AdvancedSettingsScreen extends Screen { public class AdvancedSettingsScreen extends Screen {
private final Screen parent; private final Screen parent;
public AdvancedSettingsScreen(Screen parent) { public AdvancedSettingsScreen(Screen parent) {
super(Text.of("Advanced Board Settings")); super(Component.nullToEmpty("Advanced Board Settings"));
this.parent = parent; this.parent = parent;
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices); this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
} }
} }

View file

@ -1,13 +1,13 @@
package me.jonasjones.microcraft.gui.screens.board; package me.jonasjones.microcraft.gui.screens.board;
import com.mojang.blaze3d.vertex.PoseStack;
import me.jonasjones.microcraft.Microcraft; import me.jonasjones.microcraft.Microcraft;
import me.jonasjones.microcraft.board.MicrocontrollerBoardIcon; import me.jonasjones.microcraft.board.MicrocontrollerBoardIcon;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.widget.TexturedButtonWidget; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.chat.Component;
import net.minecraft.text.Text; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Identifier;
import static me.jonasjones.microcraft.gui.widget.BoardConfigwidget.BOARD_TEXTURE; import static me.jonasjones.microcraft.gui.widget.BoardConfigwidget.BOARD_TEXTURE;
@ -15,36 +15,36 @@ public class BoardIconSelectionScreen extends Screen {
private final Screen parent; private final Screen parent;
private final MicrocontrollerBoardIcon NANO_BOARD_TEXTURE = new MicrocontrollerBoardIcon(new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-nano-sideways.png"), new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-nano.png"), 128, 52); private final MicrocontrollerBoardIcon NANO_BOARD_TEXTURE = new MicrocontrollerBoardIcon(new ResourceLocation(Microcraft.MOD_ID, "textures/boards/arduino-nano-sideways.png"), new ResourceLocation(Microcraft.MOD_ID, "textures/boards/arduino-nano.png"), 128, 52);
private final MicrocontrollerBoardIcon UNO_BOARD_TEXTURE = new MicrocontrollerBoardIcon(new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-uno-sideways.png"), new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-uno.png"), 128, 90); private final MicrocontrollerBoardIcon UNO_BOARD_TEXTURE = new MicrocontrollerBoardIcon(new ResourceLocation(Microcraft.MOD_ID, "textures/boards/arduino-uno-sideways.png"), new ResourceLocation(Microcraft.MOD_ID, "textures/boards/arduino-uno.png"), 128, 90);
private final MicrocontrollerBoardIcon PROMINI_BOARD_TEXTURE = new MicrocontrollerBoardIcon(new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-pro_mini-sideways.png"), new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-pro_mini.png"), 97, 52); private final MicrocontrollerBoardIcon PROMINI_BOARD_TEXTURE = new MicrocontrollerBoardIcon(new ResourceLocation(Microcraft.MOD_ID, "textures/boards/arduino-pro_mini-sideways.png"), new ResourceLocation(Microcraft.MOD_ID, "textures/boards/arduino-pro_mini.png"), 97, 52);
public BoardIconSelectionScreen(Screen parent) { public BoardIconSelectionScreen(Screen parent) {
super(Text.of("Select Board Icon")); super(Component.nullToEmpty("Select Board Icon"));
this.parent = parent; this.parent = parent;
} }
protected void init() { protected void init() {
this.addDrawableChild(new TexturedButtonWidget(this.width / 2 - 138, this.height / 2 - 85, NANO_BOARD_TEXTURE.width(), NANO_BOARD_TEXTURE.height(), 0, 0, 0, NANO_BOARD_TEXTURE.boardTextureHorizontal(), NANO_BOARD_TEXTURE.width(), NANO_BOARD_TEXTURE.height(), (buttonWidget) -> { this.addRenderableWidget(new ImageButton(this.width / 2 - 138, this.height / 2 - 85, NANO_BOARD_TEXTURE.width(), NANO_BOARD_TEXTURE.height(), 0, 0, 0, NANO_BOARD_TEXTURE.boardTextureHorizontal(), NANO_BOARD_TEXTURE.width(), NANO_BOARD_TEXTURE.height(), (buttonWidget) -> {
BOARD_TEXTURE = NANO_BOARD_TEXTURE; BOARD_TEXTURE = NANO_BOARD_TEXTURE;
this.client.setScreen(this.parent); this.minecraft.setScreen(this.parent);
})); }));
this.addDrawableChild(new TexturedButtonWidget(this.width / 2 - 138, this.height / 2 - 20, UNO_BOARD_TEXTURE.width(), UNO_BOARD_TEXTURE.height(), 0, 0, 0, UNO_BOARD_TEXTURE.boardTextureHorizontal(), UNO_BOARD_TEXTURE.width(), UNO_BOARD_TEXTURE.height(), (buttonWidget) -> { this.addRenderableWidget(new ImageButton(this.width / 2 - 138, this.height / 2 - 20, UNO_BOARD_TEXTURE.width(), UNO_BOARD_TEXTURE.height(), 0, 0, 0, UNO_BOARD_TEXTURE.boardTextureHorizontal(), UNO_BOARD_TEXTURE.width(), UNO_BOARD_TEXTURE.height(), (buttonWidget) -> {
BOARD_TEXTURE = UNO_BOARD_TEXTURE; BOARD_TEXTURE = UNO_BOARD_TEXTURE;
this.client.setScreen(this.parent); this.minecraft.setScreen(this.parent);
})); }));
this.addDrawableChild(new TexturedButtonWidget(this.width / 2 + 10, this.height / 2 - 85, PROMINI_BOARD_TEXTURE.width(), PROMINI_BOARD_TEXTURE.height(), 0, 0, 0, PROMINI_BOARD_TEXTURE.boardTextureHorizontal(), PROMINI_BOARD_TEXTURE.width(), PROMINI_BOARD_TEXTURE.height(), (buttonWidget) -> { this.addRenderableWidget(new ImageButton(this.width / 2 + 10, this.height / 2 - 85, PROMINI_BOARD_TEXTURE.width(), PROMINI_BOARD_TEXTURE.height(), 0, 0, 0, PROMINI_BOARD_TEXTURE.boardTextureHorizontal(), PROMINI_BOARD_TEXTURE.width(), PROMINI_BOARD_TEXTURE.height(), (buttonWidget) -> {
BOARD_TEXTURE = PROMINI_BOARD_TEXTURE; BOARD_TEXTURE = PROMINI_BOARD_TEXTURE;
this.client.setScreen(this.parent); this.minecraft.setScreen(this.parent);
})); }));
this.addDrawableChild(ButtonWidget.builder(Text.of("Cancel"), (button) -> { this.addRenderableWidget(Button.builder(Component.nullToEmpty("Cancel"), (button) -> {
this.client.setScreen(this.parent); this.minecraft.setScreen(this.parent);
}).dimensions(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build()); }).bounds(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build());
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices); this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
} }
} }

View file

@ -1,11 +1,10 @@
package me.jonasjones.microcraft.gui.screens.board; package me.jonasjones.microcraft.gui.screens.board;
import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.chat.Component;
import net.minecraft.text.Text;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class ProfileSelectionScreen extends Screen { public class ProfileSelectionScreen extends Screen {
@ -13,13 +12,13 @@ public class ProfileSelectionScreen extends Screen {
private final Screen parent; private final Screen parent;
public ProfileSelectionScreen(Screen parent) { public ProfileSelectionScreen(Screen parent) {
super(Text.of("Profile Selection Screen")); super(Component.nullToEmpty("Profile Selection Screen"));
this.parent = parent; this.parent = parent;
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices); this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
} }
} }

View file

@ -1,21 +1,21 @@
package me.jonasjones.microcraft.gui.screens.board; package me.jonasjones.microcraft.gui.screens.board;
import com.mojang.blaze3d.vertex.PoseStack;
import me.jonasjones.microcraft.gui.screens.ModSettings; import me.jonasjones.microcraft.gui.screens.ModSettings;
import me.jonasjones.microcraft.gui.screens.SelectDevice; import me.jonasjones.microcraft.gui.screens.SelectDevice;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.chat.CommonComponents;
import net.minecraft.screen.ScreenTexts; import net.minecraft.network.chat.Component;
import net.minecraft.text.Text;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class TextureSelectScreen extends Screen { public class TextureSelectScreen extends Screen {
private final Screen parent; private final Screen parent;
public TextureSelectScreen(Screen parent) { public TextureSelectScreen(Screen parent) {
super(Text.of("Microcraft Configuration")); super(Component.nullToEmpty("Microcraft Configuration"));
this.parent = parent; this.parent = parent;
} }
protected void init() { protected void init() {
@ -33,23 +33,23 @@ public class TextureSelectScreen extends Screen {
})); }));
this.addDrawableChild(new net.minecraft.client.gui.widget.CheckboxWidget(50, 50, 100, 20, Text.of("uwu checkbox"), false));*/ this.addDrawableChild(new net.minecraft.client.gui.widget.CheckboxWidget(50, 50, 100, 20, Text.of("uwu checkbox"), false));*/
this.addDrawableChild(ButtonWidget.builder(Text.of("Configure Microcontrollers"),(button) -> { this.addRenderableWidget(Button.builder(Component.nullToEmpty("Configure Microcontrollers"),(button) -> {
this.client.setScreen(new SelectDevice(this)); this.minecraft.setScreen(new SelectDevice(this));
}).dimensions(this.width / 2 - 155, this.height / 6 + 12, 150, 20).build()); }).bounds(this.width / 2 - 155, this.height / 6 + 12, 150, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.of("Configure Microcraft"), (button) -> { this.addRenderableWidget(Button.builder(Component.nullToEmpty("Configure Microcraft"), (button) -> {
this.client.setScreen(new ModSettings(this)); this.minecraft.setScreen(new ModSettings(this));
}).dimensions(this.width / 2 + 5, this.height / 6 + 12, 150, 20).build()); }).bounds(this.width / 2 + 5, this.height / 6 + 12, 150, 20).build());
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> { this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> {
this.client.setScreen(this.parent); this.minecraft.setScreen(this.parent);
}).dimensions(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build()); }).bounds(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build());
this.addDrawableChild(new net.minecraft.client.gui.widget.CheckboxWidget(50, 50, 100, 20, Text.of("uwu checkbox"), false)); this.addRenderableWidget(new net.minecraft.client.gui.components.Checkbox(50, 50, 100, 20, Component.nullToEmpty("uwu checkbox"), false));
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices); this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
} }
} }

View file

@ -5,6 +5,7 @@
package me.jonasjones.microcraft.gui.widget; package me.jonasjones.microcraft.gui.widget;
import com.mojang.blaze3d.vertex.PoseStack;
import me.jonasjones.microcraft.Microcraft; import me.jonasjones.microcraft.Microcraft;
import me.jonasjones.microcraft.board.MicrocontrollerBoardIcon; import me.jonasjones.microcraft.board.MicrocontrollerBoardIcon;
import me.jonasjones.microcraft.gui.screens.ModCreditsScreen; import me.jonasjones.microcraft.gui.screens.ModCreditsScreen;
@ -17,15 +18,9 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ImageButton; import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TexturedButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class BoardConfigwidget extends Screen { public class BoardConfigwidget extends Screen {
@ -55,25 +50,25 @@ public class BoardConfigwidget extends Screen {
this.addRenderableWidget(ButtonWidget.builder(Component.literal("Microcraft Settings"), (buttonWidget) -> this.minecraft.setScreen(new ModSettings(this))).dimensions(this.width - 210, this.height - 55, 200, 20).build());*/ this.addRenderableWidget(ButtonWidget.builder(Component.literal("Microcraft Settings"), (buttonWidget) -> this.minecraft.setScreen(new ModSettings(this))).dimensions(this.width - 210, this.height - 55, 200, 20).build());*/
this.addRenderableWidget(new Button.Builder(Component.literal("About"), (buttonWidget) -> this.minecraft.setScreen(new ModCreditsScreen(this))) this.addRenderableWidget(new Button.Builder(Component.literal("About"), (buttonWidget) -> this.minecraft.setScreen(new ModCreditsScreen(this)))
.dimensions(this.width / 2 - 154, this.height - 28, 75, 20).build()); .bounds(this.width / 2 - 154, this.height - 28, 75, 20).build());
this.addRenderableWidget(new Button.Builder(Component.literal("Pin Mapping"), (buttonWidget) -> this.minecraft.setScreen(new AdvancedPinMappingScreen(this))) this.addRenderableWidget(new Button.Builder(Component.literal("Pin Mapping"), (buttonWidget) -> this.minecraft.setScreen(new AdvancedPinMappingScreen(this)))
.dimensions(this.width / 2 + 4 + 50, this.height - 52, 100, 20).build()); .bounds(this.width / 2 + 4 + 50, this.height - 52, 100, 20).build());
this.addRenderableWidget(new Button.Builder(Component.literal("Board Settings"), (buttonWidget) -> this.minecraft.setScreen(new AdvancedSettingsScreen(this))) this.addRenderableWidget(new Button.Builder(Component.literal("Board Settings"), (buttonWidget) -> this.minecraft.setScreen(new AdvancedSettingsScreen(this)))
.dimensions(this.width / 2 - 154, this.height - 52, 100, 20).build()); .bounds(this.width / 2 - 154, this.height - 52, 100, 20).build());
this.addRenderableWidget(new Button.Builder(Component.literal("Done"), (buttonWidget) -> this.minecraft.setScreen(this.parent)) this.addRenderableWidget(new Button.Builder(Component.literal("Done"), (buttonWidget) -> this.minecraft.setScreen(this.parent))
.dimensions(this.width / 2 + 4 + 76, this.height - 28, 75, 20).build()); .bounds(this.width / 2 + 4 + 76, this.height - 28, 75, 20).build());
ButtonWidget upload = this.addRenderableWidget(new Button.Builder(Component.literal("Upload"), (buttonWidget) -> this.minecraft.setScreen(this.parent)) Button upload = this.addRenderableWidget(new Button.Builder(Component.literal("Upload"), (buttonWidget) -> this.minecraft.setScreen(this.parent))
.dimensions(this.width / 2, this.height - 28, 75, 20).build()); .bounds(this.width / 2, this.height - 28, 75, 20).build());
upload.active = false; upload.active = false;
this.addRenderableWidget(new Button.Builder(Component.literal("Settings"), (buttonWidget) -> this.minecraft.setScreen(new ModSettings(this))) this.addRenderableWidget(new Button.Builder(Component.literal("Settings"), (buttonWidget) -> this.minecraft.setScreen(new ModSettings(this)))
.dimensions(this.width / 2 - 75, this.height - 28, 70, 20).build()); .bounds(this.width / 2 - 75, this.height - 28, 70, 20).build());
} }
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices); this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215); drawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 16777215);
super.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta);
} }