]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blobdiff - src/main/java/com/irtimaled/bbor/client/gui/ListScreen.java
Get 1.17.1 building
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / gui / ListScreen.java
index 7e6e9bbd6ff32687323635440ada22fc0ca8d506..d97b546182b179b2e5bef69da6983292f38b17ed 100644 (file)
@@ -2,10 +2,13 @@ package com.irtimaled.bbor.client.gui;
 
 import com.irtimaled.bbor.Versions;
 import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.gui.IGuiEventListener;
+import net.minecraft.client.gui.Element;
 import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.util.text.StringTextComponent;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.text.LiteralText;
+
+import java.util.List;
 
 public abstract class ListScreen extends Screen {
     private final Screen lastScreen;
@@ -16,7 +19,7 @@ public abstract class ListScreen extends Screen {
     private SearchField searchField;
 
     ListScreen(Screen lastScreen) {
-        super(new StringTextComponent("Bounding Box Outline Reloaded"));
+        super(new LiteralText("Bounding Box Outline Reloaded"));
         this.lastScreen = lastScreen;
     }
 
@@ -31,36 +34,36 @@ public abstract class ListScreen extends Screen {
     @Override
     protected void init() {
         this.controlList = this.buildList(48, this.height - 28);
-        this.searchField = new SearchField(this.font, this.width / 2 - 100, 22, 200, 20, this.controlList);
-        this.doneButton = new AbstractButton(this.width / 2 - 100, this.height - 24, 200, I18n.format("gui.done")) {
+        this.searchField = new SearchField(this.textRenderer, this.width / 2 - 100, 22, 200, 20, this.controlList);
+        this.doneButton = new AbstractButton(this.width / 2 - 100, this.height - 24, 200, I18n.translate("gui.done")) {
             @Override
             public void onPressed() {
                 onDoneClicked();
             }
         };
 
-        this.children.add(this.searchField);
-        this.children.add(this.controlList);
-        this.children.add(this.doneButton);
+        this.addDrawableChild(this.searchField);
+        ((List<Element>)this.children()).add(controlList);
+        this.addDrawableChild(this.doneButton);
     }
 
     protected abstract ControlList buildList(int top, int bottom);
 
     @Override
-    public void render(int mouseX, int mouseY, float unknown) {
-        render(mouseX, mouseY);
+    public void render(MatrixStack matrixStack, int mouseX, int mouseY, float unknown) {
+        render(matrixStack, mouseX, mouseY);
     }
 
-    protected void render(int mouseX, int mouseY) {
-        this.controlList.render(mouseX, mouseY);
+    protected void render(MatrixStack matrixStack, int mouseX, int mouseY) {
+        this.controlList.render(matrixStack, mouseX, mouseY);
 
-        this.drawCenteredString(this.font, this.title.getUnformattedComponentText(), this.width / 2, 8, 16777215);
-        this.searchField.render(mouseX, mouseY);
-        this.doneButton.render(mouseX, mouseY);
+        this.drawCenteredText(matrixStack, this.textRenderer, this.title.asString(), this.width / 2, 8, 16777215);
+        this.searchField.render(matrixStack, mouseX, mouseY);
+        this.doneButton.render(matrixStack, mouseX, mouseY);
 
-        int left = this.width - this.font.getStringWidth(version) - 2;
+        int left = this.width - this.textRenderer.getWidth(version) - 2;
         int top = this.height - 10;
-        this.drawString(this.font, version, left, top, -10658467);
+        this.drawStringWithShadow(matrixStack, this.textRenderer, version, left, top, -10658467);
     }
 
     @Override
@@ -94,9 +97,9 @@ public abstract class ListScreen extends Screen {
 
     @Override
     public boolean mouseClicked(double mouseX, double mouseY, int button) {
-        for (IGuiEventListener control : this.children()) {
+        for (Element control : this.children()) {
             if (control.mouseClicked(mouseX, mouseY, button)) {
-                IGuiEventListener focused = getFocused();
+                Element focused = getFocused();
                 if (focused instanceof IFocusableControl && focused != control) {
                     ((IFocusableControl) focused).clearFocus();
                 }