Skip to content

Commit

Permalink
1.19.4 port
Browse files Browse the repository at this point in the history
  • Loading branch information
Skidamek committed Apr 9, 2023
1 parent 0f37bfa commit 186ad7f
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 46 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ subprojects {
apply plugin: "io.github.juuxel.loom-quiltflower"

// loom {

// accessWidenerPath = file("src/main/resources/automodpack.accesswidener")

// silentMojangMappingsLicense()
// }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package pl.skidam.automodpack.client.ui;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.EntryListWidget;
import net.minecraft.client.gui.widget.ElementListWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
import pl.skidam.automodpack.TextHelper;
import pl.skidam.automodpack.client.ModpackUpdater;
import pl.skidam.automodpack.client.ui.widget.ScrollingListWidget;
import pl.skidam.automodpack.config.Jsons;
import pl.skidam.automodpack.config.ConfigTools;
import pl.skidam.automodpack.config.Jsons;
import pl.skidam.automodpack.utils.ModpackContentTools;

import java.io.File;
Expand Down Expand Up @@ -98,7 +100,7 @@ private void drawSummaryOfChanges(MatrixStack matrices) {

String summary = "Mods + " + modsAdded + " | - " + modsRemoved;

drawCenteredText(matrices, textRenderer, TextHelper.literal(summary), this.width / 2, 5, 16777215);
drawCenteredTextWithShadow(matrices, textRenderer, TextHelper.literal(summary), this.width / 2, 5, 16777215);
}

private void updateChangelogs() {
Expand Down Expand Up @@ -154,7 +156,7 @@ public static class ChangelogsList extends ScrollingListWidget<ChangelogsList.En
}
}

