Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20.2 #107

Merged
merged 4 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -41,7 +42,7 @@
public class ServerGamePacketListenerImplMixin {
// Initialize attribute tracking the player for component rendering
@Inject(method = "<init>", 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);
Expand Down