mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-02-27 00:51:39 +01:00
Fix missing server state change
This commit is contained in:
parent
3997ea70f7
commit
840770a350
@ -28,9 +28,8 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufInputStream;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class NBTType extends Type<CompoundTag> {
|
||||
|
||||
@ -42,37 +41,31 @@ public class NBTType extends Type<CompoundTag> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag read(ByteBuf buffer) throws Exception {
|
||||
public CompoundTag read(final ByteBuf buffer) throws Exception {
|
||||
return read(buffer, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, CompoundTag object) throws Exception {
|
||||
public void write(final ByteBuf buffer, final CompoundTag object) throws Exception {
|
||||
write(buffer, object, "");
|
||||
}
|
||||
|
||||
public static CompoundTag read(final ByteBuf buffer, final boolean readName) throws Exception {
|
||||
final int readerIndex = buffer.readerIndex();
|
||||
final byte b = buffer.readByte();
|
||||
if (b == 0) {
|
||||
final byte id = buffer.readByte();
|
||||
if (id == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
buffer.readerIndex(readerIndex);
|
||||
|
||||
final ByteBufInputStream in = new ByteBufInputStream(buffer);
|
||||
final int id = in.readByte();
|
||||
if (id != CompoundTag.ID) {
|
||||
throw new IOException(String.format("Expected root tag to be a CompoundTag, was %s", id));
|
||||
}
|
||||
|
||||
if (readName) {
|
||||
in.skipBytes(in.readUnsignedShort());
|
||||
buffer.skipBytes(buffer.readUnsignedShort());
|
||||
}
|
||||
|
||||
final TagLimiter tagLimiter = TagLimiter.create(MAX_NBT_BYTES, MAX_NESTING_LEVEL);
|
||||
final CompoundTag tag = new CompoundTag();
|
||||
tag.read(in, tagLimiter);
|
||||
tag.read(new ByteBufInputStream(buffer), tagLimiter);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,8 @@ import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.storage.Configur
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.storage.ConfigurationState.BridgePhase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.storage.LastResourcePack;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPackets1_19_4, ClientboundPackets1_20_2, ServerboundPackets1_19_4, ServerboundPackets1_20_2> {
|
||||
|
||||
@ -120,6 +119,9 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.LOGIN_ACKNOWLEDGED.getId(), -1, wrapper -> {
|
||||
wrapper.cancel();
|
||||
|
||||
// Overwrite the state set in the base protocol to what the server actually keeps sending
|
||||
wrapper.user().getProtocolInfo().setServerState(State.PLAY);
|
||||
|
||||
final ConfigurationState configurationState = wrapper.user().get(ConfigurationState.class);
|
||||
configurationState.setBridgePhase(BridgePhase.CONFIGURATION);
|
||||
configurationState.sendQueuedPackets(wrapper.user());
|
||||
@ -198,7 +200,6 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (phase == BridgePhase.PROFILE_SENT || phase == BridgePhase.REENTERING_CONFIGURATION) {
|
||||
// Queue packets sent by the server while we wait for the client to transition to the configuration state
|
||||
configurationBridge.addPacketToQueue(packetWrapper, true);
|
||||
|
Loading…
Reference in New Issue
Block a user