public class Entry extends EntryListWidget.Entry<ChangelogsList.Entry> {
public class Entry extends ElementListWidget.Entry<ChangelogsList.Entry> {
private final String text;
private final int color;
public Entry(String text, int color) {
Expand All @@ -164,7 +166,17 @@ public Entry(String text, int color) {

@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
drawStringWithShadow(matrices, ChangelogsList.this.client.textRenderer, text, x + 10, y, color);
drawCenteredTextWithShadow(matrices, ChangelogsList.this.client.textRenderer, text, x + 10, y, color);
}

@Override
public List<? extends Selectable> selectableChildren() {
return null;
}

@Override
public List<? extends Element> children() {
return null;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ protected void init() {
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 55, 16777215);
drawCenteredText(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.danger.description"), this.width / 2, 80, 16777215);
drawCenteredText(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.danger.secDescription"), this.width / 2, 90, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, this.title, this.width / 2, 55, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.danger.description"), this.width / 2, 80, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.danger.secDescription"), this.width / 2, 90, 16777215);
super.render(matrices, mouseX, mouseY, delta);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,18 @@ private void drawDownloadingFiles(MatrixStack matrices) {
List<DownloadInfo> downloadInfosCopy = new ArrayList<>(downloadInfos);

if (downloadInfosCopy.size() > 0) {
drawCenteredText(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.download.text.downloading"), (int) (this.width / 2 * scale), y, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.download.text.downloading"), (int) (this.width / 2 * scale), y, 16777215);

// Use a separate variable for the current y position
int currentY = y + 15;
for (DownloadInfo file : downloadInfosCopy) {
if (file == null) continue;
String fileName = file.getFileName();
drawCenteredText(matrices, this.textRenderer, fileName + " (" + getDownloadedSize(fileName) + ")" + " - " + getETAOfFile(fileName), (int) (this.width / 2 * scale), currentY, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, fileName + " (" + getDownloadedSize(fileName) + ")" + " - " + getETAOfFile(fileName), (int) (this.width / 2 * scale), currentY, 16777215);
currentY += 10;
}
} else {
drawCenteredText(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.download.text.no_files"), (int) (this.width / 2 * scale), y, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.download.text.no_files"), (int) (this.width / 2 * scale), y, 16777215);
}

matrices.pop();
Expand All @@ -123,10 +123,10 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
Text stage = this.getStage();
Text eta = this.getTotalETA();
Text speed = this.getTotalDownloadSpeed();
drawCenteredText(matrices, this.textRenderer, stage, this.width / 2, this.height / 2 - 10, 16777215);
drawCenteredText(matrices, this.textRenderer, eta, this.width / 2, this.height / 2 + 10, 16777215);
drawCenteredText(matrices, this.textRenderer, percentage, this.width / 2, this.height / 2 + 30, 16777215);
drawCenteredText(matrices, this.textRenderer, speed, this.width / 2, this.height / 2 + 80, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, stage, this.width / 2, this.height / 2 - 10, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, eta, this.width / 2, this.height / 2 + 10, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, percentage, this.width / 2, this.height / 2 + 30, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, speed, this.width / 2, this.height / 2 + 80, 16777215);

drawDownloadingFiles(matrices);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ protected void init() {
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, TextHelper.literal("[AutoModpack] Error! Something went wrong!").formatted(Formatting.RED), this.width / 2, this.height / 2 - 40, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, TextHelper.literal("[AutoModpack] Error! Something went wrong!").formatted(Formatting.RED), this.width / 2, this.height / 2 - 40, 16777215);
for (int i = 0; i < this.errorMessage.length; i++) {
drawCenteredText(matrices, this.textRenderer, this.errorMessage[i], this.width / 2, this.height / 2 - 20 + i * 10, 14687790);
drawCenteredTextWithShadow(matrices, this.textRenderer, this.errorMessage[i], this.width / 2, this.height / 2 - 20 + i * 10, 14687790);
}
super.render(matrices, mouseX, mouseY, delta);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
//drawCenteredText(matrices, this.textRenderer, selectedServerIP, this.width / 2, 60, 16777215);
//drawCenteredText(matrices, this.textRenderer, selectedModpack, this.width / 2, 70, 16777215);

drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215);
//drawCenteredText(matrices, this.textRenderer, new TranslatableText("gui.automodpack.screen.menu.description"), this.width / 2, 20, 16777215);
super.render(matrices, mouseX, mouseY, delta);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ protected void renderBackground(MatrixStack matrices) {
MenuScreen.this.renderBackground(matrices);
}

protected boolean isFocused() {
public boolean isFocused() {
return MenuScreen.this.getFocused() == this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ protected void init() {
}
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, TextHelper.literal("Restart"), this.width / 2, 55, 16777215);
drawCenteredText(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.restart.description"), this.width / 2, 80, 16777215);
drawCenteredText(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.restart.secDescription"), this.width / 2, 90, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, TextHelper.literal("Restart"), this.width / 2, 55, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.restart.description"), this.width / 2, 80, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, TextHelper.translatable("gui.automodpack.screen.restart.secDescription"), this.width / 2, 90, 16777215);
super.render(matrices, mouseX, mouseY, delta);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.EntryListWidget;
import net.minecraft.client.gui.widget.ElementListWidget;
import net.minecraft.client.util.math.MatrixStack;

public class ScrollingListWidget<E extends EntryListWidget.Entry<E>> extends EntryListWidget<E> {
public class ScrollingListWidget<E extends ElementListWidget.Entry<E>> extends ElementListWidget<E> {

public ScrollingListWidget(MinecraftClient client, int width, int height, int top, int bottom, int itemHeight) {
super(client, width, height, top, bottom, itemHeight);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pl.skidam.automodpack.mixin;

import com.mojang.authlib.GameProfile;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.network.ServerLoginNetworkHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
Expand All @@ -9,4 +10,7 @@
public interface ServerLoginNetworkHandlerAccessor {
@Accessor("profile")
GameProfile getGameProfile();

@Accessor("connection")
ClientConnection getConnection();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.*;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.login.LoginDisconnectS2CPacket;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -74,8 +75,9 @@ public static void registerS2CPackets() {
if (i == 300) {
LOGGER.error("Timeout login for " + profile.getName() + " (" + uniqueId.toString() + ")");
Text reason = TextHelper.literal("AutoModpack - timeout");
handler.connection.send(new LoginDisconnectS2CPacket(reason));
handler.connection.disconnect(reason);
ClientConnection connection = ((ServerLoginNetworkHandlerAccessor) handler).getConnection();
connection.send(new LoginDisconnectS2CPacket(reason));
connection.disconnect(reason);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.authlib.GameProfile;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.fabricmc.fabric.api.networking.v1.ServerLoginNetworking;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.login.LoginDisconnectS2CPacket;
import net.minecraft.network.packet.s2c.play.DisconnectS2CPacket;
Expand All @@ -26,15 +27,17 @@ public static void receive(MinecraftServer server, ServerLoginNetworkHandler han
if (buf.readBoolean()) { // disconnect
Text reason = TextHelper.literal("[AutoModpack] Install/Update modpack to join");
acceptLogin.add(uniqueId);
handler.connection.send(new LoginDisconnectS2CPacket(reason));
handler.connection.disconnect(reason);
ClientConnection connection = ((ServerLoginNetworkHandlerAccessor) handler).getConnection();
connection.send(new LoginDisconnectS2CPacket(reason));
connection.disconnect(reason);
}
}
public static void receive(MinecraftServer server, ServerPlayerEntity player, ServerPlayNetworkHandler handler, PacketByteBuf buf, PacketSender sender) {
if (buf.readBoolean()) { // disconnect
Text reason = TextHelper.literal("[AutoModpack] Install/Update modpack to join");
handler.connection.send(new DisconnectS2CPacket(reason));
handler.connection.disconnect(reason);
ClientConnection connection = ((ServerLoginNetworkHandlerAccessor) handler).getConnection();
connection.send(new DisconnectS2CPacket(reason));
connection.disconnect(reason);
}

// otherwise just join the server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class LoginS2CPacket {

// Login packet (the best way)
public static void receive(MinecraftServer server, ServerLoginNetworkHandler handler, boolean understood, PacketByteBuf buf, ServerLoginNetworking.LoginSynchronizer sync, PacketSender sender) {
ClientConnection connection = handler.connection;
ClientConnection connection = ((ServerLoginNetworkHandlerAccessor) handler).getConnection();

GameProfile profile = ((ServerLoginNetworkHandlerAccessor) handler).getGameProfile();
UUID uniqueId = profile.getId();
Expand Down Expand Up @@ -100,7 +100,7 @@ public static void receive(MinecraftServer server, ServerLoginNetworkHandler han

// Join packet (velocity support)
public static void receive(MinecraftServer server, ServerPlayerEntity player, ServerPlayNetworkHandler handler, PacketByteBuf buf, PacketSender sender) {
ClientConnection connection = handler.connection;
ClientConnection connection = ((ServerLoginNetworkHandlerAccessor) handler).getConnection();

String correctResponse = VERSION + "-" + Platform.getPlatformType().toString().toLowerCase();
String clientResponse = buf.readString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package pl.skidam.automodpack.forge.networking.packet;

import net.minecraft.network.Packet;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.listener.ClientLoginPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraftforge.network.NetworkEvent;
import pl.skidam.automodpack.client.ModpackUpdater;
import pl.skidam.automodpack.client.ModpackUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package pl.skidam.automodpack.forge.networking.packet;

import net.minecraft.network.ClientConnection;
import net.minecraft.network.Packet;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.listener.ServerLoginPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraftforge.network.NetworkEvent;
import pl.skidam.automodpack.mixin.ServerLoginNetworkHandlerAccessor;

import java.util.function.Supplier;

public class LoginC2SPacket implements Packet<ServerLoginPacketListener> {
public class LoginC2SPacket implements Packet<ServerLoginPacketListener> {
private final String version;
public LoginC2SPacket(String version) {
this.version = version;
Expand All @@ -23,7 +24,7 @@ public void write(PacketByteBuf buf) {
}

public void apply(ServerLoginPacketListener listener) {
ClientConnection connection = listener.getConnection();
ClientConnection connection = ((ServerLoginNetworkHandlerAccessor) listener).getConnection();

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package pl.skidam.automodpack.forge.networking.packet;

import net.minecraft.network.Packet;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.listener.ClientLoginPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraftforge.network.NetworkEvent;
import pl.skidam.automodpack.forge.networking.ModPackets;
import pl.skidam.automodpack.mixin.ServerLoginNetworkHandlerAccessor;

import java.util.function.Supplier;

import static pl.skidam.automodpack.StaticVariables.LOGGER;
import static pl.skidam.automodpack.StaticVariables.VERSION;

public class LoginS2CPacket implements Packet<ClientLoginPacketListener> {
public class LoginS2CPacket implements Packet<ClientLoginPacketListener> {
private final String version;
public LoginS2CPacket(String version) {
this.version = version;
Expand All @@ -31,7 +33,8 @@ public void apply(ClientLoginPacketListener listener) {

LOGGER.error("Received login packet from server! " + version);
LOGGER.error("Sending login packet to server! " + VERSION);
listener.getConnection().send(new LoginC2SPacket(VERSION));
ClientConnection connection = ((ServerLoginNetworkHandlerAccessor) listener).getConnection();
connection.send(new LoginC2SPacket(VERSION));
LOGGER.error("Sent login packet to server! " + VERSION);
}

Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.jvmargs = -Xmx6G
minecraft_version = 1.19.3
yarn_mappings = 1.19.3+build.5
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.2

# mod
maven_group = pl.skidam
Expand All @@ -12,11 +12,11 @@ enabled_platforms = quilt,fabric,forge
quilt_flower_version = 1.8.0

# loader
architectury_version_api = 7.1.78
architectury_version_api = 8.1.79
fabric_loader_version = 0.14.19
fabric_api_version = 0.76.0+1.19.3
quilt_api_version = 4.0.0-beta.13+1.19.3
forge_version = 1.19.3-44.1.8
fabric_api_version = 0.77.0+1.19.4
quilt_api_version = 5.0.0-beta.2+1.19.4
forge_version = 1.19.4-45.0.43

# compatibility
mod_menu_version = 5.0.2
mod_menu_version = 6.1.0-rc.4

0 comments on commit 186ad7f

Please sign in to comment.