Skip to content

Commit 2889eb3

Browse files
committed
1.0.3 Release: 1.20.2 protocol support
1 parent f8fcb00 commit 2889eb3

File tree

6 files changed

+36
-4
lines changed

6 files changed

+36
-4
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.2
1+
1.0.3

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
setGroup("net.elytrium")
12-
setVersion("1.0.2")
12+
setVersion("1.0.3")
1313

1414
compileJava {
1515
getOptions().setEncoding("UTF-8")

src/main/java/net/elytrium/limbohub/LimboHub.java

+13
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ public void reload() {
356356
new PacketMapping(0x04, ProtocolVersion.MINECRAFT_1_16, true),
357357
new PacketMapping(0x02, ProtocolVersion.MINECRAFT_1_19, true),
358358
new PacketMapping(0x03, ProtocolVersion.MINECRAFT_1_19_4, true),
359+
// There is no SpawnPlayer packet since Minecraft 1.20.2
359360
})
360361
.registerPacket(PacketDirection.CLIENTBOUND, CloseContainer.class, CloseContainer::new, new PacketMapping[]{
361362
new PacketMapping(0x2E, ProtocolVersion.MINECRAFT_1_8, true),
@@ -368,6 +369,7 @@ public void reload() {
368369
new PacketMapping(0x10, ProtocolVersion.MINECRAFT_1_19, true),
369370
new PacketMapping(0x0F, ProtocolVersion.MINECRAFT_1_19_3, true),
370371
new PacketMapping(0x11, ProtocolVersion.MINECRAFT_1_19_4, true),
372+
new PacketMapping(0x12, ProtocolVersion.MINECRAFT_1_20_2, true),
371373
})
372374
.registerPacket(PacketDirection.CLIENTBOUND, SetContainerContent.class, SetContainerContent::new, new PacketMapping[]{
373375
new PacketMapping(0x30, ProtocolVersion.MINECRAFT_1_8, true),
@@ -381,6 +383,7 @@ public void reload() {
381383
new PacketMapping(0x11, ProtocolVersion.MINECRAFT_1_19, true),
382384
new PacketMapping(0x10, ProtocolVersion.MINECRAFT_1_19_3, true),
383385
new PacketMapping(0x12, ProtocolVersion.MINECRAFT_1_19_4, true),
386+
new PacketMapping(0x13, ProtocolVersion.MINECRAFT_1_20_2, true),
384387
})
385388
.registerPacket(PacketDirection.CLIENTBOUND, SetContainerSlot.class, SetContainerSlot::new, new PacketMapping[]{
386389
new PacketMapping(0x2F, ProtocolVersion.MINECRAFT_1_8, true),
@@ -394,6 +397,7 @@ public void reload() {
394397
new PacketMapping(0x13, ProtocolVersion.MINECRAFT_1_19, true),
395398
new PacketMapping(0x12, ProtocolVersion.MINECRAFT_1_19_3, true),
396399
new PacketMapping(0x14, ProtocolVersion.MINECRAFT_1_19_4, true),
400+
new PacketMapping(0x15, ProtocolVersion.MINECRAFT_1_20_2, true),
397401
})
398402
.registerPacket(PacketDirection.CLIENTBOUND, OpenScreen.class, OpenScreen::new, new PacketMapping[]{
399403
new PacketMapping(0x2D, ProtocolVersion.MINECRAFT_1_8, true),
@@ -408,6 +412,7 @@ public void reload() {
408412
new PacketMapping(0x2D, ProtocolVersion.MINECRAFT_1_19_1, true),
409413
new PacketMapping(0x2C, ProtocolVersion.MINECRAFT_1_19_3, true),
410414
new PacketMapping(0x30, ProtocolVersion.MINECRAFT_1_19_4, true),
415+
new PacketMapping(0x31, ProtocolVersion.MINECRAFT_1_20_2, true),
411416
})
412417
.registerPacket(PacketDirection.CLIENTBOUND, SetHeadRotation.class, SetHeadRotation::new, new PacketMapping[]{
413418
new PacketMapping(0x19, ProtocolVersion.MINECRAFT_1_8, true),
@@ -424,6 +429,7 @@ public void reload() {
424429
new PacketMapping(0x3F, ProtocolVersion.MINECRAFT_1_19_1, true),
425430
new PacketMapping(0x3E, ProtocolVersion.MINECRAFT_1_19_3, true),
426431
new PacketMapping(0x42, ProtocolVersion.MINECRAFT_1_19_4, true),
432+
new PacketMapping(0x44, ProtocolVersion.MINECRAFT_1_20_2, true),
427433
})
428434
.registerPacket(PacketDirection.CLIENTBOUND, DisplayObjective.class, DisplayObjective::new, new PacketMapping[]{
429435
new PacketMapping(0x3D, ProtocolVersion.MINECRAFT_1_8, true),
@@ -437,6 +443,7 @@ public void reload() {
437443
new PacketMapping(0x4F, ProtocolVersion.MINECRAFT_1_19_1, true),
438444
new PacketMapping(0x4D, ProtocolVersion.MINECRAFT_1_19_3, true),
439445
new PacketMapping(0x51, ProtocolVersion.MINECRAFT_1_19_4, true),
446+
new PacketMapping(0x53, ProtocolVersion.MINECRAFT_1_20_2, true),
440447
})
441448
.registerPacket(PacketDirection.CLIENTBOUND, SetEntityMetadata.class, SetEntityMetadata::new, new PacketMapping[]{
442449
new PacketMapping(0x1C, ProtocolVersion.MINECRAFT_1_8, true),
@@ -450,6 +457,7 @@ public void reload() {
450457
new PacketMapping(0x50, ProtocolVersion.MINECRAFT_1_19_1, true),
451458
new PacketMapping(0x4E, ProtocolVersion.MINECRAFT_1_19_3, true),
452459
new PacketMapping(0x52, ProtocolVersion.MINECRAFT_1_19_4, true),
460+
new PacketMapping(0x54, ProtocolVersion.MINECRAFT_1_20_2, true),
453461
})
454462
.registerPacket(PacketDirection.CLIENTBOUND, UpdateObjectives.class, UpdateObjectives::new, new PacketMapping[]{
455463
new PacketMapping(0x3B, ProtocolVersion.MINECRAFT_1_8, true),
@@ -463,6 +471,7 @@ public void reload() {
463471
new PacketMapping(0x56, ProtocolVersion.MINECRAFT_1_19_1, true),
464472
new PacketMapping(0x54, ProtocolVersion.MINECRAFT_1_19_3, true),
465473
new PacketMapping(0x58, ProtocolVersion.MINECRAFT_1_19_4, true),
474+
new PacketMapping(0x5A, ProtocolVersion.MINECRAFT_1_20_2, true),
466475
})
467476
.registerPacket(PacketDirection.CLIENTBOUND, ScoreboardTeam.class, ScoreboardTeam::new, new PacketMapping[]{
468477
new PacketMapping(0x3E, ProtocolVersion.MINECRAFT_1_8, true),
@@ -476,6 +485,7 @@ public void reload() {
476485
new PacketMapping(0x58, ProtocolVersion.MINECRAFT_1_19_1, true),
477486
new PacketMapping(0x56, ProtocolVersion.MINECRAFT_1_19_3, true),
478487
new PacketMapping(0x5A, ProtocolVersion.MINECRAFT_1_19_4, true),
488+
new PacketMapping(0x5C, ProtocolVersion.MINECRAFT_1_20_2, true),
479489
})
480490
.registerPacket(PacketDirection.CLIENTBOUND, UpdateScore.class, UpdateScore::new, new PacketMapping[]{
481491
new PacketMapping(0x3C, ProtocolVersion.MINECRAFT_1_8, true),
@@ -489,6 +499,7 @@ public void reload() {
489499
new PacketMapping(0x59, ProtocolVersion.MINECRAFT_1_19_1, true),
490500
new PacketMapping(0x57, ProtocolVersion.MINECRAFT_1_19_3, true),
491501
new PacketMapping(0x5B, ProtocolVersion.MINECRAFT_1_19_4, true),
502+
new PacketMapping(0x5D, ProtocolVersion.MINECRAFT_1_20_2, true),
492503
})
493504
.registerPacket(PacketDirection.SERVERBOUND, Interact.class, Interact::new, new PacketMapping[]{
494505
new PacketMapping(0x02, ProtocolVersion.MINECRAFT_1_8, false),
@@ -502,6 +513,7 @@ public void reload() {
502513
new PacketMapping(0x10, ProtocolVersion.MINECRAFT_1_19_1, false),
503514
new PacketMapping(0x0F, ProtocolVersion.MINECRAFT_1_19_3, false),
504515
new PacketMapping(0x10, ProtocolVersion.MINECRAFT_1_19_4, false),
516+
new PacketMapping(0x12, ProtocolVersion.MINECRAFT_1_20_2, true),
505517
})
506518
.registerPacket(PacketDirection.SERVERBOUND, ClickContainer.class, ClickContainer::new, new PacketMapping[]{
507519
new PacketMapping(0x0E, ProtocolVersion.MINECRAFT_1_8, false),
@@ -515,6 +527,7 @@ public void reload() {
515527
new PacketMapping(0x0B, ProtocolVersion.MINECRAFT_1_19_1, false),
516528
new PacketMapping(0x0A, ProtocolVersion.MINECRAFT_1_19_3, false),
517529
new PacketMapping(0x0B, ProtocolVersion.MINECRAFT_1_19_4, false),
530+
new PacketMapping(0x0D, ProtocolVersion.MINECRAFT_1_20_2, true),
518531
});
519532

520533
this.commands.clear();

src/main/java/net/elytrium/limbohub/entities/NPC.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ public void spawn(LimboPlayer player) {
110110
);
111111
}
112112

113-
player.writePacketAndFlush(new SpawnPlayer(this.entityId, this.uuid, this.positionX, this.positionY, this.positionZ, this.yaw, this.pitch));
113+
if (player.getProxyPlayer().getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) {
114+
player.writePacketAndFlush(new SpawnEntity(this.entityId, this.uuid, Player::getEntityType,
115+
this.positionX, this.positionY, this.positionZ, this.pitch, this.yaw, this.yaw, 0));
116+
} else {
117+
player.writePacketAndFlush(new SpawnPlayer(this.entityId, this.uuid, this.positionX, this.positionY, this.positionZ, this.yaw, this.pitch));
118+
}
119+
114120
player.writePacketAndFlush(new SetHeadRotation(this.entityId, this.yaw));
115121
player.writePacketAndFlush(new ScoreboardTeam("sb" + this.entityId, (byte) 0, "never",
116122
"always", 0, Component.empty(), Component.empty(), List.of(this.username)));

src/main/java/net/elytrium/limbohub/protocol/entities/Player.java

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424

2525
public class Player {
2626

27+
public static int getEntityType(ProtocolVersion version) {
28+
if (version.compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) {
29+
return 122;
30+
} else {
31+
throw new IllegalArgumentException("Player is not supported on versions below Minecraft 1.20.2");
32+
}
33+
}
34+
2735
public static EntityMetadata buildSkinPartsMetadata(ProtocolVersion version, byte skinParts) {
2836
if (version.compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) {
2937
return new EntityMetadata(Map.of((byte) 17, new EntityMetadataByteEntry(skinParts)));

src/main/java/net/elytrium/limbohub/protocol/packets/DisplayObjective.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersi
4444

4545
@Override
4646
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
47-
buf.writeByte(this.position);
47+
if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_20_2) >= 0) {
48+
ProtocolUtils.writeVarInt(buf, this.position);
49+
} else {
50+
buf.writeByte(this.position);
51+
}
52+
4853
ProtocolUtils.writeString(buf, this.scoreName);
4954
}
5055

0 commit comments

Comments
 (0)