From c211b10eaa621842ed5b063957102bcb47c25c41 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 6 Oct 2023 21:37:52 +1000 Subject: [PATCH] Rename NBT and NBT_ARRAY types, add TagType In theory the nameless compound tag type doesn't exist as it is written as any tag, but in practice is almost always cast and checked for its type, so we keep the extra CompoundTagType (nameless) and add the proper TagType (nameless, any tag) used for components --- .../metadata/types/MetaType1_12.java | 2 +- .../metadata/types/MetaType1_13.java | 2 +- .../metadata/types/MetaType1_13_2.java | 2 +- .../metadata/types/MetaType1_14.java | 2 +- .../metadata/types/MetaType1_16.java | 2 +- .../metadata/types/MetaType1_17.java | 2 +- .../metadata/types/MetaType1_18.java | 2 +- .../metadata/types/MetaTypes1_13.java | 2 +- .../metadata/types/MetaTypes1_13_2.java | 2 +- .../metadata/types/MetaTypes1_14.java | 2 +- .../metadata/types/MetaTypes1_19.java | 2 +- .../metadata/types/MetaTypes1_19_3.java | 2 +- .../metadata/types/MetaTypes1_19_4.java | 2 +- .../metadata/types/MetaTypes1_20_2.java | 2 +- .../metadata/types/MetaTypes1_20_3.java | 6 +- .../viaversion/viaversion/api/type/Type.java | 27 ++++++-- ...elessNBTType.java => CompoundTagType.java} | 23 ++++--- .../type/types/minecraft/FlatItemType.java | 4 +- .../types/minecraft/FlatVarIntItemType.java | 4 +- .../type/types/minecraft/Item1_20_2Type.java | 4 +- .../api/type/types/minecraft/ItemType.java | 4 +- ...NBTType.java => NamedCompoundTagType.java} | 13 ++-- .../api/type/types/minecraft/TagType.java | 63 +++++++++++++++++++ .../types/version/BlockEntityType1_18.java | 4 +- .../types/version/BlockEntityType1_20_2.java | 4 +- .../protocol/ProtocolPipelineImpl.java | 10 +-- .../protocols/base/BaseProtocol.java | 5 ++ .../Protocol1_11To1_10.java | 4 +- .../packets/WorldPackets.java | 4 +- .../types/Chunk1_13Type.java | 4 +- .../types/Chunk1_14Type.java | 8 +-- .../types/Chunk1_15Type.java | 8 +-- .../packets/EntityPackets.java | 8 +-- .../types/Chunk1_16_2Type.java | 8 +-- .../packets/EntityPackets.java | 2 +- .../packets/WorldPackets.java | 2 +- .../types/Chunk1_16Type.java | 8 +-- .../packets/EntityPackets.java | 10 +-- .../types/Chunk1_17Type.java | 8 +-- .../Protocol1_18_2To1_18.java | 10 +-- .../packets/EntityPackets.java | 6 +- .../packets/WorldPackets.java | 2 +- .../types/Chunk1_18Type.java | 4 +- .../Protocol1_19_1To1_19.java | 2 +- .../Protocol1_19_3To1_19_1.java | 7 +-- .../packets/EntityPackets.java | 7 +-- .../packets/EntityPackets.java | 4 +- .../packets/EntityPackets.java | 6 +- .../Protocol1_20_2To1_20.java | 2 +- .../BlockItemPacketRewriter1_20_2.java | 4 +- .../rewriter/EntityPacketRewriter1_20_2.java | 4 +- .../type/ChunkType1_20_2.java | 4 +- .../Protocol1_20_3To1_20_2.java | 24 ++++--- .../packets/EntityPackets.java | 4 +- .../Protocol1_9_3To1_9_1_2.java | 2 +- .../types/Chunk1_9_3_4Type.java | 4 +- .../packets/WorldPackets.java | 8 +-- .../viaversion/rewriter/BlockRewriter.java | 2 +- .../viaversion/rewriter/EntityRewriter.java | 6 +- 59 files changed, 231 insertions(+), 154 deletions(-) rename api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/{NamelessNBTType.java => CompoundTagType.java} (70%) rename api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/{NBTType.java => NamedCompoundTagType.java} (87%) create mode 100644 api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/TagType.java diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_12.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_12.java index 0083e4c7d..00be61c5e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_12.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_12.java @@ -39,7 +39,7 @@ public enum MetaType1_12 implements MetaType { Direction(10, Type.VAR_INT), OptUUID(11, Type.OPTIONAL_UUID), BlockID(12, Type.VAR_INT), - NBTTag(13, Type.NBT); + NBTTag(13, Type.NAMED_COMPOUND_TAG); private final int typeID; private final Type type; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_13.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_13.java index 35acdf98b..579825bef 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_13.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_13.java @@ -42,7 +42,7 @@ public enum MetaType1_13 implements MetaType { Direction(11, Type.VAR_INT), OptUUID(12, Type.OPTIONAL_UUID), BlockID(13, Type.VAR_INT), - NBTTag(14, Type.NBT), + NBTTag(14, Type.NAMED_COMPOUND_TAG), PARTICLE(15, Types1_13.PARTICLE); private final int typeID; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_13_2.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_13_2.java index 4f5de0693..3436053d9 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_13_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_13_2.java @@ -42,7 +42,7 @@ public enum MetaType1_13_2 implements MetaType { Direction(11, Type.VAR_INT), OptUUID(12, Type.OPTIONAL_UUID), BlockID(13, Type.VAR_INT), - NBTTag(14, Type.NBT), + NBTTag(14, Type.NAMED_COMPOUND_TAG), PARTICLE(15, Types1_13_2.PARTICLE); private final int typeID; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_14.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_14.java index e60855395..301956948 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_14.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_14.java @@ -42,7 +42,7 @@ public enum MetaType1_14 implements MetaType { Direction(11, Type.VAR_INT), OptUUID(12, Type.OPTIONAL_UUID), BlockID(13, Type.VAR_INT), - NBTTag(14, Type.NBT), + NBTTag(14, Type.NAMED_COMPOUND_TAG), PARTICLE(15, Types1_14.PARTICLE), VillagerData(16, Type.VILLAGER_DATA), OptVarInt(17, Type.OPTIONAL_VAR_INT), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_16.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_16.java index 714eac4ef..538e2318d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_16.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_16.java @@ -42,7 +42,7 @@ public enum MetaType1_16 implements MetaType { DIRECTION(11, Type.VAR_INT), OPT_UUID(12, Type.OPTIONAL_UUID), BLOCK_STATE(13, Type.VAR_INT), - NBT(14, Type.NBT), + NBT(14, Type.NAMED_COMPOUND_TAG), PARTICLE(15, Types1_16.PARTICLE), VILLAGER_DATA(16, Type.VILLAGER_DATA), OPT_VAR_INT(17, Type.OPTIONAL_VAR_INT), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_17.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_17.java index ba3187d9f..33c9fb0c1 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_17.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_17.java @@ -42,7 +42,7 @@ public enum MetaType1_17 implements MetaType { DIRECTION(11, Type.VAR_INT), OPT_UUID(12, Type.OPTIONAL_UUID), BLOCK_STATE(13, Type.VAR_INT), - NBT(14, Type.NBT), + NBT(14, Type.NAMED_COMPOUND_TAG), PARTICLE(15, Types1_17.PARTICLE), VILLAGER_DATA(16, Type.VILLAGER_DATA), OPT_VAR_INT(17, Type.OPTIONAL_VAR_INT), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_18.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_18.java index 455623c3d..37204eca8 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_18.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaType1_18.java @@ -42,7 +42,7 @@ public enum MetaType1_18 implements MetaType { DIRECTION(11, Type.VAR_INT), OPT_UUID(12, Type.OPTIONAL_UUID), BLOCK_STATE(13, Type.VAR_INT), - NBT(14, Type.NBT), + NBT(14, Type.NAMED_COMPOUND_TAG), PARTICLE(15, Types1_18.PARTICLE), VILLAGER_DATA(16, Type.VILLAGER_DATA), OPT_VAR_INT(17, Type.OPTIONAL_VAR_INT), diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13.java index 7a67af7db..33e52ae83 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13.java @@ -42,7 +42,7 @@ public final class MetaTypes1_13 extends AbstractMetaTypes { public final MetaType directionType = add(11, Type.VAR_INT); public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID); public final MetaType blockStateType = add(13, Type.VAR_INT); - public final MetaType nbtType = add(14, Type.NBT); + public final MetaType nbtType = add(14, Type.NAMED_COMPOUND_TAG); public final MetaType particleType; public MetaTypes1_13(final ParticleType particleType) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13_2.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13_2.java index c9c6c6f88..0b9cc6735 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_13_2.java @@ -42,7 +42,7 @@ public final class MetaTypes1_13_2 extends AbstractMetaTypes { public final MetaType directionType = add(11, Type.VAR_INT); public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID); public final MetaType blockStateType = add(13, Type.VAR_INT); - public final MetaType nbtType = add(14, Type.NBT); + public final MetaType nbtType = add(14, Type.NAMED_COMPOUND_TAG); public final MetaType particleType; public MetaTypes1_13_2(final ParticleType particleType) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_14.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_14.java index d5db40541..0422d072f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_14.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_14.java @@ -42,7 +42,7 @@ public final class MetaTypes1_14 extends AbstractMetaTypes { public final MetaType directionType = add(11, Type.VAR_INT); public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID); public final MetaType blockStateType = add(13, Type.VAR_INT); - public final MetaType nbtType = add(14, Type.NBT); + public final MetaType nbtType = add(14, Type.NAMED_COMPOUND_TAG); public final MetaType particleType; public final MetaType villagerDatatType = add(16, Type.VILLAGER_DATA); public final MetaType optionalVarIntType = add(17, Type.OPTIONAL_VAR_INT); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19.java index c6c98b7d2..c98c99f15 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19.java @@ -42,7 +42,7 @@ public final class MetaTypes1_19 extends AbstractMetaTypes { public final MetaType directionType = add(11, Type.VAR_INT); public final MetaType optionalUUIDType = add(12, Type.OPTIONAL_UUID); public final MetaType blockStateType = add(13, Type.VAR_INT); - public final MetaType nbtType = add(14, Type.NBT); + public final MetaType nbtType = add(14, Type.NAMED_COMPOUND_TAG); public final MetaType particleType; public final MetaType villagerDatatType = add(16, Type.VILLAGER_DATA); public final MetaType optionalVarIntType = add(17, Type.OPTIONAL_VAR_INT); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_3.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_3.java index fe1e15604..1359372f5 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_3.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_3.java @@ -43,7 +43,7 @@ public final class MetaTypes1_19_3 extends AbstractMetaTypes { public final MetaType directionType = add(12, Type.VAR_INT); public final MetaType optionalUUIDType = add(13, Type.OPTIONAL_UUID); public final MetaType blockStateType = add(14, Type.VAR_INT); - public final MetaType nbtType = add(15, Type.NBT); + public final MetaType nbtType = add(15, Type.NAMED_COMPOUND_TAG); public final MetaType particleType; public final MetaType villagerDatatType = add(17, Type.VILLAGER_DATA); public final MetaType optionalVarIntType = add(18, Type.OPTIONAL_VAR_INT); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_4.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_4.java index 0e491b000..1728aefb2 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_4.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_19_4.java @@ -44,7 +44,7 @@ public final class MetaTypes1_19_4 extends AbstractMetaTypes { public final MetaType optionalUUIDType = add(13, Type.OPTIONAL_UUID); public final MetaType blockStateType = add(14, Type.VAR_INT); public final MetaType optionalBlockStateType = add(15, Type.VAR_INT); - public final MetaType nbtType = add(16, Type.NBT); + public final MetaType nbtType = add(16, Type.NAMED_COMPOUND_TAG); public final MetaType particleType; public final MetaType villagerDatatType = add(18, Type.VILLAGER_DATA); public final MetaType optionalVarIntType = add(19, Type.OPTIONAL_VAR_INT); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_2.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_2.java index 2979ac2fa..ce050b320 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_2.java @@ -44,7 +44,7 @@ public final class MetaTypes1_20_2 extends AbstractMetaTypes { public final MetaType optionalUUIDType = add(13, Type.OPTIONAL_UUID); public final MetaType blockStateType = add(14, Type.VAR_INT); public final MetaType optionalBlockStateType = add(15, Type.VAR_INT); - public final MetaType nbtType = add(16, Type.NAMELESS_NBT); + public final MetaType nbtType = add(16, Type.COMPOUND_TAG); public final MetaType particleType; public final MetaType villagerDatatType = add(18, Type.VILLAGER_DATA); public final MetaType optionalVarIntType = add(19, Type.OPTIONAL_VAR_INT); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_3.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_3.java index eb5372f51..be5276e47 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_3.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/metadata/types/MetaTypes1_20_3.java @@ -33,8 +33,8 @@ public final class MetaTypes1_20_3 extends AbstractMetaTypes { public final MetaType longType = add(2, Type.VAR_LONG); public final MetaType floatType = add(3, Type.FLOAT); public final MetaType stringType = add(4, Type.STRING); - public final MetaType componentType = add(5, Type.NAMELESS_NBT); - public final MetaType optionalComponentType = add(6, Type.OPTIONAL_NAMELESS_NBT); + public final MetaType componentType = add(5, Type.COMPOUND_TAG); + public final MetaType optionalComponentType = add(6, Type.OPTIONAL_COMPOUND_TAG); public final MetaType itemType = add(7, Type.ITEM1_20_2); public final MetaType booleanType = add(8, Type.BOOLEAN); public final MetaType rotationType = add(9, Type.ROTATION); @@ -44,7 +44,7 @@ public final class MetaTypes1_20_3 extends AbstractMetaTypes { public final MetaType optionalUUIDType = add(13, Type.OPTIONAL_UUID); public final MetaType blockStateType = add(14, Type.VAR_INT); public final MetaType optionalBlockStateType = add(15, Type.VAR_INT); - public final MetaType nbtType = add(16, Type.NAMELESS_NBT); + public final MetaType nbtType = add(16, Type.COMPOUND_TAG); public final MetaType particleType; public final MetaType villagerDatatType = add(18, Type.VILLAGER_DATA); public final MetaType optionalVarIntType = add(19, Type.OPTIONAL_VAR_INT); diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/Type.java b/api/src/main/java/com/viaversion/viaversion/api/type/Type.java index fa2b5edf9..09383642a 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/Type.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/Type.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.type; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.github.steveice10.opennbt.tag.builtin.Tag; import com.google.gson.JsonElement; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.EulerAngle; @@ -37,6 +38,7 @@ import com.viaversion.viaversion.api.minecraft.VillagerData; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.ChunkPosition; import com.viaversion.viaversion.api.type.types.ArrayType; +import com.viaversion.viaversion.api.type.types.BitSetType; import com.viaversion.viaversion.api.type.types.BooleanType; import com.viaversion.viaversion.api.type.types.ByteArrayType; import com.viaversion.viaversion.api.type.types.ByteType; @@ -60,6 +62,7 @@ import com.viaversion.viaversion.api.type.types.VarLongType; import com.viaversion.viaversion.api.type.types.VoidType; import com.viaversion.viaversion.api.type.types.minecraft.BlockChangeRecordType; import com.viaversion.viaversion.api.type.types.minecraft.ChunkPositionType; +import com.viaversion.viaversion.api.type.types.minecraft.CompoundTagType; import com.viaversion.viaversion.api.type.types.minecraft.EulerAngleType; import com.viaversion.viaversion.api.type.types.minecraft.FlatItemArrayType; import com.viaversion.viaversion.api.type.types.minecraft.FlatItemType; @@ -69,14 +72,14 @@ import com.viaversion.viaversion.api.type.types.minecraft.GlobalPositionType; import com.viaversion.viaversion.api.type.types.minecraft.Item1_20_2Type; import com.viaversion.viaversion.api.type.types.minecraft.ItemArrayType; import com.viaversion.viaversion.api.type.types.minecraft.ItemType; -import com.viaversion.viaversion.api.type.types.minecraft.NBTType; -import com.viaversion.viaversion.api.type.types.minecraft.NamelessNBTType; +import com.viaversion.viaversion.api.type.types.minecraft.NamedCompoundTagType; import com.viaversion.viaversion.api.type.types.minecraft.OptionalVarIntType; import com.viaversion.viaversion.api.type.types.minecraft.PlayerMessageSignatureType; import com.viaversion.viaversion.api.type.types.minecraft.Position1_14Type; import com.viaversion.viaversion.api.type.types.minecraft.PositionType; import com.viaversion.viaversion.api.type.types.minecraft.ProfileKeyType; import com.viaversion.viaversion.api.type.types.minecraft.QuaternionType; +import com.viaversion.viaversion.api.type.types.minecraft.TagType; import com.viaversion.viaversion.api.type.types.minecraft.VarLongBlockChangeRecordType; import com.viaversion.viaversion.api.type.types.minecraft.Vector3fType; import com.viaversion.viaversion.api.type.types.minecraft.VectorType; @@ -165,10 +168,18 @@ public abstract class Type implements ByteBufReader, ByteBufWriter { public static final Type VECTOR = new VectorType(); public static final Type VECTOR3F = new Vector3fType(); public static final Type QUATERNION = new QuaternionType(); - public static final Type NBT = new NBTType(); - public static final Type NAMELESS_NBT = new NamelessNBTType(); - public static final Type OPTIONAL_NAMELESS_NBT = new NamelessNBTType.OptionalNamelessNBTType(); - public static final Type NBT_ARRAY = new ArrayType<>(Type.NBT); + + public static final Type NAMED_COMPOUND_TAG = new NamedCompoundTagType(); + public static final Type NAMED_COMPOUND_TAG_ARRAY = new ArrayType<>(Type.NAMED_COMPOUND_TAG); + public static final Type COMPOUND_TAG = new CompoundTagType(); + public static final Type OPTIONAL_COMPOUND_TAG = new CompoundTagType.OptionalCompoundTagType(); + public static final Type TAG = new TagType(); + public static final Type OPTIONAL_TAG = new TagType.OptionalTagType(); + @Deprecated/*(forRemoval=true)*/ + public static final Type NBT = NAMED_COMPOUND_TAG; + @Deprecated/*(forRemoval=true)*/ + public static final Type NBT_ARRAY = NAMED_COMPOUND_TAG_ARRAY; + public static final Type GLOBAL_POSITION = new GlobalPositionType(); public static final Type OPTIONAL_GLOBAL_POSITION = new GlobalPositionType.OptionalGlobalPositionType(); public static final Type CHUNK_POSITION = new ChunkPositionType(); @@ -191,6 +202,10 @@ public abstract class Type implements ByteBufReader, ByteBufWriter { public static final Type OPTIONAL_PLAYER_MESSAGE_SIGNATURE = new PlayerMessageSignatureType.OptionalPlayerMessageSignatureType(); public static final Type PLAYER_MESSAGE_SIGNATURE_ARRAY = new ArrayType<>(PLAYER_MESSAGE_SIGNATURE); + public static final BitSetType PROFILE_ACTIONS_ENUM = new BitSetType(6); + public static final ByteArrayType SIGNATURE_BYTES = new ByteArrayType(256); + public static final ByteArrayType.OptionalByteArrayType OPTIONAL_SIGNATURE_BYTES = new ByteArrayType.OptionalByteArrayType(256); + /* 1.13 Flat Item (no data) */ public static final Type FLAT_ITEM = new FlatItemType(); public static final Type FLAT_VAR_INT_ITEM = new FlatVarIntItemType(); diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/NamelessNBTType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/CompoundTagType.java similarity index 70% rename from api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/NamelessNBTType.java rename to api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/CompoundTagType.java index e7afdbb81..b46877b72 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/NamelessNBTType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/CompoundTagType.java @@ -27,26 +27,33 @@ import com.viaversion.viaversion.api.type.OptionalType; import com.viaversion.viaversion.api.type.Type; import io.netty.buffer.ByteBuf; -public class NamelessNBTType extends Type { - public NamelessNBTType() { +/** + * Compound tag type, functionally equivalent to {@link TagType} with an additional cast. + *

