Skip to content

Commit 349ef51

Browse files
UserNuggetJNNGL
andauthored
Add 1.20.2 support (#74)
* 1.20.2 support * Change version to 1.1.13-SNAPSHOT --------- Co-authored-by: jnngl <jnngles@gmail.com>
1 parent 945cae7 commit 349ef51

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
setGroup("net.elytrium")
12-
setVersion("1.1.12")
12+
setVersion("1.1.13-SNAPSHOT")
1313

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

src/main/java/net/elytrium/limbofilter/LimboFilter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ public void reload() {
277277
new PacketMapping(0x10, ProtocolVersion.MINECRAFT_1_19_1, false),
278278
new PacketMapping(0x0F, ProtocolVersion.MINECRAFT_1_19_3, false),
279279
new PacketMapping(0x10, ProtocolVersion.MINECRAFT_1_19_4, false),
280+
new PacketMapping(0x12, ProtocolVersion.MINECRAFT_1_20_2, false),
280281
})
281282
.registerPacket(PacketDirection.CLIENTBOUND, SetEntityMetadata.class, SetEntityMetadata::new, new PacketMapping[]{
282283
new PacketMapping(0x1C, ProtocolVersion.MINIMUM_VERSION, true),
@@ -290,6 +291,7 @@ public void reload() {
290291
new PacketMapping(0x50, ProtocolVersion.MINECRAFT_1_19_1, true),
291292
new PacketMapping(0x4E, ProtocolVersion.MINECRAFT_1_19_3, true),
292293
new PacketMapping(0x52, ProtocolVersion.MINECRAFT_1_19_4, true),
294+
new PacketMapping(0x54, ProtocolVersion.MINECRAFT_1_20_2, true),
293295
})
294296
.registerPacket(PacketDirection.CLIENTBOUND, SpawnEntity.class, SpawnEntity::new, new PacketMapping[]{
295297
new PacketMapping(0x0E, ProtocolVersion.MINIMUM_VERSION, true),

src/main/java/net/elytrium/limbofilter/protocol/data/EntityMetadata.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
import com.velocitypowered.api.network.ProtocolVersion;
2121
import com.velocitypowered.proxy.protocol.ProtocolUtils;
2222
import io.netty.buffer.ByteBuf;
23+
import io.netty.buffer.ByteBufOutputStream;
24+
import io.netty.handler.codec.EncoderException;
2325
import java.util.Map;
2426
import net.elytrium.limboapi.api.material.VirtualItem;
27+
import net.kyori.adventure.nbt.BinaryTagTypes;
2528
import net.kyori.adventure.nbt.CompoundBinaryTag;
2629

2730
public class EntityMetadata {
@@ -85,7 +88,17 @@ public void encode(ByteBuf buf, ProtocolVersion protocolVersion) {
8588
buf.writeByte(0);
8689
}
8790
} else {
88-
ProtocolUtils.writeCompoundTag(buf, this.nbt);
91+
if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_20_2) < 0) {
92+
ProtocolUtils.writeCompoundTag(buf, this.nbt);
93+
} else {
94+
// TODO: remove then the ProtocolUtils::writeCompoundTag will support 1.20.2
95+
try (ByteBufOutputStream output = new ByteBufOutputStream(buf)) {
96+
output.writeByte(BinaryTagTypes.COMPOUND.id());
97+
BinaryTagTypes.COMPOUND.write(this.nbt, output);
98+
} catch (Throwable throwable) {
99+
throw new EncoderException("Unable to encode NBT CompoundTag");
100+
}
101+
}
89102
}
90103
}
91104
}

0 commit comments

Comments
 (0)