diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ab7ef6fa..b040635e 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.89.1+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" +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);