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
17 changes: 7 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
plugins {
id 'eclipse'
id 'net.minecraftforge.gradle' version '5.1.+'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
}

version = "${Major}.${Patch}"
group = "${Author}"
archivesBaseName = "${ModName}-${MCVersion}-Forge"

base {
archivesName = "${ModName}-${MCVersion}-Forge"
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println "Java: ${System.getProperty "java.version"}, JVM: ${System.getProperty "java.vm.version"} (${System.getProperty "java.vendor"}), Arch: ${System.getProperty "os.arch"}"
minecraft {
// mappings channel: "parchment", version: "1.18.1-2022.03.06-1.18.2"
mappings channel: 'official', version: '1.19.3'
mappings channel: 'official', version: '1.20.1'

runs {
client {
Expand Down Expand Up @@ -41,7 +43,7 @@ sourceSets {
sourceSets.main.resources { srcDir "src/generated/resources" }

dependencies {
minecraft 'net.minecraftforge:forge:1.19.3-44.1.16'
minecraft 'net.minecraftforge:forge:1.20.1-47.2.0'
implementation "org.jetbrains:annotations:16.0.2"
}

Expand All @@ -58,8 +60,3 @@ jar {
])
}
}

ext {
autoSignProfile = "reauth"
autoSignTarget = tasks.jar.archivePath
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

MCVersion=1.19
MCVersion=1.20.1

Major=4.0
Patch=7
Major=4.1
Patch=0
Author=TechnicianLP
ModID=reauth
ModName=ReAuth
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ pluginManagement {
}
}

rootProject.name='ReAuth Forge 1.19'
rootProject.name = 'ReAuth Forge 1.20.1'
6 changes: 2 additions & 4 deletions src/main/java/technicianlp/reauth/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
public final class EventHandler {

private static final Field disconnectMessage = ReflectionUtils.findObfuscatedField(DisconnectedScreen.class, "f_95988_", "reason");
private static final Field widgetX = ReflectionUtils.findObfuscatedField(AbstractWidget.class, "f_93620_", "x");
private static final Field widgetY = ReflectionUtils.findObfuscatedField(AbstractWidget.class, "f_93621_", "y");

@SubscribeEvent
public static void onInitGui(ScreenEvent.Init.Post event) {
Expand Down Expand Up @@ -61,7 +59,7 @@ private static void handleDisconnectScreen(ScreenEvent.Init.Post event, Screen s
} else {
retryText = Component.translatable("reauth.retry.disabled");
}
Button retryButton = ReAuth.buttonFactory.createButton(ReflectionUtils.getField(widgetX, menu), ReflectionUtils.<Integer>getField(widgetY, menu) + 25, 200, 20, retryText, b -> ReconnectHelper.retryLogin(profile));
Button retryButton = ReAuth.buttonFactory.createButton(menu.getX(), menu.getY() + 25, 200, 20, retryText, b -> ReconnectHelper.retryLogin(profile));
if (profile == null || !ReconnectHelper.hasConnectionInfo()) {
retryButton.active = false;
}
Expand All @@ -79,7 +77,7 @@ public static void onDrawGui(ScreenEvent.Render.Post e) {
if (e.getScreen() instanceof JoinMultiplayerScreen) {
User user = Minecraft.getInstance().getUser();
SessionStatus state = SessionChecker.getSessionStatus(user.getAccessToken(), user.getUuid());
Minecraft.getInstance().font.drawShadow(e.getPoseStack(), I18n.get(state.getTranslationKey()), 110, 10, 0xFFFFFFFF);
e.getGuiGraphics().drawString(Minecraft.getInstance().font, I18n.get(state.getTranslationKey()), 110, 10, 0xFFFFFFFF);
}
}

Expand Down
9 changes: 1 addition & 8 deletions src/main/java/technicianlp/reauth/ReAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,7 @@ public final class ReAuth {
profiles = config.getProfileList();
i18n = I18n::get;

ButtonFactory factory;
try {
factory = new ButtonFactory.ButtonFactoryMc19();
} catch (ReflectiveOperationException e) {
log.info("Button constructor not found - using 1.19.3 Builder instead");
factory = new ButtonFactory.ButtonFactoryMc19_3();
}
buttonFactory = factory;
buttonFactory = new ButtonFactory();
} else {
config = null;
profiles = null;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/technicianlp/reauth/ReconnectHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.ConnectScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.resolver.ServerAddress;
import net.minecraft.network.Connection;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -65,7 +66,7 @@ private static void connect() {
if (add instanceof InetSocketAddress address) {
Minecraft minecraft = Minecraft.getInstance();
ServerAddress server = new ServerAddress(address.getHostString(), address.getPort());
ConnectScreen.startConnecting(ReflectionUtils.getField(previousField, screen), minecraft, server, minecraft.getCurrentServer());
ConnectScreen.startConnecting(ReflectionUtils.<Screen>getField(previousField, screen), minecraft, server, minecraft.getCurrentServer(), false);
}
}
}
Expand Down
39 changes: 7 additions & 32 deletions src/main/java/technicianlp/reauth/gui/AbstractScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
import technicianlp.reauth.ReAuth;
import technicianlp.reauth.util.ReflectionUtils;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;

abstract class AbstractScreen extends Screen {

private static MethodHandle renderSuper = null;
static final int BUTTON_WIDTH = 196;

private final String title;
Expand Down Expand Up @@ -51,35 +45,16 @@ public void init() {
}

@Override
public final void render(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(poseStack, mouseX, mouseY, partialTicks);

super.render(poseStack, mouseX, mouseY, partialTicks);

this.font.drawShadow(poseStack, I18n.get(this.title), this.centerX - (BUTTON_WIDTH / 2f), this.baseY + 8, 0xFFFFFFFF);
}
public final void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(graphics, mouseX, mouseY, partialTicks);

/**
* Render Method pre 1.19.3. Call to super via MethodHandle
*/
public final void m_6305_(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) throws Throwable {
this.renderBackground(poseStack, mouseX, mouseY, partialTicks);

try {
if (renderSuper == null) {
MethodType signature = MethodType.methodType(void.class, PoseStack.class, int.class, int.class, float.class);
renderSuper = MethodHandles.lookup().findSpecial(Screen.class, "m_6305_", signature, AbstractScreen.class);
}
renderSuper.invoke(this, poseStack, mouseX, mouseY, partialTicks);
} catch (ReflectiveOperationException e) {
throw new ReflectionUtils.UncheckedReflectiveOperationException("Unable to call super.render (m_6305_)", e);
}
super.render(graphics, mouseX, mouseY, partialTicks);

this.font.drawShadow(poseStack, I18n.get(this.title), this.centerX - (BUTTON_WIDTH / 2f), this.baseY + 8, 0xFFFFFFFF);
graphics.drawString(this.font, I18n.get(this.title), this.centerX - BUTTON_WIDTH / 2, this.baseY + 8, 0xFFFFFFFF);
}

public void renderBackground(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
this.fillGradient(poseStack, 0, 0, this.width, this.height, 0xc0101010, 0xd0101010);
public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
graphics.fillGradient(0, 0, this.width, this.height, 0xc0101010, 0xd0101010);

// modified renderDirtBackground(0);
Tesselator tesselator = Tesselator.getInstance();
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/technicianlp/reauth/gui/ButtonFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package technicianlp.reauth.gui;

import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.Component;

/**
* Small helper to construct {@link Button}s.
* <p>
* Since 1.19.4 the Button API is stable ({@link Button#builder}), so the version specific
* reflection that used to live here is no longer required.
*/
public final class ButtonFactory {

public Button createButton(int x, int y, int width, int height, Component text, Button.OnPress onPress) {
return Button.builder(text, onPress).bounds(x, y, width, height).build();
}
}
16 changes: 8 additions & 8 deletions src/main/java/technicianlp/reauth/gui/FlowScreen.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package technicianlp.reauth.gui;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.Util;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -83,8 +83,8 @@ public void init() {
}

@Override
public void renderBackground(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
super.renderBackground(poseStack, mouseX, mouseY, partialTicks);
public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
super.renderBackground(graphics, mouseX, mouseY, partialTicks);

String text = I18n.get(this.stage.getRawName(), (Object[]) this.formatArgs);
List<String> lines = new ArrayList<>();
Expand All @@ -106,13 +106,13 @@ public void renderBackground(PoseStack poseStack, int mouseX, int mouseY, float
for (String line : lines) {
if (line.startsWith("$")) {
line = line.substring(1);
poseStack.pushPose();
poseStack.scale(2, 2, 1);
this.font.drawShadow(poseStack, line, (float) (this.centerX - this.font.width(line)) / 2, (float) y / 2, 0xFFFFFFFF);
graphics.pose().pushPose();
graphics.pose().scale(2, 2, 1);
graphics.drawString(this.font, line, (this.centerX - this.font.width(line)) / 2, y / 2, 0xFFFFFFFF);
y += 18;
poseStack.popPose();
graphics.pose().popPose();
} else {
this.font.drawShadow(poseStack, line, (float) (this.centerX - this.font.width(line) / 2), (float) y, 0xFFFFFFFF);
graphics.drawString(this.font, line, this.centerX - this.font.width(line) / 2, y, 0xFFFFFFFF);
y += 9;
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/technicianlp/reauth/gui/MainScreen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package technicianlp.reauth.gui;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -28,7 +28,7 @@ public void init() {
int buttonWidthH = BUTTON_WIDTH / 2;
int y = this.centerY - 55;

SaveButton.ITooltip saveButtonTooltip = (button, matrixStack, mouseX, mouseY) -> this.renderTooltip(matrixStack, this.font.split(Component.translatable("reauth.gui.button.save.tooltip"), 250), mouseX, mouseY);
SaveButton.ITooltip saveButtonTooltip = (button, graphics, mouseX, mouseY) -> graphics.renderTooltip(this.font, this.font.split(Component.translatable("reauth.gui.button.save.tooltip"), 250), mouseX, mouseY);
SaveButton saveButton = new SaveButton(this.centerX - buttonWidthH, y + 70, Component.translatable("reauth.gui.button.save"), saveButtonTooltip);
this.addRenderableWidget(saveButton);

Expand Down Expand Up @@ -62,16 +62,16 @@ public void init() {
}

@Override
public void renderBackground(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
super.renderBackground(poseStack, mouseX, mouseY, partialTicks);
public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
super.renderBackground(graphics, mouseX, mouseY, partialTicks);

int x = this.centerX - BUTTON_WIDTH / 2;
this.font.drawShadow(poseStack, I18n.get("reauth.gui.text.profile"), x, this.centerY - 55, 0xFFFFFFFF);
this.font.drawShadow(poseStack, I18n.get("reauth.gui.text.microsoft"), x, this.centerY - 20, 0xFFFFFFFF);
this.font.drawShadow(poseStack, I18n.get("reauth.gui.text.offline"), x, this.centerY + 40, 0xFFFFFFFF);
graphics.drawString(this.font, I18n.get("reauth.gui.text.profile"), x, this.centerY - 55, 0xFFFFFFFF);
graphics.drawString(this.font, I18n.get("reauth.gui.text.microsoft"), x, this.centerY - 20, 0xFFFFFFFF);
graphics.drawString(this.font, I18n.get("reauth.gui.text.offline"), x, this.centerY + 40, 0xFFFFFFFF);

if (this.message != null) {
this.font.drawShadow(poseStack, this.message, x, this.baseY + 20, 0xFFFFFFFF);
graphics.drawString(this.font, this.message, x, this.baseY + 20, 0xFFFFFFFF);
}
}

Expand Down
11 changes: 5 additions & 6 deletions src/main/java/technicianlp/reauth/gui/OfflineLoginScreen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package technicianlp.reauth.gui;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.events.GuiEventListener;
Expand All @@ -26,19 +26,18 @@ public void init() {
this.username = new EditBox(this.font, this.centerX - BUTTON_WIDTH / 2, this.centerY - 5, BUTTON_WIDTH, 20, Component.translatable("reauth.gui.auth.username"));
this.username.setMaxLength(16);
this.addRenderableWidget(this.username);
this.username.setFocus(true);
this.username.setFocused(true);
this.setFocused(this.username);
this.addRenderableWidget(this.username);

this.confirm = ReAuth.buttonFactory.createButton(this.centerX - BUTTON_WIDTH / 2, this.baseY + this.screenHeight - 42, BUTTON_WIDTH, 20, Component.translatable("reauth.gui.button.username"), (b) -> this.performUsernameChange());
this.addRenderableWidget(this.confirm);
}

@Override
public void renderBackground(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
super.renderBackground(poseStack, mouseX, mouseY, partialTicks);
public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
super.renderBackground(graphics, mouseX, mouseY, partialTicks);

this.font.drawShadow(poseStack, I18n.get("reauth.gui.auth.username"), this.centerX - (BUTTON_WIDTH / 2f), this.centerY - 15, 0xFFFFFFFF);
graphics.drawString(this.font, I18n.get("reauth.gui.auth.username"), this.centerX - BUTTON_WIDTH / 2, this.centerY - 15, 0xFFFFFFFF);
}

@Override
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/technicianlp/reauth/gui/SaveButton.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package technicianlp.reauth.gui;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Checkbox;
import net.minecraft.network.chat.Component;

Expand All @@ -14,14 +14,14 @@ public SaveButton(int x, int y, Component title, ITooltip tooltip) {
}

@Override
public void renderButton(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
super.renderButton(poseStack, mouseX, mouseY, partialTicks);
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
super.renderWidget(graphics, mouseX, mouseY, partialTicks);
if (this.isHoveredOrFocused()) {
this.tooltip.onTooltip(this, poseStack, mouseX, mouseY);
this.tooltip.onTooltip(this, graphics, mouseX, mouseY);
}
}

public interface ITooltip {
void onTooltip(SaveButton button, PoseStack poseStack, int mouseX, int mouseY);
void onTooltip(SaveButton button, GuiGraphics graphics, int mouseX, int mouseY);
}
}
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader = "javafml"
loaderVersion = "[28,)"
loaderVersion = "[47,)"
license = "All rights reserved"
issueTrackerURL = "https://github.com/TechnicianLP/ReAuth/issues"

Expand All @@ -15,13 +15,13 @@ description = "A Mod to renew your Session"
[[dependencies.reauth]]
modId = "minecraft"
mandatory = true
versionRange = "[1.19,1.20)"
versionRange = "[1.20.1,1.20.2)"
ordering = "NONE"
side = "CLIENT"

[[dependencies.reauth]]
modId = "forge"
mandatory = true
versionRange = "[41.0.94,)"
versionRange = "[47,)"
ordering = "NONE"
side = "CLIENT"
2 changes: 1 addition & 1 deletion src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "ReAuth Resources",
"pack_format": 6
"pack_format": 15
}
}