13
0
geforkt von Mirrors/Velocity

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 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