Skip to content

Commit 8821d7e

Browse files
authored
Merge pull request #3 from LucilleTea/1.16
Port to 1.16
2 parents 299333d + 1973cfd commit 8821d7e

File tree

4 files changed

+28
-31
lines changed

4 files changed

+28
-31
lines changed

build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '0.2.6-SNAPSHOT'
2+
id 'fabric-loom' version '0.5-SNAPSHOT'
33
id 'maven-publish'
44
}
55

@@ -29,9 +29,6 @@ dependencies {
2929
// You may need to force-disable transitivity on them.
3030
//modCompile "com.jamieswhiteshirt:developer-mode:${project.developer_mode_version}"
3131
modCompile "io.github.prospector:modmenu:${project.mod_menu_version}"
32-
33-
// Nullability Annotations
34-
implementation "com.google.code.findbugs:jsr305:${project.findbugs_version}"
3532
}
3633

3734
processResources {

gradle.properties

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
55
# check these on https://fabricmc.net/use
6-
minecraft_version=1.15.2
7-
yarn_mappings=1.15.2+build.7
8-
loader_version=0.7.6+build.179
6+
minecraft_version=1.16.4
7+
yarn_mappings=1.16.4+build.7
8+
loader_version=0.10.8
99

1010
# Mod Properties
1111
mod_version = 1.0.3
@@ -14,9 +14,7 @@ org.gradle.jvmargs=-Xmx1G
1414

1515
# Dependencies
1616
# https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/
17-
fabric_version=0.4.29+build.290-1.15
17+
fabric_version=0.27.1+1.16
1818

1919
developer_mode_version=1.0.15
20-
mod_menu_version=1.8.5+build.23
21-
22-
findbugs_version=3.0.2
20+
mod_menu_version=1.14.13+build.19

src/main/java/resolutioncontrol/ResolutionControlMod.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
import net.minecraft.client.util.InputUtil;
1010
import net.minecraft.client.util.Window;
1111
import net.minecraft.util.Identifier;
12+
import org.jetbrains.annotations.Nullable;
1213
import org.lwjgl.glfw.GLFW;
1314
import resolutioncontrol.client.gui.screen.SettingsScreen;
1415
import resolutioncontrol.util.*;
1516

16-
import javax.annotation.Nullable;
17-
import javax.annotation.ParametersAreNonnullByDefault;
1817

19-
@ParametersAreNonnullByDefault
18+
2019
public class ResolutionControlMod implements ModInitializer {
2120
public static final String MOD_ID = "resolutioncontrol";
2221

@@ -35,7 +34,7 @@ public static ResolutionControlMod getInstance() {
3534
private static FabricKeyBinding settingsKeyBinding = FabricKeyBinding.Builder.create(
3635
identifier("settings"),
3736
InputUtil.Type.KEYSYM,
38-
GLFW.GLFW_KEY_P,
37+
GLFW.GLFW_KEY_O,
3938
"key.categories.misc"
4039
).build();
4140

src/main/java/resolutioncontrol/client/gui/screen/SettingsScreen.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
import net.minecraft.client.gui.screen.Screen;
66
import net.minecraft.client.gui.widget.ButtonWidget;
77
import net.minecraft.client.resource.language.I18n;
8+
import net.minecraft.client.util.math.MatrixStack;
9+
import net.minecraft.text.LiteralText;
810
import net.minecraft.text.Text;
911
import net.minecraft.text.TranslatableText;
1012
import net.minecraft.util.Identifier;
13+
import org.jetbrains.annotations.Nullable;
1114
import resolutioncontrol.ResolutionControlMod;
1215

13-
import javax.annotation.Nullable;
1416

1517
public final class SettingsScreen extends Screen {
1618
private static final Identifier backgroundTexture = ResolutionControlMod.identifier("textures/gui/settings.png");
@@ -62,59 +64,60 @@ protected void init() {
6264
decreaseButton = new ButtonWidget(
6365
centerX - buttonOffset - buttonSize / 2, buttonY,
6466
buttonSize, buttonSize,
65-
"-",
67+
new LiteralText("-"),
6668
button -> changeScaleFactor(-1));
6769
addButton(decreaseButton);
6870

6971
increaseButton = new ButtonWidget(
7072
centerX + buttonOffset - buttonSize / 2, buttonY,
7173
buttonSize, buttonSize,
72-
"+",
74+
new LiteralText("+"),
7375
button -> changeScaleFactor(+1)
7476
);
7577
addButton(increaseButton);
7678

7779
doneButton = new ButtonWidget(
7880
centerX - 100 / 2, startY + containerHeight - 10 - 20,
7981
100, buttonSize,
80-
I18n.translate("gui.done"),
81-
button -> minecraft.openScreen(parent)
82+
new TranslatableText("gui.done"),
83+
button -> client.openScreen(parent)
8284
);
8385
addButton(doneButton);
8486

8587
updateButtons();
8688
}
8789

8890
@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;
9193

92-
if (minecraft.world == null) {
93-
renderDirtBackground(0);
94+
if (client.world == null) {
95+
renderBackgroundTexture(0);
9496
}
9597

9698
GlStateManager.enableAlphaTest();
97-
minecraft.getTextureManager().bindTexture(backgroundTexture);
99+
client.getTextureManager().bindTexture(backgroundTexture);
98100
GlStateManager.color4f(1, 1, 1, 1);
99101

100102
int textureWidth = 256;
101103
int textureHeight = 192;
102-
blit(
104+
drawTexture(
105+
matrices,
103106
centerX - textureWidth / 2, centerY - textureHeight / 2,
104107
0, 0,
105108
textureWidth, textureHeight
106109
);
107110

108-
drawCenteredString(getTitle().asFormattedString(), centerX, startY + 10, 0x404040);
111+
drawCenteredString(matrices, getTitle().getString(), centerX, startY + 10, 0x404040);
109112

110113
Text scaleFactor = text("current", mod.getScaleFactor());
111-
drawCenteredString(scaleFactor.asFormattedString(), centerX, centerY - 20, 0x000000);
114+
drawCenteredString(matrices, scaleFactor.getString(), centerX, centerY - 20, 0x000000);
112115

113-
super.render(mouseX, mouseY, time); // buttons
116+
super.render(matrices, mouseX, mouseY, time); // buttons
114117
}
115118

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);
118121
}
119122

120123
private void changeScaleFactor(int change) {

0 commit comments

Comments
 (0)