Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
plugins {
id 'fabric-loom' version '0.4-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.mod_version

repositories {
maven {
url "https://maven.shedaniel.me/"
}
maven {
url "https://raw.githubusercontent.com/TerraformersMC/Archive/main/releases/"
}
}

dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand All @@ -18,9 +27,9 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modApi "me.sargunvohra.mcmods:autoconfig1u:3.2.0-unstable"
modImplementation "io.github.prospector:modmenu:1.14.6+build.31"
modApi ("me.shedaniel.cloth:config-2:4.7.0-unstable") {
modApi "me.sargunvohra.mcmods:autoconfig1u:3.3.1"
modImplementation "com.terraformersmc:modmenu:2.0.2"
modApi ("me.shedaniel.cloth:cloth-config-fabric:5.0.34") {
exclude(group: "net.fabricmc.fabric-api")
}
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
Expand All @@ -30,29 +39,27 @@ dependencies {
processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
filesMatching("fabric.mod.json") {
expand "version": project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

// Minecraft 1.17 (21w19a) upwards uses Java 16.
it.options.release = 16
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}

ext {
Expand Down
13 changes: 6 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.2
yarn_mappings=1.16.2+build.1
loader_version=0.9.1+build.205
minecraft_version=1.17
yarn_mappings=1.17+build.13
loader_version=0.11.6

# Mod Properties
mod_version = 3.9.3
archives_base_name = ReAuth-1.16-Fabric
mod_version = 3.10.0
archives_base_name = ReAuth-1.17-Fabric

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.19.0+build.398-1.16
fabric_version=0.36.0+1.17
3 changes: 1 addition & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
Expand All @@ -9,4 +8,4 @@ pluginManagement {
}
}

rootProject.name='ReAuth Fabric 1.16'
rootProject.name='ReAuth Fabric 1.17'
18 changes: 9 additions & 9 deletions src/main/java/technicianlp/reauth/gui/AuthScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,30 @@ public void init() {
this.username = new TextFieldWidget(this.textRenderer, this.width / 2 - 155, this.baseY + 15, 2 * 155, 20, new TranslatableText("reauth.gui.auth.username"));
this.username.setMaxLength(512);
this.username.setText(ReAuth.config.getUsername());
addButton(username);
addDrawableChild(username);

this.pw = new PasswordFieldWidget(this.textRenderer, this.width / 2 - 155, this.baseY + 60, 2 * 155, 20, new TranslatableText("reauth.gui.auth.password"));
this.pw.setMaxLength(Short.MAX_VALUE);
this.pw.setText(ReAuth.config.getPassword());
addButton(this.pw);
addDrawableChild(this.pw);

setInitialFocus(username.getText().isEmpty() ? username : pw);

this.save = new CheckboxWidget(this.width / 2 - 155, this.baseY + 85, 2 * 155, 20, new TranslatableText("reauth.gui.auth.checkbox"), !pw.getText().isEmpty());
if (ReAuth.config.hasCrypto()) {
addButton(this.save);
addDrawableChild(this.save);
}

this.confirm = new ButtonWidget(this.width / 2 - 155, this.baseY + 110, 153, 20, LiteralText.EMPTY, b -> doLogin());
addButton(confirm);
addDrawableChild(confirm);
this.cancel = new ButtonWidget(this.width / 2 + 2, this.baseY + 110, 155, 20, new TranslatableText("gui.cancel"), b -> this.client.openScreen(prev));
addButton(cancel);
addDrawableChild(cancel);

this.config = new ButtonWidget(this.width - 80, this.height - 25, 75, 20, new TranslatableText("reauth.gui.auth.config"), b -> {
this.client.openScreen(ClothConfigIntegration.getConfigScreen(this));
});
if (ClothConfigIntegration.isAvailable()) {
addButton(config);
addDrawableChild(config);
}

if (message.isEmpty() && ReAuth.versionCheck.getStatus() == VersionChecker.Status.OUTDATED) {
Expand Down Expand Up @@ -115,9 +115,9 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTi
private void focus(TextFieldWidget widget) {
Element old = getFocused();
if (old instanceof TextFieldWidget)
((TextFieldWidget) old).setSelected(false);
((TextFieldWidget) old).setTextFieldFocused(false);
if (widget != null)
widget.setSelected(true);
widget.setTextFieldFocused(true);
focusOn(widget);
}

Expand Down Expand Up @@ -232,6 +232,6 @@ public String getTranslation() {
* the superclass method changes from instance to static between 1.16.1 and 1.16.2
*/
private void drawCenteredString2(MatrixStack matrices, TextRenderer textRenderer, String text, int centerX, int y, int color) {
textRenderer.drawWithShadow(matrices, text, (float)(centerX - textRenderer.getWidth(text) / 2), (float)y, color);
textRenderer.drawWithShadow(matrices, text, (float) (centerX - textRenderer.getWidth(text) / 2), (float) y, color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DisconnectedScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -26,6 +26,9 @@ protected DisconnectedScreenMixin() {
super(new LiteralText("Dummy Constructor"));
}

@Shadow
private int reasonHeight;

@Override
@Accessor("reason")
public abstract Text reauthGetReason();
Expand All @@ -38,18 +41,19 @@ protected DisconnectedScreenMixin() {
private void reauthInit(CallbackInfo info) {
if ("connect.failed".equals(getTranslationKey(this.getTitle()))) {
if (getTranslationKey(reauthGetReason()).startsWith("disconnect.loginFailed")) {
AbstractButtonWidget menu = this.buttons.get(0);
int x = this.width / 2 - 100;
int y = this.height / 2 + this.reasonHeight / 2;

String key = DisconnectUtil.canRetryLogin() ? "reauth.retry" : "reauth.retry.disabled";
Text retryText = new TranslatableText(key, ReAuth.config.getProfile());
ButtonWidget retryButton = new ButtonWidget(menu.x, menu.y + 25, 200, 20, retryText, b -> {
ButtonWidget retryButton = new ButtonWidget(x, y + 25, 200, 20, retryText, b -> {
DisconnectUtil.retryLogin();
});
if (!DisconnectUtil.canRetryLogin()) {
retryButton.active = false;
}
this.addButton(retryButton);
this.addButton(new ButtonWidget(menu.x, menu.y + 50, 200, 20, new TranslatableText("reauth.open"), b -> {
this.addDrawableChild(retryButton);
this.addDrawableChild(new ButtonWidget(x, y + 50, 200, 20, new TranslatableText("reauth.open"), b -> {
MinecraftClient.getInstance().openScreen(new AuthScreen(reauthGetParent()));
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private void reauthInit(CallbackInfo info) {
if(Screen.hasShiftDown()) {
ReAuth.auth.getSessionStatus(true);
}
addButton(new ButtonWidget(5, 5, 100, 20, new TranslatableText("reauth.gui.button"),
addDrawableChild(new ButtonWidget(5, 5, 100, 20, new TranslatableText("reauth.gui.button"),
b -> MinecraftClient.getInstance().openScreen(new AuthScreen(this))));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.text.TranslatableText;
import technicianlp.reauth.ReAuth;
Expand Down Expand Up @@ -35,10 +36,10 @@ public static void retryLogin() {
ReAuth.auth.login(ReAuth.config.getUsername(), ReAuth.config.getPassword(), true);
if (screen != null) {
SocketAddress add = screen.reauthGetConnection().getAddress();
if (add instanceof InetSocketAddress) {
InetSocketAddress address = (InetSocketAddress) add;
if (add instanceof InetSocketAddress address) {
MinecraftClient client = MinecraftClient.getInstance();
client.openScreen(new ConnectScreen(screen.reauthGetParent(), client, address.getHostString(), address.getPort()));
ServerAddress serverAddress = new ServerAddress(address.getHostString(), address.getPort());
ConnectScreen.connect(screen.reauthGetParent(), client, serverAddress, null);
}
}
} catch (AuthenticationException exception) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": "1.16.*",
"minecraft": "1.17.*",
"autoconfig1u": "*"
},
"recommends": {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/reauth.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "technicianlp.reauth.mixin",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_16",
"mixins": [],
"client": [
"MultiplayerScreenMixin",
Expand Down