Skip to content

Commit

Permalink
Add 1.20.2 support (#74)
Browse files Browse the repository at this point in the history
* 1.20.2 support

* Change version to 1.1.13-SNAPSHOT

---------

Co-authored-by: jnngl <[email protected]>
  • Loading branch information
UserNugget and JNNGL authored Oct 28, 2023
1 parent 945cae7 commit 349ef51
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

setGroup("net.elytrium")
setVersion("1.1.12")
setVersion("1.1.13-SNAPSHOT")

compileJava {
getOptions().setEncoding("UTF-8")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/elytrium/limbofilter/LimboFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ public void reload() {
new PacketMapping(0x10, ProtocolVersion.MINECRAFT_1_19_1, false),
new PacketMapping(0x0F, ProtocolVersion.MINECRAFT_1_19_3, false),
new PacketMapping(0x10, ProtocolVersion.MINECRAFT_1_19_4, false),
new PacketMapping(0x12, ProtocolVersion.MINECRAFT_1_20_2, false),
})
.registerPacket(PacketDirection.CLIENTBOUND, SetEntityMetadata.class, SetEntityMetadata::new, new PacketMapping[]{
new PacketMapping(0x1C, ProtocolVersion.MINIMUM_VERSION, true),
Expand All @@ -290,6 +291,7 @@ public void reload() {
new PacketMapping(0x50, ProtocolVersion.MINECRAFT_1_19_1, true),
new PacketMapping(0x4E, ProtocolVersion.MINECRAFT_1_19_3, true),
new PacketMapping(0x52, ProtocolVersion.MINECRAFT_1_19_4, true),
new PacketMapping(0x54, ProtocolVersion.MINECRAFT_1_20_2, true),
})
.registerPacket(PacketDirection.CLIENTBOUND, SpawnEntity.class, SpawnEntity::new, new PacketMapping[]{
new PacketMapping(0x0E, ProtocolVersion.MINIMUM_VERSION, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.handler.codec.EncoderException;
import java.util.Map;
import net.elytrium.limboapi.api.material.VirtualItem;
import net.kyori.adventure.nbt.BinaryTagTypes;
import net.kyori.adventure.nbt.CompoundBinaryTag;

public class EntityMetadata {
Expand Down Expand Up @@ -85,7 +88,17 @@ public void encode(ByteBuf buf, ProtocolVersion protocolVersion) {
buf.writeByte(0);
}
} else {
ProtocolUtils.writeCompoundTag(buf, this.nbt);
if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_20_2) < 0) {
ProtocolUtils.writeCompoundTag(buf, this.nbt);
} else {
// TODO: remove then the ProtocolUtils::writeCompoundTag will support 1.20.2
try (ByteBufOutputStream output = new ByteBufOutputStream(buf)) {
output.writeByte(BinaryTagTypes.COMPOUND.id());
BinaryTagTypes.COMPOUND.write(this.nbt, output);
} catch (Throwable throwable) {
throw new EncoderException("Unable to encode NBT CompoundTag");
}
}
}
}
}
Expand Down

0 comments on commit 349ef51

Please sign in to comment.