From 7e377842c3020c9349a4cf8222ed35724898c87a Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 26 Sep 2023 20:50:08 +0100 Subject: [PATCH] Rename and document packets --- .../gjum/minecraft/mapsync/common/MapSyncMod.java | 8 ++++---- .../minecraft/mapsync/common/net/ClientHandler.java | 8 ++++---- ...cketDecoder.java => ClientboundPacketDecoder.java} | 8 ++++---- ...cketEncoder.java => ServerboundPacketEncoder.java} | 10 +++++----- .../gjum/minecraft/mapsync/common/net/SyncClient.java | 10 +++++----- .../mapsync/common/net/packet/ChunkTilePacket.java | 7 +++++++ ... => ClientboundChunkTimestampsResponsePacket.java} | 11 ++++++++--- ...t.java => ClientboundEncryptionRequestPacket.java} | 10 +++++++--- ...ps.java => ClientboundRegionTimestampsPacket.java} | 11 ++++++++--- ...uest.java => ServerboundCatchupRequestPacket.java} | 10 ++++++++-- ...a => ServerboundChunkTimestampsRequestPacket.java} | 9 +++++++-- ....java => ServerboundEncryptionResponsePacket.java} | 11 ++++++++--- ...Handshake.java => ServerboundHandshakePacket.java} | 9 ++++++--- 13 files changed, 81 insertions(+), 41 deletions(-) rename mod/common/src/main/java/gjum/minecraft/mapsync/common/net/{ServerPacketDecoder.java => ClientboundPacketDecoder.java} (69%) rename mod/common/src/main/java/gjum/minecraft/mapsync/common/net/{ClientPacketEncoder.java => ServerboundPacketEncoder.java} (56%) rename mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/{SCatchup.java => ClientboundChunkTimestampsResponsePacket.java} (72%) rename mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/{SEncryptionRequest.java => ClientboundEncryptionRequestPacket.java} (74%) rename mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/{SRegionTimestamps.java => ClientboundRegionTimestampsPacket.java} (71%) rename mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/{CCatchupRequest.java => ServerboundCatchupRequestPacket.java} (75%) rename mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/{CRegionCatchup.java => ServerboundChunkTimestampsRequestPacket.java} (63%) rename mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/{CEncryptionResponse.java => ServerboundEncryptionResponsePacket.java} (53%) rename mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/{CHandshake.java => ServerboundHandshakePacket.java} (71%) diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/MapSyncMod.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/MapSyncMod.java index d484ee61..1813dfe3 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/MapSyncMod.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/MapSyncMod.java @@ -219,7 +219,7 @@ public void handleSyncServerEncryptionSuccess() { // TODO tell server our current dimension } - public void handleRegionTimestamps(SRegionTimestamps packet, SyncClient client) { + public void handleRegionTimestamps(ClientboundRegionTimestampsPacket packet, SyncClient client) { DimensionState dimension = getDimensionState(); if (dimension == null) return; if (!dimension.dimension.location().toString().equals(packet.getDimension())) { @@ -241,7 +241,7 @@ public void handleRegionTimestamps(SRegionTimestamps packet, SyncClient client) } } - client.send(new CRegionCatchup(packet.getDimension(), outdatedRegions)); + client.send(new ServerboundChunkTimestampsRequestPacket(packet.getDimension(), outdatedRegions)); } public void handleSharedChunk(ChunkTile chunkTile) { @@ -255,7 +255,7 @@ public void handleSharedChunk(ChunkTile chunkTile) { dimensionState.processSharedChunk(chunkTile); } - public void handleCatchupData(SCatchup packet) { + public void handleCatchupData(ClientboundChunkTimestampsResponsePacket packet) { var dimensionState = getDimensionState(); if (dimensionState == null) return; debugLog("received catchup: " + packet.chunks.size() + " " + packet.chunks.get(0).syncClient.address); @@ -276,7 +276,7 @@ public void requestCatchupData(List chunks) { } for (List chunksForServer : byServer.values()) { SyncClient client = chunksForServer.get(0).syncClient; - client.send(new CCatchupRequest(chunksForServer)); + client.send(new ServerboundCatchupRequestPacket(chunksForServer)); } } diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ClientHandler.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ClientHandler.java index 44584f0b..37e2fa90 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ClientHandler.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ClientHandler.java @@ -24,18 +24,18 @@ public ClientHandler(SyncClient client) { public void channelRead(ChannelHandlerContext ctx, Object packet) { try { if (!client.isEncrypted()) { - if (packet instanceof SEncryptionRequest pktEncryptionRequest) { + if (packet instanceof ClientboundEncryptionRequestPacket pktEncryptionRequest) { client.setUpEncryption(ctx, pktEncryptionRequest); } else throw new Error("Expected encryption request, got " + packet); } else if (packet instanceof ChunkTilePacket pktChunkTile) { getMod().handleSharedChunk(pktChunkTile.chunkTile); - } else if (packet instanceof SRegionTimestamps pktRegionTimestamps) { + } else if (packet instanceof ClientboundRegionTimestampsPacket pktRegionTimestamps) { getMod().handleRegionTimestamps(pktRegionTimestamps, client); - } else if (packet instanceof SCatchup pktCatchup) { + } else if (packet instanceof ClientboundChunkTimestampsResponsePacket pktCatchup) { for (CatchupChunk chunk : pktCatchup.chunks) { chunk.syncClient = this.client; } - getMod().handleCatchupData((SCatchup) packet); + getMod().handleCatchupData((ClientboundChunkTimestampsResponsePacket) packet); } else throw new Error("Expected packet, got " + packet); } catch (Throwable err) { err.printStackTrace(); diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ServerPacketDecoder.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ClientboundPacketDecoder.java similarity index 69% rename from mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ServerPacketDecoder.java rename to mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ClientboundPacketDecoder.java index 84398f87..aac61eb0 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ServerPacketDecoder.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ClientboundPacketDecoder.java @@ -8,12 +8,12 @@ import java.util.List; -public class ServerPacketDecoder extends ReplayingDecoder { +public class ClientboundPacketDecoder extends ReplayingDecoder { public static @Nullable Packet constructServerPacket(int id, ByteBuf buf) { if (id == ChunkTilePacket.PACKET_ID) return ChunkTilePacket.read(buf); - if (id == SEncryptionRequest.PACKET_ID) return SEncryptionRequest.read(buf); - if (id == SCatchup.PACKET_ID) return SCatchup.read(buf); - if (id == SRegionTimestamps.PACKET_ID) return SRegionTimestamps.read(buf); + if (id == ClientboundEncryptionRequestPacket.PACKET_ID) return ClientboundEncryptionRequestPacket.read(buf); + if (id == ClientboundChunkTimestampsResponsePacket.PACKET_ID) return ClientboundChunkTimestampsResponsePacket.read(buf); + if (id == ClientboundRegionTimestampsPacket.PACKET_ID) return ClientboundRegionTimestampsPacket.read(buf); return null; } diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ClientPacketEncoder.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ServerboundPacketEncoder.java similarity index 56% rename from mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ClientPacketEncoder.java rename to mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ServerboundPacketEncoder.java index cd7d93ef..56f8b746 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ClientPacketEncoder.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/ServerboundPacketEncoder.java @@ -5,13 +5,13 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; -public class ClientPacketEncoder extends MessageToByteEncoder { +public class ServerboundPacketEncoder extends MessageToByteEncoder { public static int getClientPacketId(Packet packet) { if (packet instanceof ChunkTilePacket) return ChunkTilePacket.PACKET_ID; - if (packet instanceof CHandshake) return CHandshake.PACKET_ID; - if (packet instanceof CEncryptionResponse) return CEncryptionResponse.PACKET_ID; - if (packet instanceof CCatchupRequest) return CCatchupRequest.PACKET_ID; - if (packet instanceof CRegionCatchup) return CRegionCatchup.PACKET_ID; + if (packet instanceof ServerboundHandshakePacket) return ServerboundHandshakePacket.PACKET_ID; + if (packet instanceof ServerboundEncryptionResponsePacket) return ServerboundEncryptionResponsePacket.PACKET_ID; + if (packet instanceof ServerboundCatchupRequestPacket) return ServerboundCatchupRequestPacket.PACKET_ID; + if (packet instanceof ServerboundChunkTimestampsRequestPacket) return ServerboundChunkTimestampsRequestPacket.PACKET_ID; throw new IllegalArgumentException("Unknown client packet class " + packet); } diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/SyncClient.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/SyncClient.java index 27770da1..693fd17b 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/SyncClient.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/SyncClient.java @@ -113,8 +113,8 @@ public void initChannel(SocketChannel ch) { ch.pipeline().addLast( new LengthFieldPrepender(4), new LengthFieldBasedFrameDecoder(1 << 15, 0, 4, 0, 4), - new ServerPacketDecoder(), - new ClientPacketEncoder(), + new ClientboundPacketDecoder(), + new ServerboundPacketEncoder(), new ClientHandler(SyncClient.this)); } }); @@ -127,7 +127,7 @@ public void initChannel(SocketChannel ch) { channelFuture.addListener(future -> { if (future.isSuccess()) { logger.info("[map-sync] Connected to " + address); - channelFuture.channel().writeAndFlush(new CHandshake( + channelFuture.channel().writeAndFlush(new ServerboundHandshakePacket( getMod().getVersion(), Minecraft.getInstance().getUser().getName(), gameAddress, @@ -239,7 +239,7 @@ public synchronized void shutDown() { } } - void setUpEncryption(ChannelHandlerContext ctx, SEncryptionRequest packet) { + void setUpEncryption(ChannelHandlerContext ctx, ClientboundEncryptionRequestPacket packet) { try { byte[] sharedSecret = new byte[16]; ThreadLocalRandom.current().nextBytes(sharedSecret); @@ -260,7 +260,7 @@ void setUpEncryption(ChannelHandlerContext ctx, SEncryptionRequest packet) { session.getGameProfile(), session.getAccessToken(), shaHex); try { - ctx.channel().writeAndFlush(new CEncryptionResponse( + ctx.channel().writeAndFlush(new ServerboundEncryptionResponsePacket( encrypt(packet.publicKey, sharedSecret), encrypt(packet.publicKey, packet.verifyToken))); } catch (NoSuchAlgorithmException | InvalidKeyException | NoSuchPaddingException | BadPaddingException | diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ChunkTilePacket.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ChunkTilePacket.java index c35b2eda..73840b4d 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ChunkTilePacket.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ChunkTilePacket.java @@ -6,6 +6,13 @@ import javax.annotation.Nonnull; +/** + * This packet is sent in two situations: + * + * 1. Clients are relaying chunk data to each other in real time. + * + * 2. You have requested synchronisation via {@link ServerboundCatchupRequestPacket}. + */ public class ChunkTilePacket extends Packet { public static final int PACKET_ID = 4; diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/SCatchup.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ClientboundChunkTimestampsResponsePacket.java similarity index 72% rename from mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/SCatchup.java rename to mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ClientboundChunkTimestampsResponsePacket.java index ccbbac1b..f41ddf5e 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/SCatchup.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ClientboundChunkTimestampsResponsePacket.java @@ -13,7 +13,12 @@ import static gjum.minecraft.mapsync.common.Utils.readStringFromBuf; -public class SCatchup extends Packet { +/** + * You'll receive this in response to a sent {@link ServerboundChunkTimestampsRequestPacket}, + * containing an elaboration of chunk timestamps of all the regions you listed. + * You should respond with a {@link ServerboundCatchupRequestPacket}. + */ +public class ClientboundChunkTimestampsResponsePacket extends Packet { public static final int PACKET_ID = 5; /** @@ -21,7 +26,7 @@ public class SCatchup extends Packet { */ public final @Nonnull List chunks; - public SCatchup(@Nonnull List chunks) { + public ClientboundChunkTimestampsResponsePacket(@Nonnull List chunks) { this.chunks = chunks; } @@ -39,7 +44,7 @@ public static Packet read(ByteBuf buf) { dimension, chunk_x, chunk_z, timestamp); chunks.add(chunk); } - return new SCatchup(chunks); + return new ClientboundChunkTimestampsResponsePacket(chunks); } @Override diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/SEncryptionRequest.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ClientboundEncryptionRequestPacket.java similarity index 74% rename from mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/SEncryptionRequest.java rename to mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ClientboundEncryptionRequestPacket.java index c89557ed..f6ec8692 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/SEncryptionRequest.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ClientboundEncryptionRequestPacket.java @@ -8,7 +8,11 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; -public class SEncryptionRequest extends Packet { +/** + * You will receive this in response to {@link ServerboundHandshakePacket}, and + * will expect a {@link ServerboundEncryptionResponsePacket} in response. + */ +public class ClientboundEncryptionRequestPacket extends Packet { public static final int PACKET_ID = 2; @Nonnull @@ -16,13 +20,13 @@ public class SEncryptionRequest extends Packet { @Nonnull public final byte[] verifyToken; - public SEncryptionRequest(@Nonnull PublicKey publicKey, @Nonnull byte[] verifyToken) { + public ClientboundEncryptionRequestPacket(@Nonnull PublicKey publicKey, @Nonnull byte[] verifyToken) { this.publicKey = publicKey; this.verifyToken = verifyToken; } public static Packet read(ByteBuf buf) { - return new SEncryptionRequest( + return new ClientboundEncryptionRequestPacket( readKey(buf), readByteArray(buf)); } diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/SRegionTimestamps.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ClientboundRegionTimestampsPacket.java similarity index 71% rename from mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/SRegionTimestamps.java rename to mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ClientboundRegionTimestampsPacket.java index 17a921ad..2408432f 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/SRegionTimestamps.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ClientboundRegionTimestampsPacket.java @@ -5,14 +5,19 @@ import gjum.minecraft.mapsync.common.net.Packet; import io.netty.buffer.ByteBuf; -public class SRegionTimestamps extends Packet { +/** + * This is the packet for the first-stage of the synchronisation process. It's + * sent immediately after you've been authenticated. You should respond with a + * {@link ServerboundChunkTimestampsRequestPacket}. + */ +public class ClientboundRegionTimestampsPacket extends Packet { public static final int PACKET_ID = 7; private final String dimension; private final RegionTimestamp[] timestamps; - public SRegionTimestamps(String dimension, RegionTimestamp[] timestamps) { + public ClientboundRegionTimestampsPacket(String dimension, RegionTimestamp[] timestamps) { this.dimension = dimension; this.timestamps = timestamps; } @@ -39,7 +44,7 @@ public static Packet read(ByteBuf buf) { timestamps[i] = new RegionTimestamp(regionX, regionZ, timestamp); } - return new SRegionTimestamps(dimension, timestamps); + return new ClientboundRegionTimestampsPacket(dimension, timestamps); } @Override diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CCatchupRequest.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundCatchupRequestPacket.java similarity index 75% rename from mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CCatchupRequest.java rename to mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundCatchupRequestPacket.java index 104bb20b..a348e9b2 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CCatchupRequest.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundCatchupRequestPacket.java @@ -11,7 +11,13 @@ import static gjum.minecraft.mapsync.common.Utils.writeStringToBuf; -public class CCatchupRequest extends Packet { +/** + * This is the final stage in the synchronisation process, sent in response to + * a received {@link ClientboundChunkTimestampsResponsePacket}. Here you list + * what chunks you'd like to receive from the server, who'll then respond with + * a bunch of {@link ChunkTilePacket}. + */ +public class ServerboundCatchupRequestPacket extends Packet { public static final int PACKET_ID = 6; /** @@ -22,7 +28,7 @@ public class CCatchupRequest extends Packet { /** * Chunks must all be in the same dimension */ - public CCatchupRequest(@Nonnull List chunks) { + public ServerboundCatchupRequestPacket(@Nonnull List chunks) { if (chunks.isEmpty()) throw new Error("Chunks list must not be empty"); ResourceKey dim = null; for (CatchupChunk chunk : chunks) { diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CRegionCatchup.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundChunkTimestampsRequestPacket.java similarity index 63% rename from mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CRegionCatchup.java rename to mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundChunkTimestampsRequestPacket.java index ead829bd..d163bb0d 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CRegionCatchup.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundChunkTimestampsRequestPacket.java @@ -7,13 +7,18 @@ import java.util.List; -public class CRegionCatchup extends Packet { +/** + * You send this in response to a {@link ClientboundRegionTimestampsPacket}, + * listing all the regions you'd like the server to elaborate on. You should + * expect a {@link ClientboundChunkTimestampsResponsePacket}. + */ +public class ServerboundChunkTimestampsRequestPacket extends Packet { public static final int PACKET_ID = 8; private final String dimension; private final List regions; - public CRegionCatchup(String dimension, List regions) { + public ServerboundChunkTimestampsRequestPacket(String dimension, List regions) { this.dimension = dimension; this.regions = regions; } diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CEncryptionResponse.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundEncryptionResponsePacket.java similarity index 53% rename from mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CEncryptionResponse.java rename to mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundEncryptionResponsePacket.java index 5b7606d8..f6555ff5 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CEncryptionResponse.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundEncryptionResponsePacket.java @@ -3,7 +3,12 @@ import gjum.minecraft.mapsync.common.net.Packet; import io.netty.buffer.ByteBuf; -public class CEncryptionResponse extends Packet { +/** + * This is sent to the server in response to a {@link ClientboundEncryptionRequestPacket}, + * after which, if the connection persists, you are considered authenticated + * with the server. You should then receive a {@link ClientboundRegionTimestampsPacket}. + */ +public class ServerboundEncryptionResponsePacket extends Packet { public static final int PACKET_ID = 3; /** @@ -15,13 +20,13 @@ public class CEncryptionResponse extends Packet { */ public final byte[] verifyToken; - public CEncryptionResponse(byte[] sharedSecret, byte[] verifyToken) { + public ServerboundEncryptionResponsePacket(byte[] sharedSecret, byte[] verifyToken) { this.sharedSecret = sharedSecret; this.verifyToken = verifyToken; } public static Packet read(ByteBuf buf) { - return new CEncryptionResponse(readByteArray(buf), readByteArray(buf)); + return new ServerboundEncryptionResponsePacket(readByteArray(buf), readByteArray(buf)); } @Override diff --git a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CHandshake.java b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundHandshakePacket.java similarity index 71% rename from mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CHandshake.java rename to mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundHandshakePacket.java index f6c2de26..efc7e78a 100644 --- a/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/CHandshake.java +++ b/mod/common/src/main/java/gjum/minecraft/mapsync/common/net/packet/ServerboundHandshakePacket.java @@ -4,10 +4,13 @@ import io.netty.buffer.ByteBuf; import org.jetbrains.annotations.NotNull; -import static gjum.minecraft.mapsync.common.Utils.readStringFromBuf; import static gjum.minecraft.mapsync.common.Utils.writeStringToBuf; -public class CHandshake extends Packet { +/** + * This should be sent to the server IMMEDIATELY upon connection. If the + * server accepts the connection, you will receive a {@link ClientboundEncryptionRequestPacket}. + */ +public class ServerboundHandshakePacket extends Packet { public static final int PACKET_ID = 1; public final @NotNull String modVersion; @@ -15,7 +18,7 @@ public class CHandshake extends Packet { public final @NotNull String gameAddress; public final @NotNull String world; - public CHandshake(@NotNull String modVersion, @NotNull String username, @NotNull String gameAddress, @NotNull String world) { + public ServerboundHandshakePacket(@NotNull String modVersion, @NotNull String username, @NotNull String gameAddress, @NotNull String world) { this.modVersion = modVersion; this.username = username; this.gameAddress = gameAddress;