+ * On the network, this is technically written as any tag, but almost always cast to and checked + * as a CompoundTag, so we provide this type for convenience. + */ +public class CompoundTagType extends Type { + + public CompoundTagType() { super(CompoundTag.class); } @Override public CompoundTag read(final ByteBuf buffer) throws Exception { - return NBTType.read(buffer, false); + return NamedCompoundTagType.read(buffer, false); } @Override - public void write(final ByteBuf buffer, final CompoundTag tag) throws Exception { - NBTType.write(buffer, tag, null); + public void write(final ByteBuf buffer, final CompoundTag object) throws Exception { + NamedCompoundTagType.write(buffer, object, null); } - public static final class OptionalNamelessNBTType extends OptionalType { + public static final class OptionalCompoundTagType extends OptionalType { - public OptionalNamelessNBTType() { - super(Type.NAMELESS_NBT); + public OptionalCompoundTagType() { + super(Type.COMPOUND_TAG); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/FlatItemType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/FlatItemType.java index 8e0946e29..471e7a6c5 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/FlatItemType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/FlatItemType.java @@ -42,7 +42,7 @@ public class FlatItemType extends BaseItemType { Item item = new DataItem(); item.setIdentifier(id); item.setAmount(buffer.readByte()); - item.setTag(Type.NBT.read(buffer)); + item.setTag(Type.NAMED_COMPOUND_TAG.read(buffer)); return item; } } @@ -54,7 +54,7 @@ public class FlatItemType extends BaseItemType { } else { buffer.writeShort(object.identifier()); buffer.writeByte(object.amount()); - Type.NBT.write(buffer, object.tag()); + Type.NAMED_COMPOUND_TAG.write(buffer, object.tag()); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/FlatVarIntItemType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/FlatVarIntItemType.java index 3901a7111..d66bf7815 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/FlatVarIntItemType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/FlatVarIntItemType.java @@ -41,7 +41,7 @@ public class FlatVarIntItemType extends BaseItemType { Item item = new DataItem(); item.setIdentifier(VAR_INT.readPrimitive(buffer)); item.setAmount(buffer.readByte()); - item.setTag(NBT.read(buffer)); + item.setTag(NAMED_COMPOUND_TAG.read(buffer)); return item; } } @@ -54,7 +54,7 @@ public class FlatVarIntItemType extends BaseItemType { buffer.writeBoolean(true); VAR_INT.writePrimitive(buffer, object.identifier()); buffer.writeByte(object.amount()); - NBT.write(buffer, object.tag()); + NAMED_COMPOUND_TAG.write(buffer, object.tag()); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Item1_20_2Type.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Item1_20_2Type.java index 73ceacdde..5b990926f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Item1_20_2Type.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/Item1_20_2Type.java @@ -42,7 +42,7 @@ public class Item1_20_2Type extends BaseItemType { final Item item = new DataItem(); item.setIdentifier(VAR_INT.readPrimitive(buffer)); item.setAmount(buffer.readByte()); - item.setTag(NAMELESS_NBT.read(buffer)); + item.setTag(COMPOUND_TAG.read(buffer)); return item; } @@ -54,7 +54,7 @@ public class Item1_20_2Type extends BaseItemType { buffer.writeBoolean(true); VAR_INT.writePrimitive(buffer, object.identifier()); buffer.writeByte(object.amount()); - NAMELESS_NBT.write(buffer, object.tag()); + COMPOUND_TAG.write(buffer, object.tag()); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/ItemType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/ItemType.java index ccdea648d..d9dbd1607 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/ItemType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/ItemType.java @@ -43,7 +43,7 @@ public class ItemType extends BaseItemType { item.setIdentifier(id); item.setAmount(buffer.readByte()); item.setData(buffer.readShort()); - item.setTag(NBT.read(buffer)); + item.setTag(NAMED_COMPOUND_TAG.read(buffer)); return item; } } @@ -56,7 +56,7 @@ public class ItemType extends BaseItemType { buffer.writeShort(object.identifier()); buffer.writeByte(object.amount()); buffer.writeShort(object.data()); - NBT.write(buffer, object.tag()); + NAMED_COMPOUND_TAG.write(buffer, object.tag()); } } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/NBTType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/NamedCompoundTagType.java similarity index 87% rename from api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/NBTType.java rename to api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/NamedCompoundTagType.java index a281d953d..19b0c8ca5 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/NBTType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/NamedCompoundTagType.java @@ -23,6 +23,7 @@ package com.viaversion.viaversion.api.type.types.minecraft; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.limiter.TagLimiter; import com.viaversion.viaversion.api.type.Type; import io.netty.buffer.ByteBuf; @@ -31,12 +32,12 @@ import io.netty.buffer.ByteBufOutputStream; import java.io.IOException; import org.checkerframework.checker.nullness.qual.Nullable; -public class NBTType extends Type { +public class NamedCompoundTagType extends Type { - private static final int MAX_NBT_BYTES = 2097152; // 2mb - private static final int MAX_NESTING_LEVEL = 512; + public static final int MAX_NBT_BYTES = 2097152; // 2mb + public static final int MAX_NESTING_LEVEL = 512; - public NBTType() { + public NamedCompoundTagType() { super(CompoundTag.class); } @@ -69,14 +70,14 @@ public class NBTType extends Type { return tag; } - public static void write(final ByteBuf buffer, final CompoundTag tag, final @Nullable String name) throws Exception { + public static void write(final ByteBuf buffer, final Tag tag, final @Nullable String name) throws Exception { if (tag == null) { buffer.writeByte(0); return; } final ByteBufOutputStream out = new ByteBufOutputStream(buffer); - out.writeByte(CompoundTag.ID); + out.writeByte(tag.getTagId()); if (name != null) { out.writeUTF(name); } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/TagType.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/TagType.java new file mode 100644 index 000000000..5470d8ac8 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/minecraft/TagType.java @@ -0,0 +1,63 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2023 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.viaversion.viaversion.api.type.types.minecraft; + +import com.github.steveice10.opennbt.tag.TagRegistry; +import com.github.steveice10.opennbt.tag.builtin.Tag; +import com.github.steveice10.opennbt.tag.limiter.TagLimiter; +import com.viaversion.viaversion.api.type.OptionalType; +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; + +public class TagType extends Type { + + public TagType() { + super(Tag.class); + } + + @Override + public Tag read(final ByteBuf buffer) throws Exception { + final byte id = buffer.readByte(); + if (id == 0) { + return null; + } + + final TagLimiter tagLimiter = TagLimiter.create(NamedCompoundTagType.MAX_NBT_BYTES, NamedCompoundTagType.MAX_NESTING_LEVEL); + final Tag tag = TagRegistry.createInstance(id); + tag.read(new ByteBufInputStream(buffer), tagLimiter); + return tag; + } + + @Override + public void write(final ByteBuf buffer, final Tag tag) throws Exception { + NamedCompoundTagType.write(buffer, tag, null); + } + + public static final class OptionalTagType extends OptionalType { + + public OptionalTagType() { + super(Type.TAG); + } + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/BlockEntityType1_18.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/BlockEntityType1_18.java index d57e1c8c8..53a90841d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/BlockEntityType1_18.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/BlockEntityType1_18.java @@ -39,7 +39,7 @@ public class BlockEntityType1_18 extends Type { final byte xz = buffer.readByte(); final short y = buffer.readShort(); final int typeId = Type.VAR_INT.readPrimitive(buffer); - final CompoundTag tag = Type.NBT.read(buffer); + final CompoundTag tag = Type.NAMED_COMPOUND_TAG.read(buffer); return new BlockEntityImpl(xz, y, typeId, tag); } @@ -48,6 +48,6 @@ public class BlockEntityType1_18 extends Type { buffer.writeByte(entity.packedXZ()); buffer.writeShort(entity.y()); Type.VAR_INT.writePrimitive(buffer, entity.typeId()); - Type.NBT.write(buffer, entity.tag()); + Type.NAMED_COMPOUND_TAG.write(buffer, entity.tag()); } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/BlockEntityType1_20_2.java b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/BlockEntityType1_20_2.java index 2513183de..30f30f802 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/types/version/BlockEntityType1_20_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/types/version/BlockEntityType1_20_2.java @@ -39,7 +39,7 @@ public class BlockEntityType1_20_2 extends Type { final byte xz = buffer.readByte(); final short y = buffer.readShort(); final int typeId = Type.VAR_INT.readPrimitive(buffer); - final CompoundTag tag = Type.NAMELESS_NBT.read(buffer); + final CompoundTag tag = Type.COMPOUND_TAG.read(buffer); return new BlockEntityImpl(xz, y, typeId, tag); } @@ -48,6 +48,6 @@ public class BlockEntityType1_20_2 extends Type { buffer.writeByte(entity.packedXZ()); buffer.writeShort(entity.y()); Type.VAR_INT.writePrimitive(buffer, entity.typeId()); - Type.NAMELESS_NBT.write(buffer, entity.tag()); + Type.COMPOUND_TAG.write(buffer, entity.tag()); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPipelineImpl.java b/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPipelineImpl.java index 91fedc515..79acfb567 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPipelineImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolPipelineImpl.java @@ -20,7 +20,6 @@ package com.viaversion.viaversion.protocol; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.debug.DebugHandler; -import com.viaversion.viaversion.api.platform.ViaPlatform; import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.ProtocolPipeline; @@ -126,14 +125,9 @@ public class ProtocolPipelineImpl extends AbstractSimpleProtocol implements Prot } private void logPacket(Direction direction, State state, PacketWrapper packetWrapper, int originalID) { - // Debug packet - int clientProtocol = userConnection.getProtocolInfo().getProtocolVersion(); - ViaPlatform platform = Via.getPlatform(); - String actualUsername = packetWrapper.user().getProtocolInfo().getUsername(); String username = actualUsername != null ? actualUsername + " " : ""; - - platform.getLogger().log(Level.INFO, "{0}{1} {2}: {3} ({4}) -> {5} ({6}) [{7}] {8}", + Via.getPlatform().getLogger().log(Level.INFO, "{0}{1} {2}: {3} ({4}) -> {5} ({6}) [{7}] {8}", new Object[]{ username, direction, @@ -142,7 +136,7 @@ public class ProtocolPipelineImpl extends AbstractSimpleProtocol implements Prot AbstractSimpleProtocol.toNiceHex(originalID), packetWrapper.getId(), AbstractSimpleProtocol.toNiceHex(packetWrapper.getId()), - Integer.toString(clientProtocol), + Integer.toString(userConnection.getProtocolInfo().getProtocolVersion()), packetWrapper }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java index fe803dfe9..1dd3823ce 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol.java @@ -84,6 +84,11 @@ public class BaseProtocol extends AbstractProtocol { // Add Base Protocol pipeline.add(Via.getManager().getProtocolManager().getBaseProtocol(serverProtocol)); + if (Via.getManager().isDebug()) { + Via.getPlatform().getLogger().info("User connected with protocol: " + info.getProtocolVersion() + " and serverProtocol: " + info.getServerProtocolVersion()); + Via.getPlatform().getLogger().info("Protocol pipeline: " + pipeline.pipes()); + } + // Change state if (state == 1) { info.setState(State.STATUS); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java index 25641c75e..183dd4969 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java @@ -190,10 +190,10 @@ public class Protocol1_11To1_10 extends AbstractProtocol { - CompoundTag tag = wrapper.get(Type.NBT, 0); + CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 1) EntityIdRewriter.toClientSpawner(tag); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java index 94bc4fec6..1b382eb8f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java @@ -104,12 +104,12 @@ public class WorldPackets { public void register() { map(Type.POSITION); // 0 - Location map(Type.UNSIGNED_BYTE); // 1 - Action - map(Type.NBT); // 2 - NBT data + map(Type.NAMED_COMPOUND_TAG); // 2 - NBT data handler(wrapper -> { Position position = wrapper.get(Type.POSITION, 0); short action = wrapper.get(Type.UNSIGNED_BYTE, 0); - CompoundTag tag = wrapper.get(Type.NBT, 0); + CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); BlockEntityProvider provider = Via.getManager().getProviders().get(BlockEntityProvider.class); int newId = provider.transform(wrapper.user(), position, tag, true); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java index 642062924..30409b803 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java @@ -73,7 +73,7 @@ public class Chunk1_13Type extends PartialType { } } - List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); // Read all the remaining bytes (workaround for #681) if (input.readableBytes() > 0) { @@ -121,7 +121,7 @@ public class Chunk1_13Type extends PartialType { } // Write Block Entities - Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); + Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/types/Chunk1_14Type.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/types/Chunk1_14Type.java index 1f25fccea..eca9fd735 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/types/Chunk1_14Type.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/types/Chunk1_14Type.java @@ -43,7 +43,7 @@ public class Chunk1_14Type extends Type { boolean fullChunk = input.readBoolean(); int primaryBitmask = Type.VAR_INT.readPrimitive(input); - CompoundTag heightMap = Type.NBT.read(input); + CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(input); Type.VAR_INT.readPrimitive(input); @@ -65,7 +65,7 @@ public class Chunk1_14Type extends Type { } } - List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); // Read all the remaining bytes (workaround for #681) if (input.readableBytes() > 0) { @@ -85,7 +85,7 @@ public class Chunk1_14Type extends Type { output.writeBoolean(chunk.isFullChunk()); Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); - Type.NBT.write(output, chunk.getHeightMap()); + Type.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); ByteBuf buf = output.alloc().buffer(); try { @@ -111,7 +111,7 @@ public class Chunk1_14Type extends Type { } // Write Block Entities - Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); + Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/types/Chunk1_15Type.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/types/Chunk1_15Type.java index afc919461..293ba3cfe 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/types/Chunk1_15Type.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/types/Chunk1_15Type.java @@ -44,7 +44,7 @@ public class Chunk1_15Type extends Type { boolean fullChunk = input.readBoolean(); int primaryBitmask = Type.VAR_INT.readPrimitive(input); - CompoundTag heightMap = Type.NBT.read(input); + CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(input); int[] biomeData = fullChunk ? new int[1024] : null; if (fullChunk) { @@ -66,7 +66,7 @@ public class Chunk1_15Type extends Type { sections[i] = section; } - List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); // Read all the remaining bytes (workaround for #681) if (input.readableBytes() > 0) { @@ -86,7 +86,7 @@ public class Chunk1_15Type extends Type { output.writeBoolean(chunk.isFullChunk()); Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); - Type.NBT.write(output, chunk.getHeightMap()); + Type.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); // Write biome data if (chunk.isBiomeData()) { @@ -112,7 +112,7 @@ public class Chunk1_15Type extends Type { } // Write Block Entities - Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); + Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/EntityPackets.java index 9e9b5c150..25cd1ea0a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/packets/EntityPackets.java @@ -52,12 +52,12 @@ public class EntityPackets { map(Type.STRING_ARRAY); // World List handler(wrapper -> { // Throw away the old dimension registry, extra conversion would be too hard of a hit - wrapper.read(Type.NBT); - wrapper.write(Type.NBT, protocol.getMappingData().getDimensionRegistry()); + wrapper.read(Type.NAMED_COMPOUND_TAG); + wrapper.write(Type.NAMED_COMPOUND_TAG, protocol.getMappingData().getDimensionRegistry()); // Instead of the dimension's resource key, it now just wants the data directly String dimensionType = wrapper.read(Type.STRING); - wrapper.write(Type.NBT, getDimensionData(dimensionType)); + wrapper.write(Type.NAMED_COMPOUND_TAG, getDimensionData(dimensionType)); }); map(Type.STRING); // Dimension map(Type.LONG); // Seed @@ -69,7 +69,7 @@ public class EntityPackets { protocol.registerClientbound(ClientboundPackets1_16.RESPAWN, wrapper -> { String dimensionType = wrapper.read(Type.STRING); - wrapper.write(Type.NBT, getDimensionData(dimensionType)); + wrapper.write(Type.NAMED_COMPOUND_TAG, getDimensionData(dimensionType)); }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/types/Chunk1_16_2Type.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/types/Chunk1_16_2Type.java index 697de78bb..99ec63cc9 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/types/Chunk1_16_2Type.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16_2to1_16_1/types/Chunk1_16_2Type.java @@ -44,7 +44,7 @@ public class Chunk1_16_2Type extends Type { boolean fullChunk = input.readBoolean(); int primaryBitmask = Type.VAR_INT.readPrimitive(input); - CompoundTag heightMap = Type.NBT.read(input); + CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(input); int[] biomeData = null; if (fullChunk) { @@ -64,7 +64,7 @@ public class Chunk1_16_2Type extends Type { sections[i] = section; } - List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); // Read all the remaining bytes (workaround for #681) if (input.readableBytes() > 0) { @@ -84,7 +84,7 @@ public class Chunk1_16_2Type extends Type { output.writeBoolean(chunk.isFullChunk()); Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); - Type.NBT.write(output, chunk.getHeightMap()); + Type.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); // Write biome data if (chunk.isBiomeData()) { @@ -108,7 +108,7 @@ public class Chunk1_16_2Type extends Type { } // Write Block Entities - Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); + Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java index 4b249a351..a28bb6646 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java @@ -214,7 +214,7 @@ public class EntityPackets { handler(wrapper -> { wrapper.write(Type.BYTE, (byte) -1); // Previous gamemode, set to none wrapper.write(Type.STRING_ARRAY, Arrays.copyOf(WORLD_NAMES, WORLD_NAMES.length)); // World list - only used for command completion - wrapper.write(Type.NBT, DIMENSIONS_TAG.clone()); // Dimension registry + wrapper.write(Type.NAMED_COMPOUND_TAG, DIMENSIONS_TAG.clone()); // Dimension registry }); handler(DIMENSION_HANDLER); // Dimension map(Type.LONG); // Seed diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java index 2e8fcb929..ae5ae4892 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java @@ -94,7 +94,7 @@ public class WorldPackets { protocol.registerClientbound(ClientboundPackets1_15.BLOCK_ENTITY_DATA, wrapper -> { wrapper.passthrough(Type.POSITION1_14); // Position wrapper.passthrough(Type.UNSIGNED_BYTE); // Action - CompoundTag tag = wrapper.passthrough(Type.NBT); + CompoundTag tag = wrapper.passthrough(Type.NAMED_COMPOUND_TAG); handleBlockEntity(protocol, tag); }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/types/Chunk1_16Type.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/types/Chunk1_16Type.java index 1c26136b8..fc6515515 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/types/Chunk1_16Type.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_16to1_15_2/types/Chunk1_16Type.java @@ -45,7 +45,7 @@ public class Chunk1_16Type extends Type { boolean fullChunk = input.readBoolean(); boolean ignoreOldLightData = input.readBoolean(); int primaryBitmask = Type.VAR_INT.readPrimitive(input); - CompoundTag heightMap = Type.NBT.read(input); + CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(input); int[] biomeData = fullChunk ? new int[1024] : null; if (fullChunk) { @@ -67,7 +67,7 @@ public class Chunk1_16Type extends Type { sections[i] = section; } - List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); // Read all the remaining bytes (workaround for #681) if (input.readableBytes() > 0) { @@ -88,7 +88,7 @@ public class Chunk1_16Type extends Type { output.writeBoolean(chunk.isFullChunk()); output.writeBoolean(chunk.isIgnoreOldLightData()); Type.VAR_INT.writePrimitive(output, chunk.getBitmask()); - Type.NBT.write(output, chunk.getHeightMap()); + Type.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); // Write biome data if (chunk.isBiomeData()) { @@ -114,7 +114,7 @@ public class Chunk1_16Type extends Type { } // Write Block Entities - Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); + Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/EntityPackets.java index 7c155aa37..588999191 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/packets/EntityPackets.java @@ -73,18 +73,18 @@ public final class EntityPackets extends EntityRewriter { // Add new dimension fields - CompoundTag dimensionRegistry = wrapper.get(Type.NBT, 0).get("minecraft:dimension_type"); + CompoundTag dimensionRegistry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0).get("minecraft:dimension_type"); ListTag dimensions = dimensionRegistry.get("value"); for (Tag dimension : dimensions) { CompoundTag dimensionCompound = ((CompoundTag) dimension).get("element"); addNewDimensionData(dimensionCompound); } - CompoundTag currentDimensionTag = wrapper.get(Type.NBT, 1); + CompoundTag currentDimensionTag = wrapper.get(Type.NAMED_COMPOUND_TAG, 1); addNewDimensionData(currentDimensionTag); }); handler(playerTrackerHandler()); @@ -92,7 +92,7 @@ public final class EntityPackets extends EntityRewriter { - CompoundTag dimensionData = wrapper.passthrough(Type.NBT); + CompoundTag dimensionData = wrapper.passthrough(Type.NAMED_COMPOUND_TAG); addNewDimensionData(dimensionData); }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/types/Chunk1_17Type.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/types/Chunk1_17Type.java index ddcaeb3be..0f3a4db53 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/types/Chunk1_17Type.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_17to1_16_4/types/Chunk1_17Type.java @@ -48,7 +48,7 @@ public final class Chunk1_17Type extends Type { int chunkZ = input.readInt(); BitSet sectionsMask = BitSet.valueOf(Type.LONG_ARRAY_PRIMITIVE.read(input)); - CompoundTag heightMap = Type.NBT.read(input); + CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(input); int[] biomeData = Type.VAR_INT_ARRAY_PRIMITIVE.read(input); @@ -65,7 +65,7 @@ public final class Chunk1_17Type extends Type { sections[i] = section; } - List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); // Read all the remaining bytes (workaround for #681) if (input.readableBytes() > 0) { @@ -84,7 +84,7 @@ public final class Chunk1_17Type extends Type { output.writeInt(chunk.getZ()); Type.LONG_ARRAY_PRIMITIVE.write(output, chunk.getChunkMask().toLongArray()); - Type.NBT.write(output, chunk.getHeightMap()); + Type.NAMED_COMPOUND_TAG.write(output, chunk.getHeightMap()); // Write biome data Type.VAR_INT_ARRAY_PRIMITIVE.write(output, chunk.getBiomeData()); @@ -106,7 +106,7 @@ public final class Chunk1_17Type extends Type { } // Write Block Entities - Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); + Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(EMPTY_COMPOUNDS)); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18_2to1_18/Protocol1_18_2To1_18.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18_2to1_18/Protocol1_18_2To1_18.java index 2d15380a1..4c3a73864 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18_2to1_18/Protocol1_18_2To1_18.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18_2to1_18/Protocol1_18_2To1_18.java @@ -65,22 +65,22 @@ public final class Protocol1_18_2To1_18 extends AbstractProtocol { - final CompoundTag registry = wrapper.get(Type.NBT, 0); + final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); final CompoundTag dimensionsHolder = registry.get("minecraft:dimension_type"); final ListTag dimensions = dimensionsHolder.get("value"); for (final Tag dimension : dimensions) { addTagPrefix(((CompoundTag) dimension).get("element")); } - addTagPrefix(wrapper.get(Type.NBT, 1)); + addTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1)); }); } }); - registerClientbound(ClientboundPackets1_18.RESPAWN, wrapper -> addTagPrefix(wrapper.passthrough(Type.NBT))); + registerClientbound(ClientboundPackets1_18.RESPAWN, wrapper -> addTagPrefix(wrapper.passthrough(Type.NAMED_COMPOUND_TAG))); } private void addTagPrefix(CompoundTag tag) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/EntityPackets.java index 870f3448f..b919686cb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/EntityPackets.java @@ -48,8 +48,8 @@ public final class EntityPackets extends EntityRewriter { final String world = wrapper.get(Type.STRING, 0); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java index 6a17e1c62..d3a91fb58 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java @@ -57,7 +57,7 @@ public final class WorldPackets { final int newId = BlockEntityIds.newId(id); wrapper.write(Type.VAR_INT, newId); - handleSpawners(newId, wrapper.passthrough(Type.NBT)); + handleSpawners(newId, wrapper.passthrough(Type.NAMED_COMPOUND_TAG)); }); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/types/Chunk1_18Type.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/types/Chunk1_18Type.java index f7bdbe39c..a8becb0a2 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/types/Chunk1_18Type.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/types/Chunk1_18Type.java @@ -46,7 +46,7 @@ public final class Chunk1_18Type extends Type { public Chunk read(final ByteBuf buffer) throws Exception { final int chunkX = buffer.readInt(); final int chunkZ = buffer.readInt(); - final CompoundTag heightMap = Type.NBT.read(buffer); + final CompoundTag heightMap = Type.NAMED_COMPOUND_TAG.read(buffer); // Read sections final ByteBuf sectionsBuf = buffer.readBytes(Type.VAR_INT.readPrimitive(buffer)); @@ -76,7 +76,7 @@ public final class Chunk1_18Type extends Type { buffer.writeInt(chunk.getX()); buffer.writeInt(chunk.getZ()); - Type.NBT.write(buffer, chunk.getHeightMap()); + Type.NAMED_COMPOUND_TAG.write(buffer, chunk.getHeightMap()); final ByteBuf sectionBuffer = buffer.alloc().buffer(); try { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java index 594456242..3b0921bd3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_1to1_19/Protocol1_19_1To1_19.java @@ -178,7 +178,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol { public static final MappingData MAPPINGS = new MappingDataBase("1.19", "1.19.3"); - private static final ByteArrayType.OptionalByteArrayType OPTIONAL_MESSAGE_SIGNATURE_BYTES_TYPE = new ByteArrayType.OptionalByteArrayType(256); - private static final ByteArrayType MESSAGE_SIGNATURE_BYTES_TYPE = new ByteArrayType(256); private static final BitSetType ACKNOWLEDGED_BIT_SET_TYPE = new BitSetType(20); private static final UUID ZERO_UUID = new UUID(0, 0); private static final byte[] EMPTY_BYTES = new byte[0]; @@ -216,7 +213,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol { // Remove signature - wrapper.read(OPTIONAL_MESSAGE_SIGNATURE_BYTES_TYPE); // Signature + wrapper.read(Type.OPTIONAL_SIGNATURE_BYTES); // Signature wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, EMPTY_BYTES); wrapper.write(Type.BOOLEAN, false); // No signed preview diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java index 278e5d43d..bdd0a4a78 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/packets/EntityPackets.java @@ -23,7 +23,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.BitSetType; import com.viaversion.viaversion.api.type.types.version.Types1_19; import com.viaversion.viaversion.api.type.types.version.Types1_19_3; import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1; @@ -35,8 +34,6 @@ import java.util.UUID; public final class EntityPackets extends EntityRewriter { - private static final BitSetType PROFILE_ACTIONS_ENUM_TYPE = new BitSetType(6); - public EntityPackets(final Protocol1_19_3To1_19_1 protocol) { super(protocol); } @@ -55,7 +52,7 @@ public final class EntityPackets extends EntityRewriter { - final CompoundTag registry = wrapper.get(Type.NBT, 0); + final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); final CompoundTag damageTypeRegistry = protocol.getMappingData().damageTypesRegistry(); registry.put("minecraft:damage_type", damageTypeRegistry); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java index cacc6da20..0308d16a4 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java @@ -207,9 +207,9 @@ public final class EntityPackets extends EntityRewriter { - final CompoundTag tag = wrapper.get(Type.NBT, 0); + final CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); // Add necessary chat types tag.put("minecraft:chat_type", CHAT_REGISTRY.clone()); @@ -311,7 +311,7 @@ public final class EntityPackets extends EntityRewriter { wrapper.passthrough(Type.VAR_INT); // Transaction id - wrapper.write(Type.NAMELESS_NBT, wrapper.read(Type.NBT)); + wrapper.write(Type.COMPOUND_TAG, wrapper.read(Type.NAMED_COMPOUND_TAG)); }); protocol.registerClientbound(ClientboundPackets1_19_4.BLOCK_ENTITY_DATA, wrapper -> { wrapper.passthrough(Type.POSITION1_14); // Position wrapper.passthrough(Type.VAR_INT); // Type - wrapper.write(Type.NAMELESS_NBT, handleBlockEntity(wrapper.read(Type.NBT))); + wrapper.write(Type.COMPOUND_TAG, handleBlockEntity(wrapper.read(Type.NAMED_COMPOUND_TAG))); }); protocol.registerClientbound(ClientboundPackets1_19_4.CHUNK_DATA, wrapper -> { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/EntityPacketRewriter1_20_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/EntityPacketRewriter1_20_2.java index f00ca14c8..48c344b25 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/EntityPacketRewriter1_20_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_2to1_20/rewriter/EntityPacketRewriter1_20_2.java @@ -76,7 +76,7 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter { public Chunk read(final ByteBuf buffer) throws Exception { final int chunkX = buffer.readInt(); final int chunkZ = buffer.readInt(); - final CompoundTag heightMap = Type.NAMELESS_NBT.read(buffer); + final CompoundTag heightMap = Type.COMPOUND_TAG.read(buffer); // Read sections final ByteBuf sectionsBuf = buffer.readBytes(Type.VAR_INT.readPrimitive(buffer)); @@ -73,7 +73,7 @@ public final class ChunkType1_20_2 extends Type { buffer.writeInt(chunk.getX()); buffer.writeInt(chunk.getZ()); - Type.NAMELESS_NBT.write(buffer, chunk.getHeightMap()); + Type.COMPOUND_TAG.write(buffer, chunk.getHeightMap()); final ByteBuf sectionBuffer = buffer.alloc().buffer(); try { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_3to1_20_2/Protocol1_20_3To1_20_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_3to1_20_2/Protocol1_20_3To1_20_2.java index 90fc87587..1e13c1a06 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_3to1_20_2/Protocol1_20_3To1_20_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_3to1_20_2/Protocol1_20_3To1_20_2.java @@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.StringTag; +import com.github.steveice10.opennbt.tag.builtin.Tag; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.viaversion.viaversion.api.connection.UserConnection; @@ -31,8 +32,6 @@ import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.BitSetType; -import com.viaversion.viaversion.api.type.types.ByteArrayType; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundConfigurationPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2; @@ -43,9 +42,7 @@ import java.util.BitSet; import org.checkerframework.checker.nullness.qual.Nullable; public final class Protocol1_20_3To1_20_2 extends AbstractProtocol { - private static final BitSetType PROFILE_ACTIONS_ENUM_TYPE = new BitSetType(6); - private static final ByteArrayType.OptionalByteArrayType OPTIONAL_SIGNATURE_BYTES_TYPE = new ByteArrayType.OptionalByteArrayType(256); - private static final ByteArrayType SIGNATURE_BYTES_TYPE = new ByteArrayType(256); + private final EntityPacketRewriter1_20_3 entityRewriter = new EntityPacketRewriter1_20_3(this); public Protocol1_20_3To1_20_2() { @@ -119,7 +116,7 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol { wrapper.passthrough(Type.UUID); // Sender wrapper.passthrough(Type.VAR_INT); // Index - wrapper.passthrough(OPTIONAL_SIGNATURE_BYTES_TYPE); // Signature + wrapper.passthrough(Type.OPTIONAL_SIGNATURE_BYTES); // Signature wrapper.passthrough(Type.STRING); // Plain content wrapper.passthrough(Type.LONG); // Timestamp wrapper.passthrough(Type.LONG); // Salt @@ -128,7 +125,7 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol { - wrapper.cancel(); - final BitSet actions = wrapper.passthrough(PROFILE_ACTIONS_ENUM_TYPE); + final BitSet actions = wrapper.passthrough(Type.PROFILE_ACTIONS_ENUM); final int entries = wrapper.passthrough(Type.VAR_INT); for (int i = 0; i < entries; i++) { wrapper.passthrough(Type.UUID); @@ -240,25 +236,27 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol { - final CompoundTag registry = wrapper.get(Type.NBT, 0); + final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); final CompoundTag damageTypeRegistry = registry.get("minecraft:damage_type"); final ListTag damageTypes = damageTypeRegistry.get("value"); int highestId = -1; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java index 6ad987269..260dcfcc0 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java @@ -81,7 +81,7 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/types/Chunk1_9_3_4Type.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/types/Chunk1_9_3_4Type.java index 549f421bb..2c7c29f9f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/types/Chunk1_9_3_4Type.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/types/Chunk1_9_3_4Type.java @@ -68,7 +68,7 @@ public class Chunk1_9_3_4Type extends PartialType { } } - List nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input))); + List nbtData = new ArrayList<>(Arrays.asList(Type.NAMED_COMPOUND_TAG_ARRAY.read(input))); // Read all the remaining bytes (workaround for #681) if (input.readableBytes() > 0) { @@ -115,7 +115,7 @@ public class Chunk1_9_3_4Type extends PartialType { } // Write Block Entities - Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); + Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/WorldPackets.java index e1666b073..fc1d731b1 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -209,11 +209,11 @@ public class WorldPackets { public void register() { map(Type.POSITION); // 0 - Block Position map(Type.UNSIGNED_BYTE); // 1 - Action - map(Type.NBT); // 2 - NBT (Might not be present) + map(Type.NAMED_COMPOUND_TAG); // 2 - NBT (Might not be present) handler(wrapper -> { int action = wrapper.get(Type.UNSIGNED_BYTE, 0); if (action == 1) { // Update Spawner - CompoundTag tag = wrapper.get(Type.NBT, 0); + CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); if (tag != null) { if (tag.contains("EntityId")) { String entity = (String) tag.get("EntityId").getValue(); @@ -229,7 +229,7 @@ public class WorldPackets { } if (action == 2) { // Update Command Block CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class); - provider.addOrUpdateBlock(wrapper.user(), wrapper.get(Type.POSITION, 0), wrapper.get(Type.NBT, 0)); + provider.addOrUpdateBlock(wrapper.user(), wrapper.get(Type.POSITION, 0), wrapper.get(Type.NAMED_COMPOUND_TAG, 0)); // To prevent window issues don't send updates wrapper.cancel(); @@ -396,7 +396,7 @@ public class WorldPackets { updateBlockEntity.write(Type.POSITION, pos); updateBlockEntity.write(Type.UNSIGNED_BYTE, (short) 2); - updateBlockEntity.write(Type.NBT, tag.get()); + updateBlockEntity.write(Type.NAMED_COMPOUND_TAG, tag.get()); updateBlockEntity.scheduleSend(Protocol1_9To1_8.class); } diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java index 72af536ef..d6abac704 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java @@ -45,7 +45,7 @@ public class BlockRewriter { private final Type nbtType; public BlockRewriter(Protocol protocol, Type positionType) { - this(protocol, positionType, Type.NBT); + this(protocol, positionType, Type.NAMED_COMPOUND_TAG); } public BlockRewriter(Protocol protocol, Type positionType, Type nbtType) { diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java index 012b9990a..f0a18808a 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java @@ -422,7 +422,7 @@ public abstract class EntityRewriter { EntityTracker tracker = tracker(wrapper.user()); - CompoundTag registryData = wrapper.get(Type.NBT, nbtIndex); + CompoundTag registryData = wrapper.get(Type.NAMED_COMPOUND_TAG, nbtIndex); Tag height = registryData.get("height"); if (height instanceof IntTag) { int blockHeight = ((IntTag) height).asInt(); @@ -471,7 +471,7 @@ public abstract class EntityRewriter trackBiomeSize(wrapper.user(), wrapper.get(Type.NBT, 0)); + return wrapper -> trackBiomeSize(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0)); } public void trackBiomeSize(final UserConnection connection, final CompoundTag registry) { @@ -481,7 +481,7 @@ public abstract class EntityRewriter cacheDimensionData(wrapper.user(), wrapper.get(Type.NBT, 0)); + return wrapper -> cacheDimensionData(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0)); } /**