From 1e47ab7f51091eebc2c80841f213b2a0fe303706 Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Wed, 20 Sep 2023 00:41:52 +0200 Subject: [PATCH] Fixed clientside sync task system, thanks Fabric-API --- gradle.properties | 8 ++++---- .../network/MixinClientCommonNetworkHandler.java | 10 ++++------ .../viafabricplus/mappings/PackFormatsMappings.java | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/gradle.properties b/gradle.properties index 03e3c752..9205bbcc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx8G org.gradle.parallel=true # minecraft and fabric -minecraft_version=1.20.2-rc1 -yarn_mappings=1.20.2-rc1+build.2 +minecraft_version=1.20.2-rc2 +yarn_mappings=1.20.2-rc2+build.4 loader_version=0.14.22 -fabric_api_version=0.88.5+1.20.2 +fabric_api_version=0.89.0+1.20.2 # viafabricplus mod_version=2.8.7-SNAPSHOT @@ -18,7 +18,7 @@ raknet_transport_version=1.0.0.CR1-SNAPSHOT classic4j_version=1.2.0 # viaversion (and required) libs -viaversion_version=4.8.0-1.20.2-rc1-SNAPSHOT +viaversion_version=4.8.0-1.20.2-rc2-SNAPSHOT viabackwards_version=4.8.0-1.20.2-pre2-SNAPSHOT vialoader_version=2.2.9-SNAPSHOT diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientCommonNetworkHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientCommonNetworkHandler.java index a431d524..3d019a22 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientCommonNetworkHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientCommonNetworkHandler.java @@ -19,10 +19,9 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network; import de.florianmichael.viafabricplus.definition.ClientsideFixes; import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; -import io.netty.buffer.Unpooled; +import net.fabricmc.fabric.impl.networking.payload.PacketByteBufPayload; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientCommonNetworkHandler; -import net.minecraft.network.PacketByteBuf; import net.minecraft.network.listener.ServerPacketListener; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.s2c.common.CommonPingS2CPacket; @@ -79,12 +78,11 @@ public abstract class MixinClientCommonNetworkHandler { @Inject(method = "onCustomPayload(Lnet/minecraft/network/packet/s2c/common/CustomPayloadS2CPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER), cancellable = true) public void handlePseudoPackets(CustomPayloadS2CPacket packet, CallbackInfo ci) { final var channel = packet.payload().id().toString(); - final var data = new PacketByteBuf(Unpooled.buffer()); - packet.payload().write(data); - if (channel.equals(ClientsideFixes.PACKET_SYNC_IDENTIFIER)) { + if (channel.equals(ClientsideFixes.PACKET_SYNC_IDENTIFIER) && packet.payload() instanceof PacketByteBufPayload payload) { + final var data = payload.data(); + final var uuid = data.readString(); - if (ClientsideFixes.hasSyncTask(uuid)) { ClientsideFixes.getSyncTask(uuid).accept(data); ci.cancel(); diff --git a/src/main/java/de/florianmichael/viafabricplus/mappings/PackFormatsMappings.java b/src/main/java/de/florianmichael/viafabricplus/mappings/PackFormatsMappings.java index 2626d759..0a6e3d98 100644 --- a/src/main/java/de/florianmichael/viafabricplus/mappings/PackFormatsMappings.java +++ b/src/main/java/de/florianmichael/viafabricplus/mappings/PackFormatsMappings.java @@ -33,7 +33,7 @@ public class PackFormatsMappings { private final static Map protocolMap = new HashMap<>(); public static void load() { - registerVersion(VersionEnum.r1_20_2, 18, "1.20.2 Release Candidate 1", "1.20.2-rc1"); + registerVersion(VersionEnum.r1_20_2, 18, "1.20.2 Release Candidate 2", "1.20.2-rc2"); registerVersion(VersionEnum.r1_20tor1_20_1, 15, "1.20.1"); // 1.20 and 1.20.1 are the same, why care... registerVersion(VersionEnum.r1_19_4, 13, "1.19.4"); registerVersion(VersionEnum.r1_19_3, 12, "1.19.3");