Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Symbol `X` means all minor versions.
- [x] 1.18.X
- [x] 1.19.X
- [x] 1.20.X
- [x] 1.21
- [x] 1.21.X

The server **doesn't** support snapshots.

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/ua/nanit/limbo/connection/PacketHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
import ua.nanit.limbo.LimboConstants;
import ua.nanit.limbo.protocol.packets.PacketHandshake;
import ua.nanit.limbo.protocol.packets.configuration.PacketFinishConfiguration;
import ua.nanit.limbo.protocol.packets.login.PacketLoginAcknowledged;
import ua.nanit.limbo.protocol.packets.login.PacketLoginPluginRequest;
import ua.nanit.limbo.protocol.packets.login.PacketLoginPluginResponse;
import ua.nanit.limbo.protocol.packets.login.PacketLoginStart;
import ua.nanit.limbo.protocol.packets.configuration.PacketPlayerLoaded;
import ua.nanit.limbo.protocol.packets.login.*;
import ua.nanit.limbo.protocol.packets.status.PacketStatusPing;
import ua.nanit.limbo.protocol.packets.status.PacketStatusRequest;
import ua.nanit.limbo.protocol.packets.status.PacketStatusResponse;
Expand Down Expand Up @@ -137,4 +135,7 @@ public void handle(ClientConnection conn, PacketFinishConfiguration packet) {
conn.spawnPlayer();
}

