From c7dc80b71b9b534adf0a5b06cebaedd46faa441f Mon Sep 17 00:00:00 2001 From: vadage Date: Fri, 5 Apr 2024 20:32:47 +0200 Subject: [PATCH 1/5] Support config loading from input stream (#718) --- .../com/viaversion/viabackwards/ViaBackwardsConfig.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java b/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java index 8bb9ab29..dff53446 100644 --- a/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java +++ b/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java @@ -19,6 +19,7 @@ package com.viaversion.viabackwards; import com.viaversion.viaversion.util.Config; import java.io.File; +import java.io.InputStream; import java.net.URL; import java.util.Collections; import java.util.List; @@ -87,6 +88,11 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback return getClass().getClassLoader().getResource("assets/viabackwards/config.yml"); } + @Override + public InputStream getDefaultConfigInputStream() { + return getClass().getClassLoader().getResourceAsStream("assets/viabackwards/config.yml"); + } + @Override protected void handleConfig(Map map) { } From 9cf5f98ed1f41fa17543535c06baa5fd7aa45476 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Tue, 16 Apr 2024 21:00:20 +0200 Subject: [PATCH 2/5] Replace incoming/outgoing usages with client/server bound (#720) --- .../packets/PlayerPacket1_13.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java index 1ffba60c..25e379a0 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java @@ -28,7 +28,6 @@ import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; 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.rewriter.RewriterBase; import com.viaversion.viaversion.api.type.Type; @@ -39,9 +38,11 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPacke import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import com.viaversion.viaversion.rewriter.CommandRewriter; +import com.viaversion.viaversion.util.Key; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; @@ -100,7 +101,7 @@ public class PlayerPacket1_13 extends RewriterBase { String oldChannel = InventoryPackets.getOldPluginChannelId(channel); if (oldChannel == null) { if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - ViaBackwards.getPlatform().getLogger().warning("Ignoring outgoing plugin message with channel: " + channel); + ViaBackwards.getPlatform().getLogger().warning("Ignoring clientbound plugin message with channel: " + channel); } wrapper.cancel(); return; @@ -115,7 +116,7 @@ public class PlayerPacket1_13 extends RewriterBase { if (rewritten != null) { rewrittenChannels.add(rewritten); } else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + s); + ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in clientbound " + oldChannel + ": " + s); } } wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8)); @@ -489,7 +490,7 @@ public class PlayerPacket1_13 extends RewriterBase { String newChannel = InventoryPackets.getNewPluginChannelId(channel); if (newChannel == null) { if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - ViaBackwards.getPlatform().getLogger().warning("Ignoring incoming plugin message with channel: " + channel); + ViaBackwards.getPlatform().getLogger().warning("Ignoring serverbound plugin message with channel: " + channel); } wrapper.cancel(); return; @@ -504,7 +505,7 @@ public class PlayerPacket1_13 extends RewriterBase { if (rewritten != null) { rewrittenChannels.add(rewritten); } else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + s); + ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in serverbound " + Key.stripMinecraftNamespace(newChannel).toUpperCase(Locale.ROOT) + ": " + s); } } if (!rewrittenChannels.isEmpty()) { From 09eda340513dcd005e5640ed01a60471237a1d7f Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Tue, 16 Apr 2024 21:05:45 +0200 Subject: [PATCH 3/5] Use VVs IdAndData class for block id conversions (#719) --- .../api/data/MappedLegacyBlockItem.java | 8 +- .../rewriters/LegacyBlockItemRewriter.java | 34 ++++---- .../packets/BlockItemPackets1_11.java | 4 +- .../packets/BlockItemPackets1_13.java | 10 +-- .../viaversion/viabackwards/utils/Block.java | 77 ------------------- 5 files changed, 28 insertions(+), 105 deletions(-) delete mode 100644 common/src/main/java/com/viaversion/viabackwards/utils/Block.java diff --git a/common/src/main/java/com/viaversion/viabackwards/api/data/MappedLegacyBlockItem.java b/common/src/main/java/com/viaversion/viabackwards/api/data/MappedLegacyBlockItem.java index eff12d93..a5d352de 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/data/MappedLegacyBlockItem.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/data/MappedLegacyBlockItem.java @@ -17,8 +17,8 @@ */ package com.viaversion.viabackwards.api.data; -import com.viaversion.viabackwards.utils.Block; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; +import com.viaversion.viaversion.util.IdAndData; import org.checkerframework.checker.nullness.qual.Nullable; public class MappedLegacyBlockItem { @@ -26,14 +26,14 @@ public class MappedLegacyBlockItem { private final int id; private final short data; private final String name; - private final Block block; + private final IdAndData block; private BlockEntityHandler blockEntityHandler; public MappedLegacyBlockItem(int id, short data, @Nullable String name, boolean block) { this.id = id; this.data = data; this.name = name != null ? "§f" + name : null; - this.block = block ? new Block(id, data) : null; + this.block = block ? new IdAndData(id, data) : null; } public int getId() { @@ -52,7 +52,7 @@ public class MappedLegacyBlockItem { return block != null; } - public Block getBlock() { + public IdAndData getBlock() { return block; } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java index a43fb212..fdeaff00 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java @@ -22,7 +22,6 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem; import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader; import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors; -import com.viaversion.viabackwards.utils.Block; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; @@ -51,6 +50,7 @@ import com.viaversion.viaversion.util.ComponentUtil; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import com.viaversion.viaversion.util.IdAndData; import org.checkerframework.checker.nullness.qual.Nullable; public abstract class LegacyBlockItemRewriter> 12 & 15); + final IdAndData block = handleBlock(objectData & 4095, objectData >> 12 & 15); if (block == null) return; wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12); @@ -216,11 +216,11 @@ public abstract class LegacyBlockItemRewriter> 4; int meta = block & 0xF; - Block b = handleBlock(btype, meta); + IdAndData b = handleBlock(btype, meta); if (b != null) { - palette.setIdByIndex(j, Block.toRawId(b.getId(), b.getData())); + palette.setIdByIndex(j, IdAndData.toRawData(b.getId(), b.getData())); } // We already know that is has a handler @@ -336,13 +336,13 @@ public abstract class LegacyBlockItemRewriter new MappedLegacyBlockItem(52, (short) -1, null, false)); + MappedLegacyBlockItem data = replacementData.computeIfAbsent(IdAndData.toRawData(52), s -> new MappedLegacyBlockItem(52, (short) -1, null, false)); data.setBlockEntityHandler((b, tag) -> { EntityIdRewriter.toClientSpawner(tag, true); return tag; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java index 3427f269..b69d9931 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java @@ -26,7 +26,6 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_ha import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider; import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage; import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.NoteBlockStorage; -import com.viaversion.viabackwards.utils.Block; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; @@ -56,6 +55,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.BlockIdData; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter; import com.viaversion.viaversion.util.ComponentUtil; +import com.viaversion.viaversion.util.IdAndData; import com.viaversion.viaversion.util.Key; import com.viaversion.viaversion.util.Pair; import java.util.ArrayList; @@ -100,11 +100,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit } if (SpawnEggRewriter.getEntityId(oldId).isPresent()) { - wrapper.write(Type.VAR_INT, Block.rawById(383)); + wrapper.write(Type.VAR_INT, IdAndData.toRawData(383)); return; } - wrapper.write(Type.VAR_INT, Block.getId(oldId)); + wrapper.write(Type.VAR_INT, IdAndData.getId(oldId)); }); protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketHandlers() { @@ -751,7 +751,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit // Save original id int originalId = (item.identifier() << 16 | item.data() & 0xFFFF); - int rawId = Block.toRawId(item.identifier(), item.data()); + int rawId = IdAndData.toRawData(item.identifier(), item.data()); // NBT Additions if (isDamageable(item.identifier())) { @@ -832,7 +832,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit if (item.identifier() == 229) { // purple shulker box newId = 362; // directly set the new id -> base/colorless shulker box } else if (item.identifier() == 31 && item.data() == 0) { // Shrub was removed - rawId = Block.rawById(32); // Dead Bush + rawId = IdAndData.toRawData(32); // Dead Bush } else if (protocol.getMappingData().getItemMappings().inverse().getNewId(rawId & ~0xF) != -1) { rawId &= ~0xF; // Remove data } else { diff --git a/common/src/main/java/com/viaversion/viabackwards/utils/Block.java b/common/src/main/java/com/viaversion/viabackwards/utils/Block.java deleted file mode 100644 index 645400cc..00000000 --- a/common/src/main/java/com/viaversion/viabackwards/utils/Block.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards - * Copyright (C) 2016-2024 ViaVersion and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.viaversion.viabackwards.utils; - -public class Block { - private final int id; - private final short data; - - public Block(int id, int data) { - this.id = id; - this.data = (short) data; - } - - public int getId() { - return id; - } - - public int getData() { - return data; - } - - public Block withData(int data) { - return new Block(this.id, data); - } - - public static int getId(final int rawId) { - return rawId >> 4; - } - - public static int getData(final int rawId) { - return rawId & 15; - } - - public static int rawById(final int id) { - return id << 4; - } - - public static int rawByData(final int data) { - return data & ~15; - } - - public static int toRawId(final int id, final int data) { - return (id << 4) | (data & 15); - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Block block = (Block) o; - if (id != block.id) return false; - return data == block.data; - } - - @Override - public int hashCode() { - int result = id; - result = 31 * result + data; - return result; - } -} From 1ac504afb9409e4f549ca52f8eda12a175beaf04 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Wed, 17 Apr 2024 08:46:48 +0200 Subject: [PATCH 4/5] Use correct constructor in MappedLegacyBlockItem (#721) --- .../viaversion/viabackwards/api/data/MappedLegacyBlockItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/data/MappedLegacyBlockItem.java b/common/src/main/java/com/viaversion/viabackwards/api/data/MappedLegacyBlockItem.java index a5d352de..88aeaebd 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/data/MappedLegacyBlockItem.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/data/MappedLegacyBlockItem.java @@ -33,7 +33,7 @@ public class MappedLegacyBlockItem { this.id = id; this.data = data; this.name = name != null ? "§f" + name : null; - this.block = block ? new IdAndData(id, data) : null; + this.block = block ? data != -1 ? new IdAndData(id, data) : new IdAndData(id) : null; } public int getId() { From c64e9acf353826d9ab152b9cd8f4cc29a20ead7a Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 18 Apr 2024 16:26:03 +0200 Subject: [PATCH 5/5] Override getTagRewriter methods --- .../protocol1_13to1_13_1/Protocol1_13To1_13_1.java | 8 +++++++- .../protocol1_14_4to1_15/Protocol1_14_4To1_15.java | 8 +++++++- .../protocol1_15_2to1_16/Protocol1_15_2To1_16.java | 8 +++++++- .../protocol1_16_1to1_16_2/Protocol1_16_1To1_16_2.java | 8 +++++++- .../protocol1_16_4to1_17/Protocol1_16_4To1_17.java | 7 ++++++- .../protocol1_17_1to1_18/Protocol1_17_1To1_18.java | 7 ++++++- .../protocol1_18_2to1_19/Protocol1_18_2To1_19.java | 7 ++++++- .../protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java | 7 ++++++- .../protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java | 7 ++++++- .../protocol1_19_4to1_20/Protocol1_19_4To1_20.java | 7 ++++++- .../protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java | 7 ++++++- .../protocol1_20_3to1_20_5/Protocol1_20_3To1_20_5.java | 7 ++++++- .../protocol1_20to1_20_2/Protocol1_20To1_20_2.java | 7 ++++++- .../template/protocol/Protocol1_98To1_99.java | 7 ++++++- 14 files changed, 88 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java index 54164332..e1afa44e 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java @@ -51,6 +51,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_13To1_13_1() { super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); @@ -198,7 +199,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol(this).register(ClientboundPackets1_13.TAGS, RegistryType.ITEM); + tagRewriter.register(ClientboundPackets1_13.TAGS, RegistryType.ITEM); new StatisticsRewriter<>(this).register(ClientboundPackets1_13.STATISTICS); } @@ -229,4 +230,9 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol translatableRewriter() { return translatableRewriter; } + + @Override + public TagRewriter getTagRewriter() { + return tagRewriter; + } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java index 50e063e8..8087d565 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java @@ -45,6 +45,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_14_4To1_15() { super(ClientboundPackets1_15.class, ClientboundPackets1_14_4.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class); @@ -94,7 +95,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol(this).register(ClientboundPackets1_15.TAGS, RegistryType.ENTITY); + tagRewriter.register(ClientboundPackets1_15.TAGS, RegistryType.ENTITY); new StatisticsRewriter<>(this).register(ClientboundPackets1_15.STATISTICS); } @@ -120,6 +121,11 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol getTagRewriter() { + return tagRewriter; + } + @Override public TranslatableRewriter getTranslatableRewriter() { return translatableRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java index 5e55e274..f05da4e9 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java @@ -51,6 +51,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); public Protocol1_15_2To1_16() { super(ClientboundPackets1_16.class, ClientboundPackets1_15.class, ServerboundPackets1_16.class, ServerboundPackets1_14.class); @@ -118,7 +119,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol(this).register(ClientboundPackets1_16.TAGS, RegistryType.ENTITY); + tagRewriter.register(ClientboundPackets1_16.TAGS, RegistryType.ENTITY); new StatisticsRewriter<>(this).register(ClientboundPackets1_16.STATISTICS); @@ -192,4 +193,9 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol getTagRewriter() { + return tagRewriter; + } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/Protocol1_16_1To1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/Protocol1_16_1To1_16_2.java index f8fc5c3f..cf6a66c8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/Protocol1_16_1To1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/Protocol1_16_1To1_16_2.java @@ -47,6 +47,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_16_1To1_16_2() { super(ClientboundPackets1_16_2.class, ClientboundPackets1_16.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16.class); @@ -101,7 +102,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol(this).register(ClientboundPackets1_16_2.TAGS, RegistryType.ENTITY); + tagRewriter.register(ClientboundPackets1_16_2.TAGS, RegistryType.ENTITY); new StatisticsRewriter<>(this).register(ClientboundPackets1_16_2.STATISTICS); } @@ -142,4 +143,9 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol getTagRewriter() { + return tagRewriter; + } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java index 40d8750b..1a6c7757 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java @@ -59,6 +59,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_16_4To1_17() { super(ClientboundPackets1_17.class, ClientboundPackets1_16_2.class, ServerboundPackets1_17.class, ServerboundPackets1_16_2.class); @@ -81,7 +82,6 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); registerClientbound(ClientboundPackets1_17.TAGS, wrapper -> { Map> tags = new HashMap<>(); @@ -249,4 +249,9 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol getTagRewriter() { + return tagRewriter; + } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java index f7eb2607..82178c76 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java @@ -42,6 +42,7 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_17_1To1_18() { super(ClientboundPackets1_18.class, ClientboundPackets1_17_1.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class); @@ -68,7 +69,6 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:lava_pool_stone_replaceables"); tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS); @@ -154,4 +154,9 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } + + @Override + public TagRewriter getTagRewriter() { + return tagRewriter; + } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/Protocol1_18_2To1_19.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/Protocol1_18_2To1_19.java index 790e279d..67990a89 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/Protocol1_18_2To1_19.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/Protocol1_18_2To1_19.java @@ -69,6 +69,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_18_2To1_19() { super(ClientboundPackets1_19.class, ClientboundPackets1_18.class, ServerboundPackets1_19.class, ServerboundPackets1_17.class); @@ -131,7 +132,6 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.removeTags("minecraft:banner_pattern"); tagRewriter.removeTags("minecraft:instrument"); tagRewriter.removeTags("minecraft:cat_variant"); @@ -371,4 +371,9 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol getTagRewriter() { + return tagRewriter; + } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java index 8c2005fd..f990d838 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java @@ -72,6 +72,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_19_1To1_19_3() { super(ClientboundPackets1_19_3.class, ClientboundPackets1_19_1.class, ServerboundPackets1_19_3.class, ServerboundPackets1_19_1.class); @@ -116,7 +117,6 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:non_flammable_wood"); tagRewriter.addEmptyTag(RegistryType.ITEM, "minecraft:overworld_natural_logs"); tagRewriter.registerGeneric(ClientboundPackets1_19_3.TAGS); @@ -404,4 +404,9 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol getTagRewriter() { + return tagRewriter; + } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java index 70712230..7c92fa1a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java @@ -47,6 +47,7 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_19_3To1_19_4() { super(ClientboundPackets1_19_4.class, ClientboundPackets1_19_3.class, ServerboundPackets1_19_4.class, ServerboundPackets1_19_3.class); @@ -96,7 +97,6 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.removeTags("minecraft:damage_type"); tagRewriter.registerGeneric(ClientboundPackets1_19_4.TAGS); @@ -139,4 +139,9 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } + + @Override + public TagRewriter getTagRewriter() { + return tagRewriter; + } } \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/Protocol1_19_4To1_20.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/Protocol1_19_4To1_20.java index 86ee3ec6..f02cf8b4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/Protocol1_19_4To1_20.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/Protocol1_19_4To1_20.java @@ -41,6 +41,7 @@ public final class Protocol1_19_4To1_20 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); private final EntityPackets1_20 entityRewriter = new EntityPackets1_20(this); private final BlockItemPackets1_20 itemRewriter = new BlockItemPackets1_20(this); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_19_4To1_20() { super(ClientboundPackets1_19_4.class, ClientboundPackets1_19_4.class, ServerboundPackets1_19_4.class, ServerboundPackets1_19_4.class); @@ -50,7 +51,6 @@ public final class Protocol1_19_4To1_20 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:replaceable_plants"); tagRewriter.registerGeneric(ClientboundPackets1_19_4.TAGS); @@ -115,4 +115,9 @@ public final class Protocol1_19_4To1_20 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } + + @Override + public TagRewriter getTagRewriter() { + return tagRewriter; + } } \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java index 1dafc9da..5f3b4871 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/Protocol1_20_2To1_20_3.java @@ -65,6 +65,7 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_20_2To1_20_3() { super(ClientboundPacket1_20_3.class, ClientboundPacket1_20_2.class, ServerboundPacket1_20_3.class, ServerboundPacket1_20_2.class); @@ -74,7 +75,6 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.registerGeneric(ClientboundPackets1_20_3.TAGS); final SoundRewriter soundRewriter = new SoundRewriter<>(this); @@ -406,6 +406,11 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol getTagRewriter() { + return tagRewriter; + } + @Override protected PacketTypesProvider createPacketTypesProvider() { return new SimplePacketTypesProvider<>( diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/Protocol1_20_3To1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/Protocol1_20_3To1_20_5.java index 99f762ea..e8dbdb71 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/Protocol1_20_3To1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/Protocol1_20_3To1_20_5.java @@ -66,6 +66,7 @@ public final class Protocol1_20_3To1_20_5 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_20_3To1_20_5() { super(ClientboundPacket1_20_5.class, ClientboundPacket1_20_3.class, ServerboundPacket1_20_5.class, ServerboundPacket1_20_3.class); @@ -75,7 +76,6 @@ public final class Protocol1_20_3To1_20_5 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.registerGeneric(ClientboundPackets1_20_5.TAGS); registerClientbound(ClientboundConfigurationPackets1_20_5.UPDATE_TAGS, wrapper -> { // Send off registry data first @@ -202,6 +202,11 @@ public final class Protocol1_20_3To1_20_5 extends BackwardsProtocol getTagRewriter() { + return tagRewriter; + } + @Override protected PacketTypesProvider createPacketTypesProvider() { return new SimplePacketTypesProvider<>( diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java index ed97c2bc..df597ba3 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/Protocol1_20To1_20_2.java @@ -51,6 +51,7 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); public Protocol1_20To1_20_2() { super(ClientboundPackets1_20_2.class, ClientboundPackets1_19_4.class, ServerboundPackets1_20_2.class, ServerboundPackets1_19_4.class); @@ -60,7 +61,6 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.registerGeneric(ClientboundPackets1_20_2.TAGS); final SoundRewriter soundRewriter = new SoundRewriter<>(this); @@ -216,4 +216,9 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol getItemRewriter() { return itemPacketRewriter; } + + @Override + public TagRewriter getTagRewriter() { + return tagRewriter; + } } \ No newline at end of file diff --git a/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java b/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java index 72f499ea..b8d36bd3 100644 --- a/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java +++ b/template/src/main/java/com/viaversion/viabackwards/template/protocol/Protocol1_98To1_99.java @@ -51,6 +51,7 @@ public final class Protocol1_98To1_99 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); + private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_98To1_99() { super(ClientboundPacket1_20_5.class, ClientboundPacket1_20_5.class, ServerboundPacket1_20_5.class, ServerboundPacket1_20_5.class); @@ -60,7 +61,6 @@ public final class Protocol1_98To1_99 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.registerGeneric(ClientboundPackets1_20_5.TAGS); tagRewriter.registerGeneric(ClientboundConfigurationPackets1_20_5.UPDATE_TAGS); @@ -111,5 +111,10 @@ public final class Protocol1_98To1_99 extends BackwardsProtocol getTagRewriter() { + return tagRewriter; + } + // createPacketTypesProvider } \ No newline at end of file