Merge branch 'main' of github.com:Nan1t/NanoLimbo

This commit is contained in:
Nan1t 2022-12-11 11:33:55 +03:00
commit 04c1730da0
14 changed files with 218 additions and 74 deletions

View File

@ -22,6 +22,7 @@ The general features:
Symbol `X` means all minor versions. Symbol `X` means all minor versions.
- [x] 1.7.X
- [x] 1.8.X - [x] 1.8.X
- [x] 1.9.X - [x] 1.9.X
- [x] 1.10.X - [x] 1.10.X
@ -34,6 +35,7 @@ Symbol `X` means all minor versions.
- [x] 1.17.X - [x] 1.17.X
- [x] 1.18.X - [x] 1.18.X
- [x] 1.19 - [x] 1.19
- [x] 1.19.1
The server **doesn't** support snapshots. The server **doesn't** support snapshots.

View File

@ -1,6 +1,6 @@
plugins { plugins {
id 'java' id 'java'
id 'com.github.johnrengelman.shadow' version '7.0.0' id 'com.github.johnrengelman.shadow' version '7.1.2'
} }
group 'ru.nanit' group 'ru.nanit'
@ -20,12 +20,12 @@ repositories {
} }
dependencies { dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
implementation 'org.spongepowered:configurate-yaml:4.1.2' implementation 'org.spongepowered:configurate-yaml:4.1.2'
implementation 'io.netty:netty-all:4.1.77.Final' implementation 'io.netty:netty-all:4.1.85.Final'
implementation 'net.kyori:adventure-nbt:4.10.1' implementation 'net.kyori:adventure-nbt:4.12.0'
implementation 'com.grack:nanojson:1.7' implementation 'com.grack:nanojson:1.7'
} }
@ -41,4 +41,4 @@ shadowJar {
test { test {
useJUnitPlatform() useJUnitPlatform()
} }

View File

@ -46,6 +46,7 @@ import java.security.InvalidKeyException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
public class ClientConnection extends ChannelInboundHandlerAdapter { public class ClientConnection extends ChannelInboundHandlerAdapter {
@ -123,38 +124,48 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
return; return;
} }
writePacket(PacketSnapshots.PACKET_LOGIN_SUCCESS); sendPacket(PacketSnapshots.PACKET_LOGIN_SUCCESS);
updateState(State.PLAY); updateState(State.PLAY);
server.getConnections().addConnection(this); server.getConnections().addConnection(this);
writePacket(PacketSnapshots.PACKET_JOIN_GAME); Runnable sendPlayPackets = () -> {
writePacket(PacketSnapshots.PACKET_PLAYER_ABILITIES); writePacket(PacketSnapshots.PACKET_JOIN_GAME);
writePacket(PacketSnapshots.PACKET_PLAYER_POS); writePacket(PacketSnapshots.PACKET_PLAYER_ABILITIES);
writePacket(PacketSnapshots.PACKET_PLAYER_POS);
if (server.getConfig().isUsePlayerList() || clientVersion.equals(Version.V1_16_4)) if (clientVersion.moreOrEqual(Version.V1_19_3))
writePacket(PacketSnapshots.PACKET_PLAYER_INFO); writePacket(PacketSnapshots.PACKET_SPAWN_POSITION);
if (clientVersion.moreOrEqual(Version.V1_13)) { if (server.getConfig().isUsePlayerList() || clientVersion.equals(Version.V1_16_4))
writePacket(PacketSnapshots.PACKET_DECLARE_COMMANDS); writePacket(PacketSnapshots.PACKET_PLAYER_INFO);
if (PacketSnapshots.PACKET_PLUGIN_MESSAGE != null) if (clientVersion.moreOrEqual(Version.V1_13)) {
writePacket(PacketSnapshots.PACKET_PLUGIN_MESSAGE); writePacket(PacketSnapshots.PACKET_DECLARE_COMMANDS);
if (PacketSnapshots.PACKET_PLUGIN_MESSAGE != null)
writePacket(PacketSnapshots.PACKET_PLUGIN_MESSAGE);
}
if (PacketSnapshots.PACKET_BOSS_BAR != null && clientVersion.moreOrEqual(Version.V1_9))
writePacket(PacketSnapshots.PACKET_BOSS_BAR);
if (PacketSnapshots.PACKET_JOIN_MESSAGE != null)
writePacket(PacketSnapshots.PACKET_JOIN_MESSAGE);
if (PacketSnapshots.PACKET_TITLE_TITLE != null && clientVersion.moreOrEqual(Version.V1_8))
writeTitle();
if (PacketSnapshots.PACKET_HEADER_AND_FOOTER != null && clientVersion.moreOrEqual(Version.V1_8))
writePacket(PacketSnapshots.PACKET_HEADER_AND_FOOTER);
sendKeepAlive();
};
if (clientVersion.lessOrEqual(Version.V1_7_6)) {
this.channel.eventLoop().schedule(sendPlayPackets, 100, TimeUnit.MILLISECONDS);
} else {
sendPlayPackets.run();
} }
if (PacketSnapshots.PACKET_BOSS_BAR != null && clientVersion.moreOrEqual(Version.V1_9))
writePacket(PacketSnapshots.PACKET_BOSS_BAR);
if (PacketSnapshots.PACKET_JOIN_MESSAGE != null)
writePacket(PacketSnapshots.PACKET_JOIN_MESSAGE);
if (PacketSnapshots.PACKET_TITLE_TITLE != null)
writeTitle();
if (PacketSnapshots.PACKET_HEADER_AND_FOOTER != null)
writePacket(PacketSnapshots.PACKET_HEADER_AND_FOOTER);
sendKeepAlive();
} }
public void disconnectLogin(String reason) { public void disconnectLogin(String reason) {

View File

@ -33,6 +33,7 @@ public final class PacketSnapshots {
public static PacketSnapshot PACKET_LOGIN_SUCCESS; public static PacketSnapshot PACKET_LOGIN_SUCCESS;
public static PacketSnapshot PACKET_JOIN_GAME; public static PacketSnapshot PACKET_JOIN_GAME;
public static PacketSnapshot PACKET_SPAWN_POSITION;
public static PacketSnapshot PACKET_PLUGIN_MESSAGE; public static PacketSnapshot PACKET_PLUGIN_MESSAGE;
public static PacketSnapshot PACKET_PLAYER_ABILITIES; public static PacketSnapshot PACKET_PLAYER_ABILITIES;
public static PacketSnapshot PACKET_PLAYER_INFO; public static PacketSnapshot PACKET_PLAYER_INFO;
@ -99,8 +100,14 @@ public final class PacketSnapshots {
info.setGameMode(server.getConfig().getGameMode()); info.setGameMode(server.getConfig().getGameMode());
info.setUuid(uuid); info.setUuid(uuid);
PacketSpawnPosition packetSpawnPosition = new PacketSpawnPosition();
packetSpawnPosition.setX((long) server.getConfig().getSpawnPosition().getX());
packetSpawnPosition.setY((long) server.getConfig().getSpawnPosition().getY());
packetSpawnPosition.setZ((long) server.getConfig().getSpawnPosition().getZ());
PACKET_LOGIN_SUCCESS = PacketSnapshot.of(loginSuccess); PACKET_LOGIN_SUCCESS = PacketSnapshot.of(loginSuccess);
PACKET_JOIN_GAME = PacketSnapshot.of(joinGame); PACKET_JOIN_GAME = PacketSnapshot.of(joinGame);
PACKET_SPAWN_POSITION = PacketSnapshot.of(packetSpawnPosition);
PACKET_PLAYER_ABILITIES = PacketSnapshot.of(playerAbilities); PACKET_PLAYER_ABILITIES = PacketSnapshot.of(playerAbilities);
PACKET_PLAYER_POS = PacketSnapshot.of(positionAndLook); PACKET_PLAYER_POS = PacketSnapshot.of(positionAndLook);
PACKET_PLAYER_INFO = PacketSnapshot.of(info); PACKET_PLAYER_INFO = PacketSnapshot.of(info);

View File

@ -34,6 +34,9 @@ import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel; import java.nio.channels.ScatteringByteChannel;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.BitSet;
import java.util.EnumSet;
import java.util.UUID; import java.util.UUID;
public class ByteMessage extends ByteBuf { public class ByteMessage extends ByteBuf {
@ -190,6 +193,24 @@ public class ByteMessage extends ByteBuf {
} }
} }
public <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumset, Class<E> oclass) {
E[] enums = oclass.getEnumConstants();
BitSet bits = new BitSet(enums.length);
for (int i = 0; i < enums.length; ++i) {
bits.set(i, enumset.contains(enums[i]));
}
writeFixedBitSet(bits, enums.length, buf);
}
private static void writeFixedBitSet(BitSet bits, int size, ByteBuf buf) {
if (bits.length() > size) {
throw new StackOverflowError("BitSet too large (expected " + size + " got " + bits.size() + ")");
}
buf.writeBytes(Arrays.copyOf(bits.toByteArray(), (size + 8) >> 3));
}
/* Delegated methods */ /* Delegated methods */
@Override @Override

View File

@ -40,8 +40,10 @@ public class PacketLoginSuccess implements PacketOut {
public void encode(ByteMessage msg, Version version) { public void encode(ByteMessage msg, Version version) {
if (version.moreOrEqual(Version.V1_16)) { if (version.moreOrEqual(Version.V1_16)) {
msg.writeUuid(uuid); msg.writeUuid(uuid);
} else { } else if (version.moreOrEqual(Version.V1_7_6)) {
msg.writeString(uuid.toString()); msg.writeString(uuid.toString());
} else {
msg.writeString(uuid.toString().replace("-", ""));
} }
msg.writeString(username); msg.writeString(username);
if (version.moreOrEqual(Version.V1_19)) { if (version.moreOrEqual(Version.V1_19)) {

View File

@ -46,11 +46,9 @@ public class PacketChatMessage implements PacketOut {
msg.writeString(jsonData); msg.writeString(jsonData);
if (version.moreOrEqual(Version.V1_19_1)) { if (version.moreOrEqual(Version.V1_19_1)) {
msg.writeBoolean(position.index == PositionLegacy.ACTION_BAR.index); msg.writeBoolean(position.index == PositionLegacy.ACTION_BAR.index);
} } else if (version.moreOrEqual(Version.V1_19)) {
else if (version.moreOrEqual(Version.V1_19)) {
msg.writeVarInt(position.index); msg.writeVarInt(position.index);
} } else if (version.moreOrEqual(Version.V1_8)) {
else {
msg.writeByte(position.index); msg.writeByte(position.index);
} }

View File

@ -99,6 +99,14 @@ public class PacketJoinGame implements PacketOut {
public void encode(ByteMessage msg, Version version) { public void encode(ByteMessage msg, Version version) {
msg.writeInt(entityId); msg.writeInt(entityId);
if (version.fromTo(Version.V1_7_2, Version.V1_7_6)) {
msg.writeByte(gameMode == 3 ? 1 : gameMode);
msg.writeByte(dimensionRegistry.getDefaultDimension_1_16().getId());
msg.writeByte(0); // Difficulty
msg.writeByte(maxPlayers);
msg.writeString("flat"); // Level type
}
if (version.fromTo(Version.V1_8, Version.V1_9)) { if (version.fromTo(Version.V1_8, Version.V1_9)) {
msg.writeByte(gameMode); msg.writeByte(gameMode);
msg.writeByte(dimensionRegistry.getDefaultDimension_1_16().getId()); msg.writeByte(dimensionRegistry.getDefaultDimension_1_16().getId());

View File

@ -37,8 +37,10 @@ public class PacketKeepAlive implements Packet {
public void encode(ByteMessage msg, Version version) { public void encode(ByteMessage msg, Version version) {
if (version.moreOrEqual(Version.V1_12_2)) { if (version.moreOrEqual(Version.V1_12_2)) {
msg.writeLong(id); msg.writeLong(id);
} else { } else if (version.moreOrEqual(Version.V1_8)) {
msg.writeVarInt((int) id); msg.writeVarInt((int) id);
} else {
msg.writeInt((int) id);
} }
} }
@ -46,8 +48,10 @@ public class PacketKeepAlive implements Packet {
public void decode(ByteMessage msg, Version version) { public void decode(ByteMessage msg, Version version) {
if (version.moreOrEqual(Version.V1_12_2)) { if (version.moreOrEqual(Version.V1_12_2)) {
this.id = msg.readLong(); this.id = msg.readLong();
} else { } else if (version.moreOrEqual(Version.V1_8)) {
this.id = msg.readVarInt(); this.id = msg.readVarInt();
} else {
this.id = msg.readInt();
} }
} }

View File

@ -21,6 +21,7 @@ import ru.nanit.limbo.protocol.ByteMessage;
import ru.nanit.limbo.protocol.PacketOut; import ru.nanit.limbo.protocol.PacketOut;
import ru.nanit.limbo.protocol.registry.Version; import ru.nanit.limbo.protocol.registry.Version;
import java.util.EnumSet;
import java.util.UUID; import java.util.UUID;
/** /**
@ -46,17 +47,49 @@ public class PacketPlayerInfo implements PacketOut {
@Override @Override
public void encode(ByteMessage msg, Version version) { public void encode(ByteMessage msg, Version version) {
msg.writeVarInt(0); // Add player action if (version.less(Version.V1_8)) {
msg.writeVarInt(1); msg.writeString(username);
msg.writeUuid(uuid); msg.writeBoolean(true); // Is online
msg.writeString(username); msg.writeShort(0);
msg.writeVarInt(0); } else {
msg.writeVarInt(gameMode); if (version.moreOrEqual(Version.V1_19_3)) {
msg.writeVarInt(60); EnumSet<Action> actions = EnumSet.noneOf(Action.class);
msg.writeBoolean(false); actions.add(Action.ADD_PLAYER);
if (version.moreOrEqual(Version.V1_19)) { actions.add(Action.UPDATE_LISTED);
actions.add(Action.UPDATE_GAMEMODE);
msg.writeEnumSet(actions, Action.class);
msg.writeVarInt(1); // Array length (1 element)
msg.writeUuid(uuid); // UUID
msg.writeString(username); //Username
msg.writeVarInt(0); //Properties (0 is empty)
msg.writeBoolean(true); //Update listed
msg.writeVarInt(gameMode); //Gamemode
return;
}
msg.writeVarInt(0); // Add player action
msg.writeVarInt(1);
msg.writeUuid(uuid);
msg.writeString(username);
msg.writeVarInt(0);
msg.writeVarInt(gameMode);
msg.writeVarInt(60);
msg.writeBoolean(false); msg.writeBoolean(false);
if (version.moreOrEqual(Version.V1_19)) {
msg.writeBoolean(false);
}
} }
} }
public static enum Action {
ADD_PLAYER,
INITIALIZE_CHAT,
UPDATE_GAMEMODE,
UPDATE_LISTED,
UPDATE_LATENCY,
UPDATE_DISPLAY_NAME;
}
} }

View File

@ -62,15 +62,18 @@ public class PacketPlayerPositionAndLook implements PacketOut {
@Override @Override
public void encode(ByteMessage msg, Version version) { public void encode(ByteMessage msg, Version version) {
msg.writeDouble(x); msg.writeDouble(x);
msg.writeDouble(y); msg.writeDouble(y + (version.less(Version.V1_8) ? 1.62F : 0));
msg.writeDouble(z); msg.writeDouble(z);
msg.writeFloat(yaw); msg.writeFloat(yaw);
msg.writeFloat(pitch); msg.writeFloat(pitch);
if (version.less(Version.V1_9)) { if (version.moreOrEqual(Version.V1_8)) {
msg.writeBoolean(true); // On ground
} else {
msg.writeByte(flags); msg.writeByte(flags);
} else {
msg.writeBoolean(true);
}
if (version.moreOrEqual(Version.V1_9)) {
msg.writeVarInt(teleportId); msg.writeVarInt(teleportId);
} }

View File

@ -0,0 +1,34 @@
package ru.nanit.limbo.protocol.packets.play;
import ru.nanit.limbo.protocol.ByteMessage;
import ru.nanit.limbo.protocol.PacketOut;
import ru.nanit.limbo.protocol.registry.Version;
public class PacketSpawnPosition implements PacketOut {
private long x;
private long y;
private long z;
public void setX(long x) {
this.x = x;
}
public void setY(long y) {
this.y = y;
}
public void setZ(long z) {
this.z = z;
}
@Override
public void encode(ByteMessage msg, Version version) {
msg.writeLong(encodePosition(x, y ,z));
msg.writeFloat(0);
}
private static long encodePosition(long x, long y, long z) {
return ((x & 0x3FFFFFF) << 38) | ((z & 0x3FFFFFF) << 12) | (y & 0xFFF);
}
}

View File

@ -77,7 +77,7 @@ public enum State {
PLAY(3) { PLAY(3) {
{ {
serverBound.register(PacketKeepAlive::new, serverBound.register(PacketKeepAlive::new,
map(0x00, V1_8, V1_8), map(0x00, V1_7_2, V1_8),
map(0x0B, V1_9, V1_11_1), map(0x0B, V1_9, V1_11_1),
map(0x0C, V1_12, V1_12), map(0x0C, V1_12, V1_12),
map(0x0B, V1_12_1, V1_12_2), map(0x0B, V1_12_1, V1_12_2),
@ -86,7 +86,8 @@ public enum State {
map(0x10, V1_16, V1_16_4), map(0x10, V1_16, V1_16_4),
map(0x0F, V1_17, V1_18_2), map(0x0F, V1_17, V1_18_2),
map(0x11, V1_19, V1_19), map(0x11, V1_19, V1_19),
map(0x12, V1_19_1, V1_19_1) map(0x12, V1_19_1, V1_19_1),
map(0x11, V1_19_3, V1_19_3)
); );
clientBound.register(PacketDeclareCommands::new, clientBound.register(PacketDeclareCommands::new,
@ -95,10 +96,11 @@ public enum State {
map(0x11, V1_16, V1_16_1), map(0x11, V1_16, V1_16_1),
map(0x10, V1_16_2, V1_16_4), map(0x10, V1_16_2, V1_16_4),
map(0x12, V1_17, V1_18_2), map(0x12, V1_17, V1_18_2),
map(0x0F, V1_19, V1_19_1) map(0x0F, V1_19, V1_19_1),
map(0x0E, V1_19_3, V1_19_3)
); );
clientBound.register(PacketJoinGame::new, clientBound.register(PacketJoinGame::new,
map(0x01, V1_8, V1_8), map(0x01, V1_7_2, V1_8),
map(0x23, V1_9, V1_12_2), map(0x23, V1_9, V1_12_2),
map(0x25, V1_13, V1_14_4), map(0x25, V1_13, V1_14_4),
map(0x26, V1_15, V1_15_2), map(0x26, V1_15, V1_15_2),
@ -106,7 +108,8 @@ public enum State {
map(0x24, V1_16_2, V1_16_4), map(0x24, V1_16_2, V1_16_4),
map(0x26, V1_17, V1_18_2), map(0x26, V1_17, V1_18_2),
map(0x23, V1_19, V1_19), map(0x23, V1_19, V1_19),
map(0x25, V1_19_1, V1_19_1) map(0x25, V1_19_1, V1_19_1),
map(0x24, V1_19_3, V1_19_3)
); );
clientBound.register(PacketPluginMessage::new, clientBound.register(PacketPluginMessage::new,
map(0x19, V1_13, V1_13_2), map(0x19, V1_13, V1_13_2),
@ -116,10 +119,11 @@ public enum State {
map(0x17, V1_16_2, V1_16_4), map(0x17, V1_16_2, V1_16_4),
map(0x18, V1_17, V1_18_2), map(0x18, V1_17, V1_18_2),
map(0x15, V1_19, V1_19), map(0x15, V1_19, V1_19),
map(0x16, V1_19_1, V1_19_1) map(0x16, V1_19_1, V1_19_1),
map(0x15, V1_19_3, V1_19_3)
); );
clientBound.register(PacketPlayerAbilities::new, clientBound.register(PacketPlayerAbilities::new,
map(0x39, V1_8, V1_8), map(0x39, V1_7_2, V1_8),
map(0x2B, V1_9, V1_12), map(0x2B, V1_9, V1_12),
map(0x2C, V1_12_1, V1_12_2), map(0x2C, V1_12_1, V1_12_2),
map(0x2E, V1_13, V1_13_2), map(0x2E, V1_13, V1_13_2),
@ -129,10 +133,11 @@ public enum State {
map(0x30, V1_16_2, V1_16_4), map(0x30, V1_16_2, V1_16_4),
map(0x32, V1_17, V1_18_2), map(0x32, V1_17, V1_18_2),
map(0x2F, V1_19, V1_19), map(0x2F, V1_19, V1_19),
map(0x31, V1_19_1, V1_19_1) map(0x31, V1_19_1, V1_19_1),
map(0x30, V1_19_3, V1_19_3)
); );
clientBound.register(PacketPlayerPositionAndLook::new, clientBound.register(PacketPlayerPositionAndLook::new,
map(0x08, V1_8, V1_8), map(0x08, V1_7_2, V1_8),
map(0x2E, V1_9, V1_12), map(0x2E, V1_9, V1_12),
map(0x2F, V1_12_1, V1_12_2), map(0x2F, V1_12_1, V1_12_2),
map(0x32, V1_13, V1_13_2), map(0x32, V1_13, V1_13_2),
@ -142,10 +147,11 @@ public enum State {
map(0x34, V1_16_2, V1_16_4), map(0x34, V1_16_2, V1_16_4),
map(0x38, V1_17, V1_18_2), map(0x38, V1_17, V1_18_2),
map(0x36, V1_19, V1_19), map(0x36, V1_19, V1_19),
map(0x39, V1_19_1, V1_19_1) map(0x39, V1_19_1, V1_19_1),
map(0x38, V1_19_3, V1_19_3)
); );
clientBound.register(PacketKeepAlive::new, clientBound.register(PacketKeepAlive::new,
map(0x00, V1_8, V1_8), map(0x00, V1_7_2, V1_8),
map(0x1F, V1_9, V1_12_2), map(0x1F, V1_9, V1_12_2),
map(0x21, V1_13, V1_13_2), map(0x21, V1_13, V1_13_2),
map(0x20, V1_14, V1_14_4), map(0x20, V1_14, V1_14_4),
@ -154,27 +160,29 @@ public enum State {
map(0x1F, V1_16_2, V1_16_4), map(0x1F, V1_16_2, V1_16_4),
map(0x21, V1_17, V1_18_2), map(0x21, V1_17, V1_18_2),
map(0x1E, V1_19, V1_19), map(0x1E, V1_19, V1_19),
map(0x20, V1_19_1, V1_19_1) map(0x20, V1_19_1, V1_19_1),
map(0x1F, V1_19_3, V1_19_3)
); );
clientBound.register(PacketChatMessage::new, clientBound.register(PacketChatMessage::new,
map(0x02, V1_8, V1_8), map(0x02, V1_7_2, V1_8),
map(0x0F, V1_9, V1_12_2), map(0x0F, V1_9, V1_12_2),
map(0x0E, V1_13, V1_14_4), map(0x0E, V1_13, V1_14_4),
map(0x0F, V1_15, V1_15_2), map(0x0F, V1_15, V1_15_2),
map(0x0E, V1_16, V1_16_4), map(0x0E, V1_16, V1_16_4),
map(0x0F, V1_17, V1_18_2), map(0x0F, V1_17, V1_18_2),
map(0x5F, V1_19, V1_19), map(0x5F, V1_19, V1_19),
map(0x62, V1_19_1, V1_19_1) map(0x62, V1_19_1, V1_19_1),
map(0x60, V1_19_3, V1_19_3)
); );
clientBound.register(PacketBossBar::new, clientBound.register(PacketBossBar::new,
map(0x0C, V1_9, V1_14_4), map(0x0C, V1_9, V1_14_4),
map(0x0D, V1_15, V1_15_2), map(0x0D, V1_15, V1_15_2),
map(0x0C, V1_16, V1_16_4), map(0x0C, V1_16, V1_16_4),
map(0x0D, V1_17, V1_18_2), map(0x0D, V1_17, V1_18_2),
map(0x0A, V1_19, V1_19_1) map(0x0A, V1_19, V1_19_3)
); );
clientBound.register(PacketPlayerInfo::new, clientBound.register(PacketPlayerInfo::new,
map(0x38, V1_8, V1_8), map(0x38, V1_7_2, V1_8),
map(0x2D, V1_9, V1_12), map(0x2D, V1_9, V1_12),
map(0x2E, V1_12_1, V1_12_2), map(0x2E, V1_12_1, V1_12_2),
map(0x30, V1_13, V1_13_2), map(0x30, V1_13, V1_13_2),
@ -184,7 +192,8 @@ public enum State {
map(0x32, V1_16_2, V1_16_4), map(0x32, V1_16_2, V1_16_4),
map(0x36, V1_17, V1_18_2), map(0x36, V1_17, V1_18_2),
map(0x34, V1_19, V1_19), map(0x34, V1_19, V1_19),
map(0x37, V1_19_1, V1_19_1) map(0x37, V1_19_1, V1_19_1),
map(0x36, V1_19_3, V1_19_3)
); );
clientBound.register(PacketTitleLegacy::new, clientBound.register(PacketTitleLegacy::new,
map(0x45, V1_8, V1_11_1), map(0x45, V1_8, V1_11_1),
@ -198,17 +207,20 @@ public enum State {
clientBound.register(PacketTitleSetTitle::new, clientBound.register(PacketTitleSetTitle::new,
map(0x59, V1_17, V1_17_1), map(0x59, V1_17, V1_17_1),
map(0x5A, V1_18, V1_19), map(0x5A, V1_18, V1_19),
map(0x5D, V1_19_1, V1_19_1) map(0x5D, V1_19_1, V1_19_1),
map(0x5B, V1_19_3, V1_19_3)
); );
clientBound.register(PacketTitleSetSubTitle::new, clientBound.register(PacketTitleSetSubTitle::new,
map(0x57, V1_17, V1_17_1), map(0x57, V1_17, V1_17_1),
map(0x58, V1_18, V1_19), map(0x58, V1_18, V1_19),
map(0x5B, V1_19_1, V1_19_1) map(0x5B, V1_19_1, V1_19_1),
map(0x59, V1_19_3, V1_19_3)
); );
clientBound.register(PacketTitleTimes::new, clientBound.register(PacketTitleTimes::new,
map(0x5A, V1_17, V1_17_1), map(0x5A, V1_17, V1_17_1),
map(0x5B, V1_18, V1_19), map(0x5B, V1_18, V1_19),
map(0x5E, V1_19_1, V1_19_1) map(0x5E, V1_19_1, V1_19_1),
map(0x5C, V1_19_3, V1_19_3)
); );
clientBound.register(PacketPlayerListHeader::new, clientBound.register(PacketPlayerListHeader::new,
map(0x47, V1_8, V1_8), map(0x47, V1_8, V1_8),
@ -223,7 +235,11 @@ public enum State {
map(0x5E, V1_17, V1_17_1), map(0x5E, V1_17, V1_17_1),
map(0x5F, V1_18, V1_18_2), map(0x5F, V1_18, V1_18_2),
map(0x60, V1_19, V1_19), map(0x60, V1_19, V1_19),
map(0x63, V1_19_1, V1_19_1) map(0x63, V1_19_1, V1_19_1),
map(0x61, V1_19_3, V1_19_3)
);
clientBound.register(PacketSpawnPosition::new,
map(0x4C, V1_19_3, V1_19_3)
); );
} }
}; };

View File

@ -23,6 +23,10 @@ import java.util.Map;
public enum Version { public enum Version {
UNDEFINED(-1), UNDEFINED(-1),
V1_7_2(4),
// 1.7.2-1.7.5 has same protocol numbers
V1_7_6(5),
// 1.7.6-1.7.10 has same protocol numbers
V1_8(47), V1_8(47),
// 1.8-1.8.8 has same protocol numbers // 1.8-1.8.8 has same protocol numbers
V1_9(107), V1_9(107),
@ -60,7 +64,8 @@ public enum Version {
// 1.18.1 has same protocol number // 1.18.1 has same protocol number
V1_18_2(758), V1_18_2(758),
V1_19(759), V1_19(759),
V1_19_1(760); V1_19_1(760),
V1_19_3(761);
private static final Map<Integer, Version> VERSION_MAP; private static final Map<Integer, Version> VERSION_MAP;
private static final Version MAX; private static final Version MAX;
@ -119,7 +124,7 @@ public enum Version {
} }
public static Version getMin() { public static Version getMin() {
return V1_8; return V1_7_2;
} }
public static Version getMax() { public static Version getMax() {