public void handle(ClientConnection conn, PacketPlayerLoaded packet) {
}

}
4 changes: 2 additions & 2 deletions src/main/java/ua/nanit/limbo/connection/PacketSnapshots.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ public static void initPackets(LimboServer server) {

PACKET_REGISTRY_DATA = PacketSnapshot.of(packetRegistryData);

Dimension dimension1_21 = server.getDimensionRegistry().getDimension_1_21();
Dimension dimension1_21_4 = server.getDimensionRegistry().getDimension_1_21_4();
List<PacketSnapshot> packetRegistries = new ArrayList<>();
CompoundBinaryTag dimensionTag = dimension1_21.getData();
CompoundBinaryTag dimensionTag = dimension1_21_4.getData();
for (String registryType : dimensionTag.keySet()) {
CompoundBinaryTag compoundRegistryType = dimensionTag.getCompound(registryType);

Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This packet is called ClientSettings and in this particular case there seems to be no point in decoding it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did you find the name of ClientSettings? Is there documentation available on this new packet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not long ago, the popular wiki for minecraft protocol - wiki.vg was closed, but the information is transferred to a new wiki here:
https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Protocol

The packet with the number 0x00 in the configuration phase of Serverbound is a ClientSettings packet, in addition to the fact that it has a locale field, your packet is missing 8 more fields.
And as I already said, decoding this packet is not required at all

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ua.nanit.limbo.protocol.packets.configuration;

import ua.nanit.limbo.connection.ClientConnection;
import ua.nanit.limbo.protocol.ByteMessage;
import ua.nanit.limbo.protocol.PacketIn;
import ua.nanit.limbo.protocol.registry.Version;
import ua.nanit.limbo.server.LimboServer;
import ua.nanit.limbo.server.Log;

public class PacketPlayerLoaded implements PacketIn {

private String locale;

public String getLocale() {
return locale;
}

@Override
public void decode(ByteMessage msg, Version version) {
locale = msg.readString();
}

@Override
public void handle(ClientConnection conn, LimboServer server) {
server.getPacketHandler().handle(conn, this);
}

@Override
public String toString() {
return getClass().getSimpleName();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void encode(ByteMessage msg, Version version) {
if (version.moreOrEqual(Version.V1_19)) {
msg.writeVarInt(0);
}
if (version.moreOrEqual(Version.V1_20_5)) {
if (version.fromTo(Version.V1_20_5, Version.V1_21)) {
msg.writeBoolean(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import ua.nanit.limbo.protocol.ByteMessage;
import ua.nanit.limbo.protocol.PacketOut;
import ua.nanit.limbo.protocol.registry.Version;
import ua.nanit.limbo.server.Log;
import ua.nanit.limbo.world.DimensionRegistry;

public class PacketJoinGame implements PacketOut {
Expand Down Expand Up @@ -280,7 +281,7 @@ public void encode(ByteMessage msg, Version version) {
msg.writeVarInt(0);
}

if (version.moreOrEqual(Version.V1_20_5)) {
if (version.fromTo(Version.V1_20_5, Version.V1_21)) {
msg.writeBoolean(isHardcore);
msg.writeStringsArray(worldNames);
msg.writeVarInt(maxPlayers);
Expand All @@ -300,6 +301,50 @@ public void encode(ByteMessage msg, Version version) {
msg.writeVarInt(0);
msg.writeBoolean(secureProfile);
}

if (version.equals(Version.V1_21_2)) {
msg.writeBoolean(isHardcore);
msg.writeStringsArray(worldNames);
msg.writeVarInt(maxPlayers);
msg.writeVarInt(viewDistance);
msg.writeVarInt(viewDistance); // Simulation Distance
msg.writeBoolean(reducedDebugInfo);
msg.writeBoolean(enableRespawnScreen);
msg.writeBoolean(limitedCrafting);
msg.writeVarInt(dimensionRegistry.getDimension_1_21().getId());
msg.writeString(worldName);
msg.writeLong(hashedSeed);
msg.writeByte(gameMode);
msg.writeByte(previousGameMode);
msg.writeBoolean(isDebug);
msg.writeBoolean(isFlat);
msg.writeBoolean(false);
msg.writeVarInt(0);
msg.writeVarInt(0);
msg.writeBoolean(secureProfile);
}

if (version.moreOrEqual(Version.V1_21_4)) {
msg.writeBoolean(isHardcore);
msg.writeStringsArray(worldNames);
msg.writeVarInt(maxPlayers);
msg.writeVarInt(viewDistance);
msg.writeVarInt(viewDistance); // Simulation Distance
msg.writeBoolean(reducedDebugInfo);
msg.writeBoolean(enableRespawnScreen);
msg.writeBoolean(limitedCrafting);
msg.writeVarInt(dimensionRegistry.getDimension_1_21_4().getId());
msg.writeString(worldName);
msg.writeLong(hashedSeed);
msg.writeByte(gameMode);
msg.writeByte(previousGameMode);
msg.writeBoolean(isDebug);
msg.writeBoolean(isFlat);
msg.writeBoolean(false);
msg.writeVarInt(0);
msg.writeVarInt(0);
msg.writeBoolean(secureProfile);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import ua.nanit.limbo.protocol.ByteMessage;
import ua.nanit.limbo.protocol.Packet;
import ua.nanit.limbo.protocol.registry.Version;
import ua.nanit.limbo.server.Log;

public class PacketKeepAlive implements Packet {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class PacketPlayerPositionAndLook implements PacketOut {
private float pitch;
private int teleportId;

public PacketPlayerPositionAndLook() {}
public PacketPlayerPositionAndLook() {
}

public PacketPlayerPositionAndLook(double x, double y, double z, float yaw, float pitch, int teleportId) {
this.x = x;
Expand All @@ -43,6 +44,15 @@ public PacketPlayerPositionAndLook(double x, double y, double z, float yaw, floa

@Override
public void encode(ByteMessage msg, Version version) {
if (version.moreOrEqual(Version.V1_21_2)) {
encodeModern(msg, version);
return;
}

encodeLegacy(msg, version);
}

private void encodeLegacy(ByteMessage msg, Version version) {
msg.writeDouble(x);
msg.writeDouble(y + (version.less(Version.V1_8) ? 1.62F : 0));
msg.writeDouble(z);
Expand All @@ -64,4 +74,20 @@ public void encode(ByteMessage msg, Version version) {
}
}

private void encodeModern(ByteMessage msg, Version version) {
msg.writeVarInt(teleportId);

msg.writeDouble(x);
msg.writeDouble(y);
msg.writeDouble(z);

msg.writeDouble(0);
msg.writeDouble(0);
msg.writeDouble(0);

msg.writeFloat(yaw);
msg.writeFloat(pitch);

msg.writeInt(0x08);
}
}
Loading