3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-16 21:10:30 +01:00

fix: Respawn packet codec for 1.20.2+ (#1156)

Dieser Commit ist enthalten in:
ishland 2023-12-11 23:11:22 +08:00 committet von GitHub
Ursprung b270206d2e
Commit c8ca28cd30
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -186,12 +186,10 @@ public class Respawn implements MinecraftPacket {
boolean isDebug = buf.readBoolean(); boolean isDebug = buf.readBoolean();
boolean isFlat = buf.readBoolean(); boolean isFlat = buf.readBoolean();
this.dimensionInfo = new DimensionInfo(dimensionIdentifier, levelName, isFlat, isDebug); 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(); this.dataToKeep = buf.readByte();
} else if (buf.readBoolean()) {
this.dataToKeep = 1;
} else {
this.dataToKeep = 0;
} }
} else { } else {
this.levelType = ProtocolUtils.readString(buf, 16); this.levelType = ProtocolUtils.readString(buf, 16);
@ -202,6 +200,9 @@ public class Respawn implements MinecraftPacket {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_20) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_20) >= 0) {
this.portalCooldown = ProtocolUtils.readVarInt(buf); this.portalCooldown = ProtocolUtils.readVarInt(buf);
} }
if (version.compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) {
this.dataToKeep = buf.readByte();
}
} }
@Override @Override
@ -229,10 +230,10 @@ public class Respawn implements MinecraftPacket {
buf.writeByte(previousGamemode); buf.writeByte(previousGamemode);
buf.writeBoolean(dimensionInfo.isDebugType()); buf.writeBoolean(dimensionInfo.isDebugType());
buf.writeBoolean(dimensionInfo.isFlat()); buf.writeBoolean(dimensionInfo.isFlat());
if (version.compareTo(ProtocolVersion.MINECRAFT_1_19_3) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_19_3) < 0) {
buf.writeByte(dataToKeep);
} else {
buf.writeBoolean(dataToKeep != 0); buf.writeBoolean(dataToKeep != 0);
} else if (version.compareTo(ProtocolVersion.MINECRAFT_1_20_2) < 0) {
buf.writeByte(dataToKeep);
} }
} else { } else {
ProtocolUtils.writeString(buf, levelType); ProtocolUtils.writeString(buf, levelType);
@ -252,6 +253,10 @@ public class Respawn implements MinecraftPacket {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_20) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_20) >= 0) {
ProtocolUtils.writeVarInt(buf, portalCooldown); ProtocolUtils.writeVarInt(buf, portalCooldown);
} }
if (version.compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) {
buf.writeByte(dataToKeep);
}
} }
@Override @Override