3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 16:12:43 +01:00

Don't remove configuration packet storage on login

Needed with proxies if a server is doing nonstandard optimizations
Fixes #881
Dieser Commit ist enthalten in:
Nassim Jahnke 2024-09-08 10:48:10 +02:00
Ursprung ffb98523e6
Commit 0bac9201ac
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
2 geänderte Dateien mit 10 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -108,7 +108,7 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
@Override
public void register() {
handler(wrapper -> {
final ConfigurationPacketStorage configurationPacketStorage = wrapper.user().remove(ConfigurationPacketStorage.class);
final ConfigurationPacketStorage configurationPacketStorage = wrapper.user().get(ConfigurationPacketStorage.class);
wrapper.passthrough(Types.INT); // Entity id
wrapper.passthrough(Types.BOOLEAN); // Hardcore

Datei anzeigen

@ -18,13 +18,13 @@
package com.viaversion.viabackwards.protocol.v1_20_2to1_20.storage;
import com.google.common.base.Preconditions;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.Protocol1_20_2To1_20;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.PacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4;
import com.viaversion.nbt.tag.CompoundTag;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
@ -77,17 +77,21 @@ public final class ConfigurationPacketStorage implements StorableObject {
public void sendQueuedPackets(final UserConnection connection) {
// Send resource pack at the end
List<QueuedPacket> packets = rawPackets;
if (resourcePack != null) {
rawPackets.add(resourcePack);
packets = new ArrayList<>(rawPackets);
packets.add(resourcePack);
resourcePack = null;
}
for (final QueuedPacket queuedPacket : rawPackets) {
for (final QueuedPacket queuedPacket : packets) {
// Don't clear the list or use the original buffer, we might need them later if a server skips subsequent config phases
final ByteBuf buf = queuedPacket.buf().copy();
try {
final PacketWrapper packet = PacketWrapper.create(queuedPacket.packetType(), queuedPacket.buf(), connection);
final PacketWrapper packet = PacketWrapper.create(queuedPacket.packetType(), buf, connection);
packet.send(Protocol1_20_2To1_20.class);
} finally {
queuedPacket.buf().release();
buf.release();
}
}
}