From c0b3c5c47f7e51ea896ee23fb0b99e6aa77a7a71 Mon Sep 17 00:00:00 2001 From: zml Date: Sat, 26 Aug 2023 16:41:36 -0700 Subject: [PATCH 1/4] 1.20.2-pre1 --- gradle/libs.versions.toml | 10 ++--- .../ServerCommonPacketListenerImplAccess.java | 37 +++++++++++++++++++ .../ServerGamePacketListenerImplAccess.java | 2 - ...nture-platform-fabric.accessor.mixins.json | 1 + .../minecraft/network/PacketEncoderMixin.java | 3 +- .../server/level/ServerPlayerMixin.java | 8 ++-- .../ServerGamePacketListenerImplMixin.java | 3 +- 7 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 src/accessor/java/net/kyori/adventure/platform/fabric/impl/accessor/minecraft/network/ServerCommonPacketListenerImplAccess.java diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ab7ef6fa..1eee2682 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,12 +8,12 @@ ansi = "1.0.3" autoService = "1.1.1" checkstyle = "10.12.3" examination = "1.3.0" -fabricApi = "0.85.0+1.20.1" -fabricLoader = "0.14.21" +fabricApi = "0.88.2+1.20.2" +fabricLoader = "0.14.22" indra = "3.1.3" -minecraft = "1.20.1" -parchment = "1.20.1:2023.07.16" -vineflower = "1.9.2" +minecraft = "1.20.2-pre1" +parchment = "1.20.1:2023.09.03" +vineflower = "1.9.3" spotless = "6.21.0" [libraries] diff --git a/src/accessor/java/net/kyori/adventure/platform/fabric/impl/accessor/minecraft/network/ServerCommonPacketListenerImplAccess.java b/src/accessor/java/net/kyori/adventure/platform/fabric/impl/accessor/minecraft/network/ServerCommonPacketListenerImplAccess.java new file mode 100644 index 00000000..ff93068c --- /dev/null +++ b/src/accessor/java/net/kyori/adventure/platform/fabric/impl/accessor/minecraft/network/ServerCommonPacketListenerImplAccess.java @@ -0,0 +1,37 @@ +/* + * This file is part of adventure-platform-fabric, licensed under the MIT License. + * + * Copyright (c) 2023 KyoriPowered + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package net.kyori.adventure.platform.fabric.impl.accessor.minecraft.network; + +import net.minecraft.network.Connection; +import net.minecraft.server.network.ServerCommonPacketListenerImpl; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ServerCommonPacketListenerImpl.class) +public interface ServerCommonPacketListenerImplAccess { + // @formatter:off + @Accessor("connection") @Final Connection accessor$connection(); + // @formatter:on +} diff --git a/src/accessor/java/net/kyori/adventure/platform/fabric/impl/accessor/minecraft/network/ServerGamePacketListenerImplAccess.java b/src/accessor/java/net/kyori/adventure/platform/fabric/impl/accessor/minecraft/network/ServerGamePacketListenerImplAccess.java index de400900..b826dc6e 100644 --- a/src/accessor/java/net/kyori/adventure/platform/fabric/impl/accessor/minecraft/network/ServerGamePacketListenerImplAccess.java +++ b/src/accessor/java/net/kyori/adventure/platform/fabric/impl/accessor/minecraft/network/ServerGamePacketListenerImplAccess.java @@ -23,7 +23,6 @@ */ package net.kyori.adventure.platform.fabric.impl.accessor.minecraft.network; -import net.minecraft.network.Connection; import net.minecraft.network.chat.MessageSignatureCache; import net.minecraft.server.network.ServerGamePacketListenerImpl; import org.spongepowered.asm.mixin.Final; @@ -33,7 +32,6 @@ @Mixin(ServerGamePacketListenerImpl.class) public interface ServerGamePacketListenerImplAccess { // @formatter:off - @Accessor("connection") @Final Connection accessor$connection(); @Accessor("messageSignatureCache") @Final MessageSignatureCache accessor$messageSignatureCache(); // @formatter:on } diff --git a/src/accessor/resources/adventure-platform-fabric.accessor.mixins.json b/src/accessor/resources/adventure-platform-fabric.accessor.mixins.json index d85af899..b43a3131 100644 --- a/src/accessor/resources/adventure-platform-fabric.accessor.mixins.json +++ b/src/accessor/resources/adventure-platform-fabric.accessor.mixins.json @@ -5,6 +5,7 @@ "api.key.InvalidKeyExceptionAccess", "brigadier.builder.RequiredArgumentBuilderAccess", "minecraft.network.ConnectionAccess", + "minecraft.network.ServerCommonPacketListenerImplAccess", "minecraft.network.ServerGamePacketListenerImplAccess", "minecraft.network.chat.Component_SerializerAccess", "minecraft.world.level.LevelAccess" diff --git a/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/network/PacketEncoderMixin.java b/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/network/PacketEncoderMixin.java index 0a7411cf..fb93827e 100644 --- a/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/network/PacketEncoderMixin.java +++ b/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/network/PacketEncoderMixin.java @@ -25,6 +25,7 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; +import io.netty.util.Attribute; import net.kyori.adventure.platform.fabric.impl.server.FriendlyByteBufBridge; import net.minecraft.network.ConnectionProtocol; import net.minecraft.network.FriendlyByteBuf; @@ -39,7 +40,7 @@ @Mixin(PacketEncoder.class) public class PacketEncoderMixin { @Inject(method = "encode(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/protocol/Packet;Lio/netty/buffer/ByteBuf;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/FriendlyByteBuf;writeVarInt(I)Lnet/minecraft/network/FriendlyByteBuf;"), locals = LocalCapture.CAPTURE_FAILHARD) - private void adventure$applyLocaleToBuffer(final ChannelHandlerContext ctx, final Packet pkt, final ByteBuf orig, final CallbackInfo ci, final ConnectionProtocol unused$proto, final int unused$id, final FriendlyByteBuf buffer) { + private void adventure$applyLocaleToBuffer(final ChannelHandlerContext ctx, final Packet pkt, final ByteBuf orig, final CallbackInfo ci, final Attribute unused$protoAttr, final ConnectionProtocol.CodecData unused$protocol, final int unused$id, final FriendlyByteBuf buffer) { ((FriendlyByteBufBridge) buffer).adventure$data(ctx.channel().attr(FriendlyByteBufBridge.CHANNEL_RENDER_DATA).get()); } } diff --git a/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/server/level/ServerPlayerMixin.java b/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/server/level/ServerPlayerMixin.java index abf0e6e5..216b82fc 100644 --- a/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/server/level/ServerPlayerMixin.java +++ b/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/server/level/ServerPlayerMixin.java @@ -35,7 +35,7 @@ import net.kyori.adventure.platform.fabric.PlayerLocales; import net.kyori.adventure.platform.fabric.impl.LocaleHolderBridge; import net.kyori.adventure.platform.fabric.impl.accessor.minecraft.network.ConnectionAccess; -import net.kyori.adventure.platform.fabric.impl.accessor.minecraft.network.ServerGamePacketListenerImplAccess; +import net.kyori.adventure.platform.fabric.impl.accessor.minecraft.network.ServerCommonPacketListenerImplAccess; import net.kyori.adventure.platform.fabric.impl.mixin.minecraft.world.entity.player.PlayerMixin; import net.kyori.adventure.platform.fabric.impl.server.FabricServerAudiencesImpl; import net.kyori.adventure.platform.fabric.impl.server.FriendlyByteBufBridge; @@ -44,9 +44,9 @@ import net.kyori.adventure.platform.fabric.impl.server.ServerPlayerBridge; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundTabListPacket; -import net.minecraft.network.protocol.game.ServerboundClientInformationPacket; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ClientInformation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.world.entity.EntityType; @@ -121,7 +121,7 @@ public Audience renderUsing(final FabricServerAudiencesImpl controller) { // Locale tracking @Inject(method = "updateOptions", at = @At("HEAD")) - private void adventure$handleLocaleUpdate(final ServerboundClientInformationPacket information, final CallbackInfo ci) { + private void adventure$handleLocaleUpdate(final ClientInformation information, final CallbackInfo ci) { final String language = information.language(); final @Nullable Locale locale = LocaleHolderBridge.toLocale(language); if (!Objects.equals(this.adventure$locale, locale)) { @@ -135,7 +135,7 @@ public Audience renderUsing(final FabricServerAudiencesImpl controller) { @Inject(method = "restoreFrom", at = @At("RETURN")) private void copyData(final ServerPlayer old, final boolean alive, final CallbackInfo ci) { FabricServerAudiencesImpl.forEachInstance(controller -> controller.bossBars().replacePlayer(old, (ServerPlayer) (Object) this)); - final Channel channel = ((ConnectionAccess) ((ServerGamePacketListenerImplAccess) this.connection).accessor$connection()).accessor$channel(); + final Channel channel = ((ConnectionAccess) ((ServerCommonPacketListenerImplAccess) this.connection).accessor$connection()).accessor$channel(); if (channel != null) { channel.attr(FriendlyByteBufBridge.CHANNEL_RENDER_DATA).set(this); } diff --git a/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/server/network/ServerGamePacketListenerImplMixin.java b/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/server/network/ServerGamePacketListenerImplMixin.java index 5e74c25d..0179fae9 100644 --- a/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/server/network/ServerGamePacketListenerImplMixin.java +++ b/src/mixin/java/net/kyori/adventure/platform/fabric/impl/mixin/minecraft/server/network/ServerGamePacketListenerImplMixin.java @@ -29,6 +29,7 @@ import net.minecraft.network.Connection; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.CommonListenerCookie; import net.minecraft.server.network.ServerGamePacketListenerImpl; import org.jetbrains.annotations.Nullable; import org.objectweb.asm.Opcodes; @@ -41,7 +42,7 @@ public class ServerGamePacketListenerImplMixin { // Initialize attribute tracking the player for component rendering @Inject(method = "", at = @At(value = "FIELD", target = "Lnet/minecraft/server/level/ServerPlayer;connection:Lnet/minecraft/server/network/ServerGamePacketListenerImpl;", opcode = Opcodes.PUTFIELD)) - private void adventure$initTracking(final MinecraftServer server, final Connection conn, final ServerPlayer player, final CallbackInfo ci) { + private void adventure$initTracking(final MinecraftServer server, final Connection conn, final ServerPlayer player, final CommonListenerCookie cookie, final CallbackInfo ci) { final @Nullable Channel chan = ((ConnectionAccess) conn).accessor$channel(); // XX: Broken mods that refuse to fix their fake player implementations throw an NPE here if (chan != null) { chan.attr(FriendlyByteBufBridge.CHANNEL_RENDER_DATA).set(player); From e473428bdce4b728b0731769683d8062fae3986f Mon Sep 17 00:00:00 2001 From: zml Date: Sat, 9 Sep 2023 19:10:48 -0700 Subject: [PATCH 2/4] 1.20.2-pre1 --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1eee2682..76a816c8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,10 +8,10 @@ ansi = "1.0.3" autoService = "1.1.1" checkstyle = "10.12.3" examination = "1.3.0" -fabricApi = "0.88.2+1.20.2" +fabricApi = "0.88.3+1.20.2" fabricLoader = "0.14.22" indra = "3.1.3" -minecraft = "1.20.2-pre1" +minecraft = "1.20.2-pre2" parchment = "1.20.1:2023.09.03" vineflower = "1.9.3" spotless = "6.21.0" From cbe6ed4cf28df42c4fe732ee2a182e6885d18695 Mon Sep 17 00:00:00 2001 From: zml Date: Mon, 18 Sep 2023 19:04:26 -0700 Subject: [PATCH 3/4] 1.20.2-rc2 --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 76a816c8..7af4cad2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,10 +8,10 @@ ansi = "1.0.3" autoService = "1.1.1" checkstyle = "10.12.3" examination = "1.3.0" -fabricApi = "0.88.3+1.20.2" +fabricApi = "0.89.0+1.20.2" fabricLoader = "0.14.22" indra = "3.1.3" -minecraft = "1.20.2-pre2" +minecraft = "1.20.2-rc2" parchment = "1.20.1:2023.09.03" vineflower = "1.9.3" spotless = "6.21.0" From cbe2da438d9f7b258b5090e0e9afb30a6f9423eb Mon Sep 17 00:00:00 2001 From: zml Date: Thu, 21 Sep 2023 16:06:14 -0700 Subject: [PATCH 4/4] 1.20.2 final --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7af4cad2..b040635e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,10 +8,10 @@ ansi = "1.0.3" autoService = "1.1.1" checkstyle = "10.12.3" examination = "1.3.0" -fabricApi = "0.89.0+1.20.2" +fabricApi = "0.89.1+1.20.2" fabricLoader = "0.14.22" indra = "3.1.3" -minecraft = "1.20.2-rc2" +minecraft = "1.20.2" parchment = "1.20.1:2023.09.03" vineflower = "1.9.3" spotless = "6.21.0"