|
5 | 5 | import net.minecraft.client.gui.screen.Screen; |
6 | 6 | import net.minecraft.client.gui.widget.ButtonWidget; |
7 | 7 | import net.minecraft.client.resource.language.I18n; |
| 8 | +import net.minecraft.client.util.math.MatrixStack; |
| 9 | +import net.minecraft.text.LiteralText; |
8 | 10 | import net.minecraft.text.Text; |
9 | 11 | import net.minecraft.text.TranslatableText; |
10 | 12 | import net.minecraft.util.Identifier; |
| 13 | +import org.jetbrains.annotations.Nullable; |
11 | 14 | import resolutioncontrol.ResolutionControlMod; |
12 | 15 |
|
13 | | -import javax.annotation.Nullable; |
14 | 16 |
|
15 | 17 | public final class SettingsScreen extends Screen { |
16 | 18 | private static final Identifier backgroundTexture = ResolutionControlMod.identifier("textures/gui/settings.png"); |
@@ -62,59 +64,60 @@ protected void init() { |
62 | 64 | decreaseButton = new ButtonWidget( |
63 | 65 | centerX - buttonOffset - buttonSize / 2, buttonY, |
64 | 66 | buttonSize, buttonSize, |
65 | | - "-", |
| 67 | + new LiteralText("-"), |
66 | 68 | button -> changeScaleFactor(-1)); |
67 | 69 | addButton(decreaseButton); |
68 | 70 |
|
69 | 71 | increaseButton = new ButtonWidget( |
70 | 72 | centerX + buttonOffset - buttonSize / 2, buttonY, |
71 | 73 | buttonSize, buttonSize, |
72 | | - "+", |
| 74 | + new LiteralText("+"), |
73 | 75 | button -> changeScaleFactor(+1) |
74 | 76 | ); |
75 | 77 | addButton(increaseButton); |
76 | 78 |
|
77 | 79 | doneButton = new ButtonWidget( |
78 | 80 | centerX - 100 / 2, startY + containerHeight - 10 - 20, |
79 | 81 | 100, buttonSize, |
80 | | - I18n.translate("gui.done"), |
81 | | - button -> minecraft.openScreen(parent) |
| 82 | + new TranslatableText("gui.done"), |
| 83 | + button -> client.openScreen(parent) |
82 | 84 | ); |
83 | 85 | addButton(doneButton); |
84 | 86 |
|
85 | 87 | updateButtons(); |
86 | 88 | } |
87 | 89 |
|
88 | 90 | @Override |
89 | | - public void render(int mouseX, int mouseY, float time) { |
90 | | - assert minecraft != null; |
| 91 | + public void render(MatrixStack matrices, int mouseX, int mouseY, float time) { |
| 92 | + assert client != null; |
91 | 93 |
|
92 | | - if (minecraft.world == null) { |
93 | | - renderDirtBackground(0); |
| 94 | + if (client.world == null) { |
| 95 | + renderBackgroundTexture(0); |
94 | 96 | } |
95 | 97 |
|
96 | 98 | GlStateManager.enableAlphaTest(); |
97 | | - minecraft.getTextureManager().bindTexture(backgroundTexture); |
| 99 | + client.getTextureManager().bindTexture(backgroundTexture); |
98 | 100 | GlStateManager.color4f(1, 1, 1, 1); |
99 | 101 |
|
100 | 102 | int textureWidth = 256; |
101 | 103 | int textureHeight = 192; |
102 | | - blit( |
| 104 | + drawTexture( |
| 105 | + matrices, |
103 | 106 | centerX - textureWidth / 2, centerY - textureHeight / 2, |
104 | 107 | 0, 0, |
105 | 108 | textureWidth, textureHeight |
106 | 109 | ); |
107 | 110 |
|
108 | | - drawCenteredString(getTitle().asFormattedString(), centerX, startY + 10, 0x404040); |
| 111 | + drawCenteredString(matrices, getTitle().getString(), centerX, startY + 10, 0x404040); |
109 | 112 |
|
110 | 113 | Text scaleFactor = text("current", mod.getScaleFactor()); |
111 | | - drawCenteredString(scaleFactor.asFormattedString(), centerX, centerY - 20, 0x000000); |
| 114 | + drawCenteredString(matrices, scaleFactor.getString(), centerX, centerY - 20, 0x000000); |
112 | 115 |
|
113 | | - super.render(mouseX, mouseY, time); // buttons |
| 116 | + super.render(matrices, mouseX, mouseY, time); // buttons |
114 | 117 | } |
115 | 118 |
|
116 | | - private void drawCenteredString(String text, int x, int y, int color) { |
117 | | - font.draw(text, x - font.getStringWidth(text) / 2, y, color); |
| 119 | + private void drawCenteredString(MatrixStack matrices, String text, int x, int y, int color) { |
| 120 | + textRenderer.draw(matrices, text, x - textRenderer.getWidth(text) / 2, y, color); |
118 | 121 | } |
119 | 122 |
|
120 | 123 | private void changeScaleFactor(int change) { |
|
0 commit comments