3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2025-01-09 14:50:10 +01:00
Dieser Commit ist enthalten in:
Lechner Markus 2020-07-01 22:01:33 +02:00
Ursprung 5bea13c74e
Commit 4ba8996fed
3 geänderte Dateien mit 42 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -36,7 +36,8 @@ public enum ProtocolVersion {
MINECRAFT_1_15_1(575, "1.15.1"), MINECRAFT_1_15_1(575, "1.15.1"),
MINECRAFT_1_15_2(578, "1.15.2"), MINECRAFT_1_15_2(578, "1.15.2"),
MINECRAFT_1_16(735, "1.16"), MINECRAFT_1_16(735, "1.16"),
MINECRAFT_1_16_1(736, "1.16.1"); MINECRAFT_1_16_1(736, "1.16.1"),
MINECRAFT_1_16_2(738, "1.16.2");
private final int protocol; private final int protocol;
private final String name; private final String name;

Datei anzeigen

@ -7,6 +7,7 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_13;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_14; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_14;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_15; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_15;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16_2;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_4; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9_4;
@ -122,7 +123,8 @@ public enum StateRegistry {
map(0x18, MINECRAFT_1_12, false), map(0x18, MINECRAFT_1_12, false),
map(0x1D, MINECRAFT_1_13, false), map(0x1D, MINECRAFT_1_13, false),
map(0x1F, MINECRAFT_1_14, false), map(0x1F, MINECRAFT_1_14, false),
map(0x20, MINECRAFT_1_16, false)); map(0x20, MINECRAFT_1_16, false),
map(0x21, MINECRAFT_1_16_2, false));
clientbound.register(BossBar.class, BossBar::new, clientbound.register(BossBar.class, BossBar::new,
map(0x0C, MINECRAFT_1_9, false), map(0x0C, MINECRAFT_1_9, false),

Datei anzeigen

@ -17,7 +17,8 @@ public class JoinGame implements MinecraftPacket {
private int dimension; private int dimension;
private long partialHashedSeed; // 1.15+ private long partialHashedSeed; // 1.15+
private short difficulty; private short difficulty;
private short maxPlayers; private boolean isHardcore;
private int maxPlayers;
private @Nullable String levelType; private @Nullable String levelType;
private int viewDistance; // 1.14+ private int viewDistance; // 1.14+
private boolean reducedDebugInfo; private boolean reducedDebugInfo;
@ -62,11 +63,11 @@ public class JoinGame implements MinecraftPacket {
this.difficulty = difficulty; this.difficulty = difficulty;
} }
public short getMaxPlayers() { public int getMaxPlayers() {
return maxPlayers; return maxPlayers;
} }
public void setMaxPlayers(short maxPlayers) { public void setMaxPlayers(int maxPlayers) {
this.maxPlayers = maxPlayers; this.maxPlayers = maxPlayers;
} }
@ -118,6 +119,14 @@ public class JoinGame implements MinecraftPacket {
this.previousGamemode = previousGamemode; this.previousGamemode = previousGamemode;
} }
public boolean getIsHardcore() {
return isHardcore;
}
public void setIsHardcore(boolean isHardcore) {
this.isHardcore = isHardcore;
}
@Override @Override
public String toString() { public String toString() {
return "JoinGame{" return "JoinGame{"
@ -126,6 +135,7 @@ public class JoinGame implements MinecraftPacket {
+ ", dimension=" + dimension + ", dimension=" + dimension
+ ", partialHashedSeed=" + partialHashedSeed + ", partialHashedSeed=" + partialHashedSeed
+ ", difficulty=" + difficulty + ", difficulty=" + difficulty
+ ", isHardcore=" + isHardcore
+ ", maxPlayers=" + maxPlayers + ", maxPlayers=" + maxPlayers
+ ", levelType='" + levelType + '\'' + ", levelType='" + levelType + '\''
+ ", viewDistance=" + viewDistance + ", viewDistance=" + viewDistance
@ -139,7 +149,14 @@ public class JoinGame implements MinecraftPacket {
@Override @Override
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
this.entityId = buf.readInt(); this.entityId = buf.readInt();
this.gamemode = buf.readByte(); if (version.compareTo(ProtocolVersion.MINECRAFT_1_16_2) >= 0) {
this.isHardcore = buf.readBoolean();
this.gamemode = buf.readByte();
} else {
this.gamemode = buf.readByte();
this.isHardcore = (this.gamemode & 0x08) != 0;
this.gamemode &= ~0x08;
}
String dimensionIdentifier = null; String dimensionIdentifier = null;
String levelName = null; String levelName = null;
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
@ -160,7 +177,11 @@ public class JoinGame implements MinecraftPacket {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_15) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_15) >= 0) {
this.partialHashedSeed = buf.readLong(); this.partialHashedSeed = buf.readLong();
} }
this.maxPlayers = buf.readUnsignedByte(); if (version.compareTo(ProtocolVersion.MINECRAFT_1_16_2) >= 0) {
this.maxPlayers = ProtocolUtils.readVarInt(buf);
} else {
this.maxPlayers = buf.readUnsignedByte();
}
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) < 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) < 0) {
this.levelType = ProtocolUtils.readString(buf, 16); this.levelType = ProtocolUtils.readString(buf, 16);
} }
@ -181,7 +202,12 @@ public class JoinGame implements MinecraftPacket {
@Override @Override
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
buf.writeInt(entityId); buf.writeInt(entityId);
buf.writeByte(gamemode); if (version.compareTo(ProtocolVersion.MINECRAFT_1_16_2) >= 0) {
buf.writeBoolean(isHardcore);
buf.writeByte(gamemode);
} else {
buf.writeByte(isHardcore ? gamemode | 0x8 : gamemode);
}
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
buf.writeByte(previousGamemode); buf.writeByte(previousGamemode);
ProtocolUtils.writeStringArray(buf, dimensionRegistry.getLevelNames().toArray( ProtocolUtils.writeStringArray(buf, dimensionRegistry.getLevelNames().toArray(
@ -200,7 +226,11 @@ public class JoinGame implements MinecraftPacket {
if (version.compareTo(ProtocolVersion.MINECRAFT_1_15) >= 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_15) >= 0) {
buf.writeLong(partialHashedSeed); buf.writeLong(partialHashedSeed);
} }
buf.writeByte(maxPlayers); if (version.compareTo(ProtocolVersion.MINECRAFT_1_16_2) >= 0) {
ProtocolUtils.writeVarInt(buf, maxPlayers);
} else {
buf.writeByte(maxPlayers);
}
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) < 0) { if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) < 0) {
if (levelType == null) { if (levelType == null) {
throw new IllegalStateException("No level type specified."); throw new IllegalStateException("No level type specified.");