diff --git a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java index 5d12f710b..b6415af9b 100644 --- a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java +++ b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java @@ -56,7 +56,7 @@ public enum ProtocolVersion { MINECRAFT_1_16_4(754, "1.16.4", "1.16.5"), MINECRAFT_1_17(755, "1.17"), MINECRAFT_1_17_1(756, "1.17.1"), - MINECRAFT_1_18(-1, 43, "1.18"); // Snapshot: 21w39a, future protocol: 757 + MINECRAFT_1_18(-1, 44, "1.18"); // Snapshot: 21w40a, future protocol: 757 private static final int SNAPSHOT_BIT = 30; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java index a65946e08..bab367e49 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java @@ -27,6 +27,7 @@ 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_16_4; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_17; +import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_18; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_7_2; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_9; @@ -246,7 +247,8 @@ public enum StateRegistry { map(0x53, MINECRAFT_1_14, true), map(0x54, MINECRAFT_1_15, true), map(0x53, MINECRAFT_1_16, true), - map(0x5E, MINECRAFT_1_17, true)); + map(0x5E, MINECRAFT_1_17, true), + map(0x5F, MINECRAFT_1_18, true)); clientbound.register(LegacyTitlePacket.class, LegacyTitlePacket::new, map(0x45, MINECRAFT_1_8, true), map(0x45, MINECRAFT_1_9, true), @@ -257,13 +259,16 @@ public enum StateRegistry { map(0x50, MINECRAFT_1_15, true), map(0x4F, MINECRAFT_1_16, MINECRAFT_1_16_4, true)); clientbound.register(TitleSubtitlePacket.class, TitleSubtitlePacket::new, - map(0x57, MINECRAFT_1_17, true)); + map(0x57, MINECRAFT_1_17, true), + map(0x58, MINECRAFT_1_18, true)); clientbound.register(TitleTextPacket.class, TitleTextPacket::new, - map(0x59, MINECRAFT_1_17, true)); + map(0x59, MINECRAFT_1_17, true), + map(0x5A, MINECRAFT_1_18, true)); clientbound.register(TitleActionbarPacket.class, TitleActionbarPacket::new, map(0x41, MINECRAFT_1_17, true)); clientbound.register(TitleTimesPacket.class, TitleTimesPacket::new, - map(0x5A, MINECRAFT_1_17, true)); + map(0x5A, MINECRAFT_1_17, true), + map(0x5B, MINECRAFT_1_18, true)); clientbound.register(TitleClearPacket.class, TitleClearPacket::new, map(0x10, MINECRAFT_1_17, true)); clientbound.register(PlayerListItem.class, PlayerListItem::new, diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java index 26a293a1a..74e2956c0 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java @@ -50,6 +50,7 @@ public class JoinGame implements MinecraftPacket { private DimensionData currentDimensionData; // 1.16.2+ private short previousGamemode; // 1.16+ private CompoundBinaryTag biomeRegistry; // 1.16.2+ + private int simulationDistance; // 1.18+ public int getEntityId() { return entityId; @@ -163,6 +164,14 @@ public class JoinGame implements MinecraftPacket { return currentDimensionData; } + public int getSimulationDistance(){ + return simulationDistance; + } + + public void setSimulationDistance(int simulationDistance) { + this.simulationDistance = simulationDistance; + } + @Override public String toString() { return "JoinGame{" @@ -178,6 +187,7 @@ public class JoinGame implements MinecraftPacket { + ", dimensionRegistry='" + dimensionRegistry + '\'' + ", dimensionInfo='" + dimensionInfo + '\'' + ", previousGamemode=" + previousGamemode + + ", simulationDistance=" + simulationDistance + '}'; } @@ -271,6 +281,10 @@ public class JoinGame implements MinecraftPacket { } this.viewDistance = ProtocolUtils.readVarInt(buf); + if (version.compareTo(ProtocolVersion.MINECRAFT_1_18) >= 0) { + this.simulationDistance = ProtocolUtils.readVarInt(buf); + } + this.reducedDebugInfo = buf.readBoolean(); this.showRespawnScreen = buf.readBoolean(); boolean isDebug = buf.readBoolean(); @@ -360,6 +374,10 @@ public class JoinGame implements MinecraftPacket { buf.writeByte(maxPlayers); } ProtocolUtils.writeVarInt(buf, viewDistance); + if (version.compareTo(ProtocolVersion.MINECRAFT_1_18) >= 0) { + ProtocolUtils.writeVarInt(buf, simulationDistance); + } + buf.writeBoolean(reducedDebugInfo); buf.writeBoolean(showRespawnScreen); buf.writeBoolean(dimensionInfo.isDebugType());