diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java index d679f1849..7df19e7cb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java @@ -34,6 +34,7 @@ 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.protocol.remapper.ValueTransformer; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_13; @@ -145,7 +146,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { + final PacketWrapper tagsPacket = w.create(ClientboundPackets1_13.UPDATE_TAGS, wrapper -> { wrapper.write(Types.VAR_INT, MAPPINGS.getBlockTags().size()); // block tags for (Map.Entry tag : MAPPINGS.getBlockTags().entrySet()) { wrapper.write(Types.STRING, tag.getKey()); @@ -164,7 +165,13 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol implements com.viavers public void handleGeneric(final PacketWrapper wrapper) { final int length = wrapper.passthrough(Types.VAR_INT); - int editedLength = length; + int finalLength = length; + final Set readTypes = EnumSet.noneOf(RegistryType.class); for (int i = 0; i < length; i++) { final String registryKey = wrapper.read(Types.STRING); - if (toRemoveRegistries.contains(Key.stripMinecraftNamespace(registryKey))) { - wrapper.set(Types.VAR_INT, 0, --editedLength); + final String strippedKey = Key.stripMinecraftNamespace(registryKey); + if (toRemoveRegistries.contains(strippedKey)) { + finalLength--; + final int tagsSize = wrapper.read(Types.VAR_INT); for (int j = 0; j < tagsSize; j++) { wrapper.read(Types.STRING); @@ -157,7 +161,29 @@ public class TagRewriter implements com.viavers } wrapper.write(Types.STRING, registryKey); - handle(wrapper, Key.stripMinecraftNamespace(registryKey)); + + final RegistryType type = RegistryType.getByKey(registryKey); + if (type != null) { + handle(wrapper, type); + readTypes.add(type); + } else { + handle(wrapper, null, null, null, null); + } + } + + for (final Map.Entry> entry : toAdd.entrySet()) { + if (readTypes.contains(entry.getKey())) { + continue; + } + + // Registry wasn't present in the packet, add them here + wrapper.write(Types.STRING, entry.getKey().resourceLocation()); + appendNewTags(wrapper, entry.getKey()); + finalLength++; + } + + if (length != finalLength) { + wrapper.set(Types.VAR_INT, 0, finalLength); } } diff --git a/common/src/main/resources/assets/viaversion/data/enchantments-1.21.nbt b/common/src/main/resources/assets/viaversion/data/enchantments-1.21.nbt index 91baa7abd..5989737d8 100644 Binary files a/common/src/main/resources/assets/viaversion/data/enchantments-1.21.nbt and b/common/src/main/resources/assets/viaversion/data/enchantments-1.21.nbt differ