diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Respawn.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Respawn.java index 712024f63..fe7b15441 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Respawn.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/Respawn.java @@ -186,12 +186,10 @@ public class Respawn implements MinecraftPacket { boolean isDebug = buf.readBoolean(); boolean isFlat = buf.readBoolean(); this.dimensionInfo = new DimensionInfo(dimensionIdentifier, levelName, isFlat, isDebug); - if (version.compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) { + if (version.compareTo(ProtocolVersion.MINECRAFT_1_19_3) < 0) { + this.dataToKeep = (byte) (buf.readBoolean() ? 1 : 0); + } else if (version.compareTo(ProtocolVersion.MINECRAFT_1_20_2) < 0) { this.dataToKeep = buf.readByte(); - } else if (buf.readBoolean()) { - this.dataToKeep = 1; - } else { - this.dataToKeep = 0; } } else { this.levelType = ProtocolUtils.readString(buf, 16); @@ -202,6 +200,9 @@ public class Respawn implements MinecraftPacket { if (version.compareTo(ProtocolVersion.MINECRAFT_1_20) >= 0) { this.portalCooldown = ProtocolUtils.readVarInt(buf); } + if (version.compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) { + this.dataToKeep = buf.readByte(); + } } @Override @@ -229,10 +230,10 @@ public class Respawn implements MinecraftPacket { buf.writeByte(previousGamemode); buf.writeBoolean(dimensionInfo.isDebugType()); buf.writeBoolean(dimensionInfo.isFlat()); - if (version.compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) { - buf.writeByte(dataToKeep); - } else { + if (version.compareTo(ProtocolVersion.MINECRAFT_1_19_3) < 0) { buf.writeBoolean(dataToKeep != 0); + } else if (version.compareTo(ProtocolVersion.MINECRAFT_1_20_2) < 0) { + buf.writeByte(dataToKeep); } } else { ProtocolUtils.writeString(buf, levelType); @@ -252,6 +253,10 @@ public class Respawn implements MinecraftPacket { if (version.compareTo(ProtocolVersion.MINECRAFT_1_20) >= 0) { ProtocolUtils.writeVarInt(buf, portalCooldown); } + + if (version.compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) { + buf.writeByte(dataToKeep); + } } @Override