diff --git a/gradle.properties b/gradle.properties index 35672807..12858811 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx8G org.gradle.parallel=true # Minecraft/Fabric -minecraft_version=1.20.5-pre4 -yarn_mappings=1.20.5-pre4+build.1 +minecraft_version=1.20.5-rc1 +yarn_mappings=1.20.5-rc1+build.1 loader_version=0.15.10 fabric_api_version=0.97.3+1.20.5 @@ -14,7 +14,7 @@ maven_group=de.florianmichael archives_base_name=ViaFabricPlus # ViaVersion Libraries -viaversion_version=4.10.0-1.20.5-pre4-SNAPSHOT +viaversion_version=4.10.0-1.20.5-rc1-SNAPSHOT viabackwards_version=4.10.0-24w09a-SNAPSHOT vialegacy_version=2.2.22-SNAPSHOT viaaprilfools_version=2.0.11-SNAPSHOT diff --git a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index 49541b6f..99a181a4 100644 --- a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -49,7 +49,6 @@ import java.util.concurrent.CompletableFuture; * * TODO | Port * - Readd MixinCustomPayloadS2CPacket, MixinInGameHud - * - All Update todos * - Test 1.11.2 banner recipe * - Test 1.20.1 riding offsets * - Fix on protocol level: modify1_7StepHeight, modifyReachDistance @@ -58,9 +57,7 @@ import java.util.concurrent.CompletableFuture; * - Readd item fixes on protocol level: MixinAxeItem, MixinHoeItem, MixinPickaxeItem, MixinShearsItem, MixinShovelItem, MixinSwordItem, MixinMiningToolItem, MixinItem * - Readd item fixes: ArmorMaterials, MixinItemStack, MixinDrawContext, MixinPacketByteBuf * - Test villager trading in 1.8/1.12.2 - * - Test 1.8 triple chest * - Figure out how to fix 32k enchantments with codecs (MixinEnchantmentHelper) - * - Test sign interactions */ public class ViaFabricPlus { diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java index 2a05c685..c17212d0 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java @@ -31,6 +31,7 @@ import de.florianmichael.viafabricplus.fixes.versioned.visual.FootStepParticle1_ import de.florianmichael.viafabricplus.injection.access.IClientConnection; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import de.florianmichael.viafabricplus.settings.impl.BedrockSettings; +import de.florianmichael.viafabricplus.util.DataCustomPayload; import net.minecraft.block.*; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.FontStorage; @@ -119,6 +120,9 @@ public class ClientsideFixes { // Register the footstep particle FootStepParticle1_12_2.init(); + + // Register the custom payload packet for sync tasks + DataCustomPayload.init(); } /** 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 12a89a92..4d623175 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 @@ -21,8 +21,10 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.storage.InventoryAcknowledgements; +import de.florianmichael.viafabricplus.fixes.ClientsideFixes; import de.florianmichael.viafabricplus.injection.access.IClientConnection; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; +import de.florianmichael.viafabricplus.util.DataCustomPayload; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientCommonNetworkHandler; import net.minecraft.network.ClientConnection; @@ -100,11 +102,10 @@ public abstract class MixinClientCommonNetworkHandler { @Inject(method = "onCustomPayload(Lnet/minecraft/network/packet/s2c/common/CustomPayloadS2CPacket;)V", at = @At("HEAD"), cancellable = true) private void handleSyncTask(CustomPayloadS2CPacket packet, CallbackInfo ci) { - // TODO: Update: Fix - /*if (packet.payload().id().toString().equals(ClientsideFixes.PACKET_SYNC_IDENTIFIER) && packet.payload() instanceof ResolvablePayload payload) { - ClientsideFixes.handleSyncTask(((UntypedPayload) payload.resolve(null)).buffer()); + if (packet.payload() instanceof DataCustomPayload dataCustomPayload) { + ClientsideFixes.handleSyncTask(dataCustomPayload.buf()); ci.cancel(); // Cancel the packet, so it doesn't get processed by the client - }*/ + } } @Inject(method = "onResourcePackSend", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/de/florianmichael/viafabricplus/util/DataCustomPayload.java b/src/main/java/de/florianmichael/viafabricplus/util/DataCustomPayload.java new file mode 100644 index 00000000..a6deb32c --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/util/DataCustomPayload.java @@ -0,0 +1,44 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC + * Copyright (C) 2023-2024 contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.util; + +import de.florianmichael.viafabricplus.fixes.ClientsideFixes; +import io.netty.buffer.Unpooled; +import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.packet.CustomPayload; +import net.minecraft.util.Identifier; + +public record DataCustomPayload(PacketByteBuf buf) implements CustomPayload { + + public static final CustomPayload.Id ID = new CustomPayload.Id<>(new Identifier(ClientsideFixes.PACKET_SYNC_IDENTIFIER)); + + public static void init() { + PayloadTypeRegistry.playS2C().register(DataCustomPayload.ID, CustomPayload.codecOf((value, buf) -> { + throw new UnsupportedOperationException("DataCustomPayload is a read-only packet"); + }, buf -> new DataCustomPayload(new PacketByteBuf(Unpooled.copiedBuffer(buf.readSlice(buf.readableBytes())))))); + } + + @Override + public Id getId() { + return ID; + } + +}