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 183dfbf4c..d60192074 100644 --- a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java +++ b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java @@ -54,7 +54,7 @@ public enum ProtocolVersion { MINECRAFT_1_16_2(751, "1.16.2"), MINECRAFT_1_16_3(753, "1.16.3"), MINECRAFT_1_16_4(754, "1.16.4", "1.16.5"), - MINECRAFT_1_17(-1, 7, "1.17"); // Note: Indev as of 20w45a (754, borked by Mojang) + MINECRAFT_1_17(-1, 8, "1.17"); // Note: Indev as of 20w45a (754, borked by Mojang) private static final int SNAPSHOT_BIT = 30; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/DimensionData.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/DimensionData.java index 406bce93a..7640d331f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/DimensionData.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/registry/DimensionData.java @@ -43,6 +43,8 @@ public final class DimensionData { private final @Nullable Boolean createDragonFight; private final @Nullable Double coordinateScale; private final @Nullable String effects; + private final @Nullable Integer minY; // Required and added by 1.17 + private final @Nullable Integer height; // Required and added by 1.17 /** * Initializes a new {@link DimensionData} instance. @@ -64,6 +66,8 @@ public final class DimensionData { * @param createDragonFight optional. Internal flag used in the end dimension * @param coordinateScale optional, unknown purpose * @param effects optional, unknown purpose + * @param minY the world effective lowest build-level + * @param height the world height above zero */ public DimensionData(String registryIdentifier, @Nullable Integer dimensionId, @@ -75,7 +79,8 @@ public final class DimensionData { int logicalHeight, String burningBehaviourIdentifier, @Nullable Long fixedTime, @Nullable Boolean createDragonFight, @Nullable Double coordinateScale, - @Nullable String effects) { + @Nullable String effects, + @Nullable Integer minY, @Nullable Integer height) { Preconditions.checkNotNull( registryIdentifier, "registryIdentifier cannot be null"); Preconditions.checkArgument(registryIdentifier.length() > 0, @@ -103,6 +108,8 @@ public final class DimensionData { this.createDragonFight = createDragonFight; this.coordinateScale = coordinateScale; this.effects = effects; + this.minY = minY; + this.height = height; } public String getRegistryIdentifier() { @@ -173,6 +180,14 @@ public final class DimensionData { return coordinateScale; } + public @Nullable Integer getMinY() { + return minY; + } + + public @Nullable Integer getHeight() { + return height; + } + /** * Returns a fresh {@link DimensionData} with the specified {@code registryIdentifier} * and {@code dimensionId}. @@ -186,7 +201,7 @@ public final class DimensionData { return new DimensionData(registryIdentifier, dimensionId, isNatural, ambientLight, isShrunk, isUltrawarm, hasCeiling, hasSkylight, isPiglinSafe, doBedsWork, doRespawnAnchorsWork, hasRaids, logicalHeight, burningBehaviourIdentifier, fixedTime, createDragonFight, - coordinateScale, effects); + coordinateScale, effects, minY, height); } public boolean isUnannotated() { @@ -223,11 +238,19 @@ public final class DimensionData { ? details.getDouble("coordinate_scale") : null; String effects = details.keySet().contains("effects") ? details.getString("effects") : null; + Integer minY = details.keySet().contains("min_y") ? details.getInt("min_y") : null; + Integer height = details.keySet().contains("height") ? details.getInt("height") : null; + if (version.compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) { + Preconditions.checkNotNull(height, + "DimensionData requires 'minY' to be present for this version"); + Preconditions.checkNotNull(minY, + "DimensionData requires 'height' to be present for this version"); + } return new DimensionData( UNKNOWN_DIMENSION_ID, null, isNatural, ambientLight, isShrunk, isUltrawarm, hasCeiling, hasSkylight, isPiglinSafe, doBedsWork, doRespawnAnchorsWork, hasRaids, logicalHeight, burningBehaviourIdentifier, fixedTime, hasEnderdragonFight, - coordinateScale, effects); + coordinateScale, effects, minY, height); } /** @@ -306,6 +329,12 @@ public final class DimensionData { if (effects != null) { ret.putString("effects", effects); } + if (minY != null) { + ret.putInt("min_y", minY); + } + if (height != null) { + ret.putInt("height", height); + } return ret.build(); } } 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 87bc5d091..c3c25d91c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java @@ -25,6 +25,7 @@ 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_16; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16_2; +import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_17; 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; @@ -145,25 +146,29 @@ public enum StateRegistry { clientbound.register(BossBar.class, BossBar::new, map(0x0C, MINECRAFT_1_9, false), map(0x0D, MINECRAFT_1_15, false), - map(0x0C, MINECRAFT_1_16, false)); + map(0x0C, MINECRAFT_1_16, false), + map(0x0D, MINECRAFT_1_17, false)); clientbound.register(Chat.class, Chat::new, map(0x02, MINECRAFT_1_7_2, true), map(0x0F, MINECRAFT_1_9, true), map(0x0E, MINECRAFT_1_13, true), map(0x0F, MINECRAFT_1_15, true), - map(0x0E, MINECRAFT_1_16, true)); + map(0x0E, MINECRAFT_1_16, true), + map(0x0F, MINECRAFT_1_17, true)); clientbound.register(TabCompleteResponse.class, TabCompleteResponse::new, map(0x3A, MINECRAFT_1_7_2, false), map(0x0E, MINECRAFT_1_9, false), map(0x10, MINECRAFT_1_13, false), map(0x11, MINECRAFT_1_15, false), map(0x10, MINECRAFT_1_16, false), - map(0x0F, MINECRAFT_1_16_2, false)); + map(0x0F, MINECRAFT_1_16_2, false), + map(0x10, MINECRAFT_1_17, false)); clientbound.register(AvailableCommands.class, AvailableCommands::new, map(0x11, MINECRAFT_1_13, false), map(0x12, MINECRAFT_1_15, false), map(0x11, MINECRAFT_1_16, false), - map(0x10, MINECRAFT_1_16_2, false)); + map(0x10, MINECRAFT_1_16_2, false), + map(0x11, MINECRAFT_1_17, false)); clientbound.register(PluginMessage.class, PluginMessage::new, map(0x3F, MINECRAFT_1_7_2, false), map(0x18, MINECRAFT_1_9, false), @@ -171,7 +176,8 @@ public enum StateRegistry { map(0x18, MINECRAFT_1_14, false), map(0x19, MINECRAFT_1_15, false), map(0x18, MINECRAFT_1_16, false), - map(0x17, MINECRAFT_1_16_2, false)); + map(0x17, MINECRAFT_1_16_2, false), + map(0x18, MINECRAFT_1_17, false)); clientbound.register(Disconnect.class, Disconnect::new, map(0x40, MINECRAFT_1_7_2, false), map(0x1A, MINECRAFT_1_9, false), @@ -179,7 +185,8 @@ public enum StateRegistry { map(0x1A, MINECRAFT_1_14, false), map(0x1B, MINECRAFT_1_15, false), map(0x1A, MINECRAFT_1_16, false), - map(0x19, MINECRAFT_1_16_2, false)); + map(0x19, MINECRAFT_1_16_2, false), + map(0x1A, MINECRAFT_1_17, false)); clientbound.register(KeepAlive.class, KeepAlive::new, map(0x00, MINECRAFT_1_7_2, false), map(0x1F, MINECRAFT_1_9, false), @@ -187,7 +194,8 @@ public enum StateRegistry { map(0x20, MINECRAFT_1_14, false), map(0x21, MINECRAFT_1_15, false), map(0x20, MINECRAFT_1_16, false), - map(0x1F, MINECRAFT_1_16_2, false)); + map(0x1F, MINECRAFT_1_16_2, false), + map(0x20, MINECRAFT_1_17, false)); clientbound.register(JoinGame.class, JoinGame::new, map(0x01, MINECRAFT_1_7_2, false), map(0x23, MINECRAFT_1_9, false), @@ -195,7 +203,8 @@ public enum StateRegistry { map(0x25, MINECRAFT_1_14, false), map(0x26, MINECRAFT_1_15, false), map(0x25, MINECRAFT_1_16, false), - map(0x24, MINECRAFT_1_16_2, false)); + map(0x24, MINECRAFT_1_16_2, false), + map(0x25, MINECRAFT_1_17, false)); clientbound.register(Respawn.class, Respawn::new, map(0x07, MINECRAFT_1_7_2, true), map(0x33, MINECRAFT_1_9, true), @@ -205,7 +214,8 @@ public enum StateRegistry { map(0x3A, MINECRAFT_1_14, true), map(0x3B, MINECRAFT_1_15, true), map(0x3A, MINECRAFT_1_16, true), - map(0x39, MINECRAFT_1_16_2, true)); + map(0x39, MINECRAFT_1_16_2, true), + map(0x3A, MINECRAFT_1_17, true)); clientbound.register(ResourcePackRequest.class, ResourcePackRequest::new, map(0x48, MINECRAFT_1_8, true), map(0x32, MINECRAFT_1_9, true), @@ -215,7 +225,8 @@ public enum StateRegistry { map(0x39, MINECRAFT_1_14, true), map(0x3A, MINECRAFT_1_15, true), map(0x39, MINECRAFT_1_16, true), - map(0x38, MINECRAFT_1_16_2, true)); + map(0x38, MINECRAFT_1_16_2, true), + map(0x39, MINECRAFT_1_17, true)); clientbound.register(HeaderAndFooter.class, HeaderAndFooter::new, map(0x47, MINECRAFT_1_8, true), map(0x48, MINECRAFT_1_9, true), @@ -225,7 +236,8 @@ public enum StateRegistry { map(0x4E, MINECRAFT_1_13, true), map(0x53, MINECRAFT_1_14, true), map(0x54, MINECRAFT_1_15, true), - map(0x53, MINECRAFT_1_16, true)); + map(0x53, MINECRAFT_1_16, true), + map(0x54, MINECRAFT_1_17, true)); clientbound.register(TitlePacket.class, TitlePacket::new, map(0x45, MINECRAFT_1_8, true), map(0x45, MINECRAFT_1_9, true), @@ -234,7 +246,8 @@ public enum StateRegistry { map(0x4B, MINECRAFT_1_13, true), map(0x4F, MINECRAFT_1_14, true), map(0x50, MINECRAFT_1_15, true), - map(0x4F, MINECRAFT_1_16, true)); + map(0x4F, MINECRAFT_1_16, true), + map(0x50, MINECRAFT_1_17, true)); clientbound.register(PlayerListItem.class, PlayerListItem::new, map(0x38, MINECRAFT_1_7_2, false), map(0x2D, MINECRAFT_1_9, false), @@ -243,7 +256,8 @@ public enum StateRegistry { map(0x33, MINECRAFT_1_14, false), map(0x34, MINECRAFT_1_15, false), map(0x33, MINECRAFT_1_16, false), - map(0x32, MINECRAFT_1_16_2, false)); + map(0x32, MINECRAFT_1_16_2, false), + map(0x33, MINECRAFT_1_17, false)); } }, LOGIN {