diff --git a/common/src/main/java/com/viaversion/viabackwards/api/BackwardsProtocol.java b/common/src/main/java/com/viaversion/viabackwards/api/BackwardsProtocol.java index 80adf8f4..4e3ce394 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/BackwardsProtocol.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/BackwardsProtocol.java @@ -18,7 +18,7 @@ package com.viaversion.viabackwards.api; import com.viaversion.viabackwards.api.data.BackwardsMappingData; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.TranslatableRewriter; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.Protocol; @@ -66,7 +66,7 @@ public boolean hasMappingDataToLoad() { } @Override - public @Nullable TranslatableRewriter getComponentRewriter() { + public @Nullable TranslatableRewriter getComponentRewriter() { return null; } } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java index 242e03ea..1407390e 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsPlatform.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.ViaBackwardsConfig; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.data.TranslatableMappings; import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10; import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1; import com.viaversion.viabackwards.protocol.v1_11_1to1_11.Protocol1_11_1To1_11; @@ -92,7 +92,7 @@ default void init(final File configFile) { Via.getManager().getSubPlatforms().add(VersionInfo.getImplementationVersion()); getLogger().info("Loading translations..."); - TranslatableRewriter.loadTranslatables(); + TranslatableMappings.loadTranslatables(); getLogger().info("Registering protocols..."); final ProtocolManager protocolManager = Via.getManager().getProtocolManager(); diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/data/TranslatableMappings.java similarity index 54% rename from common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java rename to common/src/main/java/com/viaversion/viabackwards/api/data/TranslatableMappings.java index 1a186252..f47509d8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/data/TranslatableMappings.java @@ -15,26 +15,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.viaversion.viabackwards.api.rewriters; +package com.viaversion.viabackwards.api.data; -import com.viaversion.nbt.tag.CompoundTag; -import com.viaversion.nbt.tag.StringTag; import com.viaversion.viabackwards.ViaBackwards; -import com.viaversion.viabackwards.api.BackwardsProtocol; -import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; +import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; -import com.viaversion.viaversion.rewriter.ComponentRewriter; import java.util.HashMap; import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; -public class TranslatableRewriter extends ComponentRewriter { +public final class TranslatableMappings { private static final Map> TRANSLATABLES = new HashMap<>(); - private final Map translatables; public static void loadTranslatables() { if (!TRANSLATABLES.isEmpty()) { @@ -53,42 +46,24 @@ public static void fillTranslatables(final JsonObject jsonObject, final Map protocol, final ReadType type) { - this(protocol, type, protocol.getClass().getSimpleName().replace("Protocol", "").split("To")[0].replace("_", ".")); + public static Map translatablesFor(final Protocol protocol) { + final String version = protocol.getClass().getSimpleName() + .replace("Protocol", "") + .split("To")[0] + .replace("_", "."); + return translatablesFor(version); } - public TranslatableRewriter(final BackwardsProtocol protocol, final ReadType type, final String version) { - super(protocol, type); + public static Map translatablesFor(final String version) { final Map translatableMappings = getTranslatableMappings(version); if (translatableMappings == null) { ViaBackwards.getPlatform().getLogger().warning("Missing " + version + " translatables!"); - this.translatables = new HashMap<>(); - } else { - this.translatables = translatableMappings; + return new HashMap<>(); } + return translatableMappings; } - @Override - protected void handleTranslate(final JsonObject root, final String translate) { - final String newTranslate = mappedTranslationKey(translate); - if (newTranslate != null) { - root.addProperty("translate", newTranslate); - } - } - - @Override - protected void handleTranslate(final UserConnection connection, final CompoundTag parentTag, final StringTag translateTag) { - final String newTranslate = mappedTranslationKey(translateTag.getValue()); - if (newTranslate != null) { - parentTag.put("translate", new StringTag(newTranslate)); - } - } - - public @Nullable String mappedTranslationKey(final String translationKey) { - return translatables.get(translationKey); - } - - public static Map getTranslatableMappings(final String sectionIdentifier) { + public static @Nullable Map getTranslatableMappings(final String sectionIdentifier) { return TRANSLATABLES.get(sectionIdentifier); } } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/text/JsonNBTComponentRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/text/JsonNBTComponentRewriter.java new file mode 100644 index 00000000..730fd939 --- /dev/null +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/text/JsonNBTComponentRewriter.java @@ -0,0 +1,64 @@ +/* + * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards + * Copyright (C) 2016-2025 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.api.rewriters.text; + +import com.viaversion.nbt.tag.CompoundTag; +import com.viaversion.nbt.tag.StringTag; +import com.viaversion.viabackwards.api.BackwardsProtocol; +import com.viaversion.viabackwards.api.data.TranslatableMappings; +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; +import com.viaversion.viaversion.libs.gson.JsonObject; +import java.util.Map; +import org.checkerframework.checker.nullness.qual.Nullable; + +public class JsonNBTComponentRewriter extends com.viaversion.viaversion.rewriter.text.JsonNBTComponentRewriter implements TranslatableRewriter { + + private final Map translatables; + + public JsonNBTComponentRewriter(final BackwardsProtocol protocol, final ReadType type) { + super(protocol, type); + this.translatables = TranslatableMappings.translatablesFor(protocol); + } + + public JsonNBTComponentRewriter(final BackwardsProtocol protocol, final ReadType type, final String version) { + super(protocol, type); + this.translatables = TranslatableMappings.translatablesFor(version); + } + + @Override + protected void handleTranslate(final JsonObject root, final String translate) { + final String newTranslate = mappedTranslationKey(translate); + if (newTranslate != null) { + root.addProperty("translate", newTranslate); + } + } + + @Override + protected void handleTranslate(final UserConnection connection, final CompoundTag parentTag, final StringTag translateTag) { + final String newTranslate = mappedTranslationKey(translateTag.getValue()); + if (newTranslate != null) { + parentTag.put("translate", new StringTag(newTranslate)); + } + } + + @Override + public @Nullable String mappedTranslationKey(final String translationKey) { + return translatables.get(translationKey); + } +} diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/text/NBTComponentRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/text/NBTComponentRewriter.java new file mode 100644 index 00000000..b96e8a0b --- /dev/null +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/text/NBTComponentRewriter.java @@ -0,0 +1,64 @@ +/* + * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards + * Copyright (C) 2016-2025 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.api.rewriters.text; + +import com.viaversion.nbt.tag.CompoundTag; +import com.viaversion.nbt.tag.StringTag; +import com.viaversion.viabackwards.api.BackwardsProtocol; +import com.viaversion.viabackwards.api.data.TranslatableMappings; +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; +import com.viaversion.viaversion.libs.gson.JsonObject; +import java.util.Map; +import org.checkerframework.checker.nullness.qual.Nullable; + +public class NBTComponentRewriter extends com.viaversion.viaversion.rewriter.text.NBTComponentRewriter implements TranslatableRewriter { + + private final Map translatables; + + public NBTComponentRewriter(final BackwardsProtocol protocol) { + super(protocol); + this.translatables = TranslatableMappings.translatablesFor(protocol); + } + + public NBTComponentRewriter(final BackwardsProtocol protocol, final String version) { + super(protocol); + this.translatables = TranslatableMappings.translatablesFor(version); + } + + @Override + protected void handleTranslate(final JsonObject root, final String translate) { + final String newTranslate = mappedTranslationKey(translate); + if (newTranslate != null) { + root.addProperty("translate", newTranslate); + } + } + + @Override + protected void handleTranslate(final UserConnection connection, final CompoundTag parentTag, final StringTag translateTag) { + final String newTranslate = mappedTranslationKey(translateTag.getValue()); + if (newTranslate != null) { + parentTag.put("translate", new StringTag(newTranslate)); + } + } + + @Override + public @Nullable String mappedTranslationKey(final String translationKey) { + return translatables.get(translationKey); + } +} diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/text/TranslatableRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/text/TranslatableRewriter.java new file mode 100644 index 00000000..fb0106ff --- /dev/null +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/text/TranslatableRewriter.java @@ -0,0 +1,27 @@ +/* + * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards + * Copyright (C) 2016-2025 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.api.rewriters.text; + +import com.viaversion.viaversion.api.rewriter.ComponentRewriter; +import org.checkerframework.checker.nullness.qual.Nullable; + +public interface TranslatableRewriter extends ComponentRewriter { + + @Nullable + String mappedTranslationKey(String translationKey); +} diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/template/ComponentRewriter1_99.java b/common/src/main/java/com/viaversion/viabackwards/protocol/template/ComponentRewriter1_99.java index 874a4db6..fca4a91b 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/template/ComponentRewriter1_99.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/template/ComponentRewriter1_99.java @@ -19,15 +19,14 @@ import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viabackwards.api.BackwardsProtocol; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.NBTComponentRewriter; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2; -import com.viaversion.viaversion.util.SerializerVersion; -final class ComponentRewriter1_99 extends TranslatableRewriter { +final class ComponentRewriter1_99 extends NBTComponentRewriter { public ComponentRewriter1_99(final BackwardsProtocol protocol) { - super(protocol, ReadType.NBT); + super(protocol); } @Override @@ -38,11 +37,6 @@ protected void handleShowItem(final UserConnection connection, final CompoundTag } // Remove or update data from componentsTag - // New added data which is not handled otherwise needs to be removed to prevent errors on the client - } - - @Override - protected SerializerVersion inputSerializerVersion() { - return SerializerVersion.V1_21_4; + // Newly added data which is not handled otherwise needs to be removed to prevent errors on the client } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/template/Protocol1_98To1_99.java b/common/src/main/java/com/viaversion/viabackwards/protocol/template/Protocol1_98To1_99.java index f0603f89..a966ea9a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/template/Protocol1_98To1_99.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/template/Protocol1_98To1_99.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.NBTComponentRewriter; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_4; import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider; @@ -57,7 +57,7 @@ final class Protocol1_98To1_99 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this, Types1_21_4.PARTICLE/*, Types1_OLD.PARTICLE*/); - private final TranslatableRewriter translatableRewriter = new ComponentRewriter1_99(this); + private final NBTComponentRewriter translatableRewriter = new ComponentRewriter1_99(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_98To1_99() { @@ -80,7 +80,7 @@ protected void registerPackets() { //new AttributeRewriter<>(this).register1_21(ClientboundPackets1_21_2.UPDATE_ATTRIBUTES); // Registers translatable mappings (missing a whole bunch still) - //translatableRewriter.registerOpenScreen(ClientboundPackets1_21_2.OPEN_SCREEN); // Handled by registerOpenScreen in item rewriters + //translatableRewriter.registerOpenScreen1_14(ClientboundPackets1_21_2.OPEN_SCREEN); // Handled by registerOpenScreen in item rewriters translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_ACTION_BAR_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_SUBTITLE_TEXT); @@ -124,7 +124,7 @@ public ParticleRewriter getParticleRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public NBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_10to1_9_3/Protocol1_10To1_9_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_10to1_9_3/Protocol1_10To1_9_3.java index eb0f074b..c5906c14 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_10to1_9_3/Protocol1_10To1_9_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_10to1_9_3/Protocol1_10To1_9_3.java @@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_10to1_9_3.rewriter.BlockItemPacketRewriter1_10; import com.viaversion.viabackwards.protocol.v1_10to1_9_3.rewriter.EntityPacketRewriter1_10; import com.viaversion.viaversion.api.connection.UserConnection; @@ -34,7 +34,7 @@ import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; public class Protocol1_10To1_9_3 extends BackwardsProtocol { @@ -92,7 +92,7 @@ public void register() { } }); - TranslatableRewriter componentRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + JsonNBTComponentRewriter componentRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); componentRewriter.registerComponentPacket(ClientboundPackets1_9_3.CHAT); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/Protocol1_11To1_10.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/Protocol1_11To1_10.java index 5b3bd878..6582def4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/Protocol1_11To1_10.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/Protocol1_11To1_10.java @@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.BlockItemPacketRewriter1_11; import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.EntityPacketRewriter1_11; import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.PlayerPacketRewriter1_11; @@ -30,17 +30,16 @@ import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11; import com.viaversion.viaversion.data.entity.EntityTrackerBase; -import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; public class Protocol1_11To1_10 extends BackwardsProtocol { public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.11", "1.10"); private final EntityPacketRewriter1_11 entityRewriter = new EntityPacketRewriter1_11(this); private final BlockItemPacketRewriter1_11 itemRewriter = new BlockItemPacketRewriter1_11(this); - private TranslatableRewriter componentRewriter; + private JsonNBTComponentRewriter componentRewriter; public Protocol1_11To1_10() { super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class); @@ -56,7 +55,7 @@ protected void registerPackets() { soundRewriter.registerNamedSound(ClientboundPackets1_9_3.CUSTOM_SOUND); soundRewriter.registerSound(ClientboundPackets1_9_3.SOUND); - componentRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + componentRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); componentRewriter.registerComponentPacket(ClientboundPackets1_9_3.CHAT); } @@ -85,7 +84,7 @@ public BlockItemPacketRewriter1_11 getItemRewriter() { return itemRewriter; } - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return componentRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_12to1_11_1/rewriter/ComponentRewriter1_12.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_12to1_11_1/rewriter/ComponentRewriter1_12.java index d995dd5c..5851d04a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_12to1_11_1/rewriter/ComponentRewriter1_12.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_12to1_11_1/rewriter/ComponentRewriter1_12.java @@ -18,18 +18,18 @@ package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; -public class ComponentRewriter1_12 extends TranslatableRewriter { +public class ComponentRewriter1_12 extends JsonNBTComponentRewriter { public ComponentRewriter1_12(Protocol1_12To1_11_1 protocol) { - super(protocol, ComponentRewriter.ReadType.JSON); + super(protocol, ComponentRewriterBase.ReadType.JSON); } @Override diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/Protocol1_13_1To1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/Protocol1_13_1To1_13.java index fc96d725..01ae8046 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/Protocol1_13_1To1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/Protocol1_13_1To1_13.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter.CommandRewriter1_13_1; import com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter.EntityPacketRewriter1_13_1; import com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter.ItemPacketRewriter1_13_1; @@ -40,7 +40,7 @@ import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13; import com.viaversion.viaversion.protocols.v1_13to1_13_1.Protocol1_13To1_13_1; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -52,7 +52,7 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_13_1To1_13() { @@ -230,7 +230,7 @@ public ParticleRewriter getParticleRewriter() { return particleRewriter; } - public TranslatableRewriter translatableRewriter() { + public JsonNBTComponentRewriter translatableRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/Protocol1_13To1_12_2.java index 0e0894dd..25f173ca 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/Protocol1_13To1_12_2.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.BackwardsProtocol; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_13to1_12_2.data.BackwardsMappingData1_13; import com.viaversion.viabackwards.protocol.v1_13to1_12_2.data.PaintingNames1_13; import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider; @@ -45,7 +45,7 @@ import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ClientboundPackets1_12_1; import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ServerboundPackets1_12_1; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.util.ComponentUtil; import com.viaversion.viaversion.util.ProtocolLogger; import org.checkerframework.checker.nullness.qual.Nullable; @@ -56,7 +56,7 @@ public class Protocol1_13To1_12_2 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON) { + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON) { @Override protected void handleTranslate(JsonObject root, String translate) { String mappedKey = mappedTranslationKey(translate); @@ -65,7 +65,7 @@ protected void handleTranslate(JsonObject root, String translate) { } } }; - private final TranslatableRewriter translatableToLegacyRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON) { + private final JsonNBTComponentRewriter translatableToLegacyRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON) { @Override protected void handleTranslate(JsonObject root, String translate) { String mappedKey = mappedTranslationKey(translate); @@ -148,7 +148,7 @@ public BlockItemPacketRewriter1_13 getItemRewriter() { } // Don't override the parent method - public TranslatableRewriter translatableRewriter() { + public JsonNBTComponentRewriter translatableRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/Protocol1_14To1_13_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/Protocol1_14To1_13_2.java index 327d7cda..9edd5a1e 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/Protocol1_14To1_13_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/Protocol1_14To1_13_2.java @@ -19,7 +19,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter.BlockItemPacketRewriter1_14; import com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter.CommandRewriter1_14; import com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter.EntityPacketRewriter1_14; @@ -37,7 +37,7 @@ import com.viaversion.viaversion.protocols.v1_13_2to1_14.Protocol1_13_2To1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPackets1_14; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; @@ -47,7 +47,7 @@ public class Protocol1_14To1_13_2 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); public Protocol1_14To1_13_2() { super(ClientboundPackets1_14.class, ClientboundPackets1_13.class, ServerboundPackets1_14.class, ServerboundPackets1_13.class); @@ -197,7 +197,7 @@ public ParticleRewriter getParticleRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java index 2295ff4b..ee11302b 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java @@ -21,9 +21,9 @@ import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.ListTag; import com.viaversion.nbt.tag.StringTag; +import com.viaversion.viabackwards.api.data.TranslatableMappings; import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter; import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; import com.viaversion.viabackwards.protocol.v1_14to1_13_2.Protocol1_14To1_13_2; import com.viaversion.viabackwards.protocol.v1_14to1_13_2.storage.ChunkLightStorage; import com.viaversion.viaversion.api.Via; @@ -479,7 +479,7 @@ public Item handleItemToClient(UserConnection connection, Item item) { continue; } TextUtils.setTranslator(component, s -> Protocol1_12_2To1_13.MAPPINGS.getMojangTranslation(). - getOrDefault(s, TranslatableRewriter.getTranslatableMappings("1.14").get(s))); + getOrDefault(s, TranslatableMappings.getTranslatableMappings("1.14").get(s))); loreEntry.setValue(component.asLegacyFormatString()); } } catch (final JsonParseException e) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_15to1_14_4/Protocol1_15To1_14_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_15to1_14_4/Protocol1_15To1_14_4.java index b81b430e..7bd4c73f 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_15to1_14_4/Protocol1_15To1_14_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_15to1_14_4/Protocol1_15To1_14_4.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_15to1_14_4.rewriter.BlockItemPacketRewriter1_15; import com.viaversion.viabackwards.protocol.v1_15to1_14_4.rewriter.EntityPacketRewriter1_15; import com.viaversion.viabackwards.protocol.v1_15to1_14_4.storage.ImmediateRespawnStorage; @@ -36,7 +36,7 @@ import com.viaversion.viaversion.protocols.v1_14_3to1_14_4.packet.ClientboundPackets1_14_4; import com.viaversion.viaversion.protocols.v1_14_4to1_15.Protocol1_14_4To1_15; import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -47,7 +47,7 @@ public class Protocol1_15To1_14_4 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_15To1_14_4() { @@ -62,7 +62,7 @@ protected void registerPackets() { translatableRewriter.registerComponentPacket(ClientboundPackets1_15.CHAT); translatableRewriter.registerPlayerCombat(ClientboundPackets1_15.PLAYER_COMBAT); translatableRewriter.registerComponentPacket(ClientboundPackets1_15.DISCONNECT); - translatableRewriter.registerOpenScreen(ClientboundPackets1_15.OPEN_SCREEN); + translatableRewriter.registerOpenScreen1_14(ClientboundPackets1_15.OPEN_SCREEN); translatableRewriter.registerTabList(ClientboundPackets1_15.TAB_LIST); translatableRewriter.registerTitle(ClientboundPackets1_15.SET_TITLES); translatableRewriter.registerPing(); @@ -137,7 +137,7 @@ public TagRewriter getTagRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java index 072c1892..e214ff20 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.BlockItemPacketRewriter1_16_2; import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.CommandRewriter1_16_2; import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.EntityPacketRewriter1_16_2; @@ -37,7 +37,7 @@ import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.Protocol1_16_1To1_16_2; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ClientboundPackets1_16_2; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPackets1_16_2; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -50,7 +50,7 @@ public class Protocol1_16_2To1_16_1 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_16_2To1_16_1() { @@ -66,7 +66,7 @@ protected void registerPackets() { translatableRewriter.registerComponentPacket(ClientboundPackets1_16_2.DISCONNECT); translatableRewriter.registerTabList(ClientboundPackets1_16_2.TAB_LIST); translatableRewriter.registerTitle(ClientboundPackets1_16_2.SET_TITLES); - translatableRewriter.registerOpenScreen(ClientboundPackets1_16_2.OPEN_SCREEN); + translatableRewriter.registerOpenScreen1_14(ClientboundPackets1_16_2.OPEN_SCREEN); translatableRewriter.registerPing(); particleRewriter.registerLevelParticles1_13(ClientboundPackets1_16_2.LEVEL_PARTICLES, Types.DOUBLE); @@ -131,7 +131,7 @@ public void init(UserConnection user) { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/rewriter/TranslatableRewriter1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/rewriter/TranslatableRewriter1_16.java index 9badd19d..5af014c9 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/rewriter/TranslatableRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/rewriter/TranslatableRewriter1_16.java @@ -17,7 +17,7 @@ */ package com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -27,7 +27,7 @@ import com.viaversion.viaversion.util.ComponentUtil; import com.viaversion.viaversion.util.SerializerVersion; -public class TranslatableRewriter1_16 extends TranslatableRewriter { +public class TranslatableRewriter1_16 extends JsonNBTComponentRewriter { private static final ChatColor[] COLORS = { new ChatColor("black", 0x000000), diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/Protocol1_17To1_16_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/Protocol1_17To1_16_4.java index 537be671..449f9fa0 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/Protocol1_17To1_16_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/Protocol1_17To1_16_4.java @@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_17to1_16_4.rewriter.BlockItemPacketRewriter1_17; import com.viaversion.viabackwards.protocol.v1_17to1_16_4.rewriter.EntityPacketRewriter1_17; import com.viaversion.viabackwards.protocol.v1_17to1_16_4.storage.PlayerLastCursorItem; @@ -40,7 +40,7 @@ import com.viaversion.viaversion.protocols.v1_16_4to1_17.Protocol1_16_4To1_17; import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ClientboundPackets1_17; import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ServerboundPackets1_17; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.rewriter.IdRewriteFunction; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; @@ -59,7 +59,7 @@ public final class Protocol1_17To1_16_4 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_17To1_16_4() { @@ -74,7 +74,7 @@ protected void registerPackets() { translatableRewriter.registerBossEvent(ClientboundPackets1_17.BOSS_EVENT); translatableRewriter.registerComponentPacket(ClientboundPackets1_17.DISCONNECT); translatableRewriter.registerTabList(ClientboundPackets1_17.TAB_LIST); - translatableRewriter.registerOpenScreen(ClientboundPackets1_17.OPEN_SCREEN); + translatableRewriter.registerOpenScreen1_14(ClientboundPackets1_17.OPEN_SCREEN); translatableRewriter.registerPing(); SoundRewriter soundRewriter = new SoundRewriter<>(this); @@ -229,7 +229,7 @@ public BackwardsMappingData getMappingData() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18to1_17_1/Protocol1_18To1_17_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18to1_17_1/Protocol1_18To1_17_1.java index 4e829af8..e01afd0b 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18to1_17_1/Protocol1_18To1_17_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18to1_17_1/Protocol1_18To1_17_1.java @@ -19,7 +19,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_18to1_17_1.data.BackwardsMappingData1_18; import com.viaversion.viabackwards.protocol.v1_18to1_17_1.rewriter.BlockItemPacketRewriter1_18; import com.viaversion.viabackwards.protocol.v1_18to1_17_1.rewriter.EntityPacketRewriter1_18; @@ -33,7 +33,7 @@ import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ServerboundPackets1_17; import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPackets1_18; import com.viaversion.viaversion.protocols.v1_17to1_17_1.packet.ClientboundPackets1_17_1; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -43,7 +43,7 @@ public final class Protocol1_18To1_17_1 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_18To1_17_1() { @@ -61,7 +61,7 @@ protected void registerPackets() { translatableRewriter.registerBossEvent(ClientboundPackets1_18.BOSS_EVENT); translatableRewriter.registerComponentPacket(ClientboundPackets1_18.DISCONNECT); translatableRewriter.registerTabList(ClientboundPackets1_18.TAB_LIST); - translatableRewriter.registerOpenScreen(ClientboundPackets1_18.OPEN_SCREEN); + translatableRewriter.registerOpenScreen1_14(ClientboundPackets1_18.OPEN_SCREEN); translatableRewriter.registerPlayerCombatKill(ClientboundPackets1_18.PLAYER_COMBAT_KILL); translatableRewriter.registerPing(); @@ -158,7 +158,7 @@ public ParticleRewriter getParticleRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_1to1_19/Protocol1_19_1To1_19.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_1to1_19/Protocol1_19_1To1_19.java index d6ba4e01..76124034 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_1to1_19/Protocol1_19_1To1_19.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_1to1_19/Protocol1_19_1To1_19.java @@ -17,9 +17,8 @@ */ package com.viaversion.viabackwards.protocol.v1_19_1to1_19; -import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.BackwardsProtocol; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_19_1to1_19.rewriter.EntityPacketRewriter1_19_1; import com.viaversion.viabackwards.protocol.v1_19_1to1_19.storage.ChatRegistryStorage; import com.viaversion.viabackwards.protocol.v1_19_1to1_19.storage.ChatRegistryStorage1_19_1; @@ -38,7 +37,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; -import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -53,7 +51,7 @@ import com.viaversion.viaversion.protocols.v1_19to1_19_1.packet.ClientboundPackets1_19_1; import com.viaversion.viaversion.protocols.v1_19to1_19_1.packet.ServerboundPackets1_19_1; import com.viaversion.viaversion.protocols.v1_18_2to1_19.Protocol1_18_2To1_19; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.util.CipherUtil; import com.viaversion.viaversion.util.ComponentUtil; import com.viaversion.viaversion.util.Pair; @@ -70,7 +68,7 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); public Protocol1_19_1To1_19() { super(ClientboundPackets1_19_1.class, ClientboundPackets1_19.class, ServerboundPackets1_19_1.class, ServerboundPackets1_19.class); @@ -84,7 +82,7 @@ protected void registerPackets() { translatableRewriter.registerBossEvent(ClientboundPackets1_19_1.BOSS_EVENT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_1.DISCONNECT); translatableRewriter.registerTabList(ClientboundPackets1_19_1.TAB_LIST); - translatableRewriter.registerOpenScreen(ClientboundPackets1_19_1.OPEN_SCREEN); + translatableRewriter.registerOpenScreen1_14(ClientboundPackets1_19_1.OPEN_SCREEN); translatableRewriter.registerPlayerCombatKill(ClientboundPackets1_19_1.PLAYER_COMBAT_KILL); translatableRewriter.registerPing(); @@ -395,7 +393,7 @@ public void init(final UserConnection user) { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_3to1_19_1/Protocol1_19_3To1_19_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_3to1_19_1/Protocol1_19_3To1_19_1.java index f2c7f4f8..e2466264 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_3to1_19_1/Protocol1_19_3To1_19_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_3to1_19_1/Protocol1_19_3To1_19_1.java @@ -20,7 +20,7 @@ import com.google.common.base.Preconditions; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_19_1to1_19.Protocol1_19_1To1_19; import com.viaversion.viabackwards.protocol.v1_19_3to1_19_1.data.BackwardsMappingData1_19_3; import com.viaversion.viabackwards.protocol.v1_19_3to1_19_1.rewriter.BlockItemPacketRewriter1_19_3; @@ -54,7 +54,7 @@ import com.viaversion.viaversion.protocols.v1_19to1_19_1.packet.ClientboundPackets1_19_1; import com.viaversion.viaversion.protocols.v1_19to1_19_1.packet.ServerboundPackets1_19_1; import com.viaversion.viaversion.rewriter.CommandRewriter; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -74,7 +74,7 @@ public final class Protocol1_19_3To1_19_1 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_19_3To1_19_1() { @@ -92,7 +92,7 @@ protected void registerPackets() { translatableRewriter.registerBossEvent(ClientboundPackets1_19_3.BOSS_EVENT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_3.DISCONNECT); translatableRewriter.registerTabList(ClientboundPackets1_19_3.TAB_LIST); - translatableRewriter.registerOpenScreen(ClientboundPackets1_19_3.OPEN_SCREEN); + translatableRewriter.registerOpenScreen1_14(ClientboundPackets1_19_3.OPEN_SCREEN); translatableRewriter.registerPlayerCombatKill(ClientboundPackets1_19_3.PLAYER_COMBAT_KILL); translatableRewriter.registerPing(); @@ -406,7 +406,7 @@ public BackwardsMappingData1_19_3 getMappingData() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_4to1_19_3/Protocol1_19_4To1_19_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_4to1_19_3/Protocol1_19_4To1_19_3.java index 7c7f057f..55878960 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_4to1_19_3/Protocol1_19_4To1_19_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_4to1_19_3/Protocol1_19_4To1_19_3.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_19_4to1_19_3.rewriter.BlockItemPacketRewriter1_19_4; import com.viaversion.viabackwards.protocol.v1_19_4to1_19_3.rewriter.EntityPacketRewriter1_19_4; import com.viaversion.viabackwards.protocol.v1_19_4to1_19_3.storage.EntityTracker1_19_4; @@ -34,7 +34,7 @@ import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ServerboundPackets1_19_4; import com.viaversion.viaversion.rewriter.CommandRewriter; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -47,7 +47,7 @@ public final class Protocol1_19_4To1_19_3 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_19_4To1_19_3() { @@ -137,7 +137,7 @@ public EntityPacketRewriter1_19_4 getEntityRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/Protocol1_19To1_18_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/Protocol1_19To1_18_2.java index 0931b03d..dab0c589 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/Protocol1_19To1_18_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/Protocol1_19To1_18_2.java @@ -21,7 +21,7 @@ import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_19_1to1_19.Protocol1_19_1To1_19; import com.viaversion.viabackwards.protocol.v1_19to1_18_2.data.BackwardsMappingData1_19; import com.viaversion.viabackwards.protocol.v1_19to1_18_2.rewriter.BlockItemPacketRewriter1_19; @@ -50,7 +50,7 @@ import com.viaversion.viaversion.protocols.v1_19to1_19_1.Protocol1_19To1_19_1; import com.viaversion.viaversion.protocols.v1_19to1_19_1.data.ChatDecorationResult; import com.viaversion.viaversion.rewriter.CommandRewriter; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -69,7 +69,7 @@ public final class Protocol1_19To1_18_2 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_19To1_18_2() { @@ -86,7 +86,7 @@ protected void registerPackets() { translatableRewriter.registerBossEvent(ClientboundPackets1_19.BOSS_EVENT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19.DISCONNECT); translatableRewriter.registerTabList(ClientboundPackets1_19.TAB_LIST); - translatableRewriter.registerOpenScreen(ClientboundPackets1_19.OPEN_SCREEN); + translatableRewriter.registerOpenScreen1_14(ClientboundPackets1_19.OPEN_SCREEN); translatableRewriter.registerPlayerCombatKill(ClientboundPackets1_19.PLAYER_COMBAT_KILL); translatableRewriter.registerPing(); @@ -372,7 +372,7 @@ public BackwardsMappingData1_19 getMappingData() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/Protocol1_20_3To1_20_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/Protocol1_20_3To1_20_2.java index c2c44b6a..6b044cda 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/Protocol1_20_3To1_20_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/Protocol1_20_3To1_20_2.java @@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.rewriter.BlockItemPacketRewriter1_20_3; import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.rewriter.EntityPacketRewriter1_20_3; import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.storage.ResourcepackIDStorage; @@ -50,10 +50,10 @@ import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundConfigurationPackets1_20_2; import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPacket1_20_2; import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2; -import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.util.ComponentUtil; import java.util.BitSet; import java.util.UUID; @@ -66,7 +66,7 @@ public final class Protocol1_20_3To1_20_2 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.NBT); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_20_3To1_20_2() { @@ -405,7 +405,7 @@ public EntityPacketRewriter1_20_3 getEntityRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/Protocol1_20_5To1_20_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/Protocol1_20_5To1_20_3.java index 90d15847..d5307b2a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/Protocol1_20_5To1_20_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/Protocol1_20_5To1_20_3.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.provider.TransferProvider; import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.rewriter.BlockItemPacketRewriter1_20_5; import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.rewriter.EntityPacketRewriter1_20_5; @@ -57,10 +57,10 @@ import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.storage.ArmorTrimStorage; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.storage.BannerPatternStorage; import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundConfigurationPackets1_20_2; -import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap; @@ -70,7 +70,7 @@ public final class Protocol1_20_5To1_20_3 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.NBT); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_20_5To1_20_3() { @@ -255,7 +255,7 @@ public ParticleRewriter getParticleRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/Protocol1_20To1_19_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/Protocol1_20To1_19_4.java index d210216b..1dde4775 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/Protocol1_20To1_19_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/Protocol1_20To1_19_4.java @@ -19,7 +19,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_20to1_19_4.data.BackwardsMappingData1_20; import com.viaversion.viabackwards.protocol.v1_20to1_19_4.rewriter.BlockItemPacketRewriter1_20; import com.viaversion.viabackwards.protocol.v1_20to1_19_4.rewriter.EntityPacketRewriter1_20; @@ -30,7 +30,7 @@ import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ServerboundPackets1_19_4; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -39,7 +39,7 @@ public final class Protocol1_20To1_19_4 extends BackwardsProtocol { public static final BackwardsMappingData1_20 MAPPINGS = new BackwardsMappingData1_20(); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + private final JsonNBTComponentRewriter translatableRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); private final EntityPacketRewriter1_20 entityRewriter = new EntityPacketRewriter1_20(this); private final BlockItemPacketRewriter1_20 itemRewriter = new BlockItemPacketRewriter1_20(this); private final ParticleRewriter particleRewriter = new ParticleRewriter<>(this); @@ -117,7 +117,7 @@ public ParticleRewriter getParticleRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java index d55b43eb..3851afc3 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/Protocol1_21_2To1_21.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_21_2to1_21.rewriter.BlockItemPacketRewriter1_21_2; import com.viaversion.viabackwards.protocol.v1_21_2to1_21.rewriter.ComponentRewriter1_21_2; import com.viaversion.viabackwards.protocol.v1_21_2to1_21.rewriter.EntityPacketRewriter1_21_2; @@ -62,7 +62,7 @@ public final class Protocol1_21_2To1_21 extends BackwardsProtocol translatableRewriter = new ComponentRewriter1_21_2(this); + private final JsonNBTComponentRewriter translatableRewriter = new ComponentRewriter1_21_2(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_21_2To1_21() { @@ -185,7 +185,7 @@ public ParticleRewriter1_21_2 getParticleRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/ComponentRewriter1_21_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/ComponentRewriter1_21_2.java index 8a5bd843..eeb061a6 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/ComponentRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/ComponentRewriter1_21_2.java @@ -18,14 +18,14 @@ package com.viaversion.viabackwards.protocol.v1_21_2to1_21.rewriter; import com.viaversion.nbt.tag.CompoundTag; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_21_2to1_21.Protocol1_21_2To1_21; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2; import com.viaversion.viaversion.util.SerializerVersion; import com.viaversion.viaversion.util.TagUtil; -public final class ComponentRewriter1_21_2 extends TranslatableRewriter { +public final class ComponentRewriter1_21_2 extends JsonNBTComponentRewriter { public ComponentRewriter1_21_2(final Protocol1_21_2To1_21 protocol) { super(protocol, ReadType.NBT); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_4to1_21_2/Protocol1_21_4To1_21_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_4to1_21_2/Protocol1_21_4To1_21_2.java index 13681dff..c68dab8f 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_4to1_21_2/Protocol1_21_4To1_21_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_4to1_21_2/Protocol1_21_4To1_21_2.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.BlockItemPacketRewriter1_21_4; import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.ComponentRewriter1_21_4; import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.rewriter.EntityPacketRewriter1_21_4; @@ -59,7 +59,7 @@ public final class Protocol1_21_4To1_21_2 extends BackwardsProtocol particleRewriter = new ParticleRewriter1_21_4(this); - private final TranslatableRewriter translatableRewriter = new ComponentRewriter1_21_4(this); + private final JsonNBTComponentRewriter translatableRewriter = new ComponentRewriter1_21_4(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_21_4To1_21_2() { @@ -81,7 +81,7 @@ protected void registerPackets() { new StatisticsRewriter<>(this).register(ClientboundPackets1_21_2.AWARD_STATS); new AttributeRewriter<>(this).register1_21(ClientboundPackets1_21_2.UPDATE_ATTRIBUTES); - translatableRewriter.registerOpenScreen(ClientboundPackets1_21_2.OPEN_SCREEN); + translatableRewriter.registerOpenScreen1_14(ClientboundPackets1_21_2.OPEN_SCREEN); translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_ACTION_BAR_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_SUBTITLE_TEXT); @@ -199,7 +199,7 @@ public ParticleRewriter getParticleRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_4to1_21_2/rewriter/ComponentRewriter1_21_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_4to1_21_2/rewriter/ComponentRewriter1_21_4.java index 17f960dc..d676e799 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_4to1_21_2/rewriter/ComponentRewriter1_21_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_4to1_21_2/rewriter/ComponentRewriter1_21_4.java @@ -19,13 +19,13 @@ import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viabackwards.api.BackwardsProtocol; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2; import com.viaversion.viaversion.util.SerializerVersion; import com.viaversion.viaversion.util.TagUtil; -public final class ComponentRewriter1_21_4 extends TranslatableRewriter { +public final class ComponentRewriter1_21_4 extends JsonNBTComponentRewriter { public ComponentRewriter1_21_4(final BackwardsProtocol protocol) { super(protocol, ReadType.NBT); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java index ba6e0055..d3aae476 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java @@ -20,7 +20,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter.BlockItemPacketRewriter1_21; import com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter.ComponentRewriter1_21; import com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter.EntityPacketRewriter1_21; @@ -60,7 +60,7 @@ public final class Protocol1_21To1_20_5 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this, Types1_21.PARTICLE, Types1_20_5.PARTICLE); - private final TranslatableRewriter translatableRewriter = new ComponentRewriter1_21(this); + private final JsonNBTComponentRewriter translatableRewriter = new ComponentRewriter1_21(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_21To1_20_5() { @@ -219,7 +219,7 @@ public ParticleRewriter getParticleRewriter() { } @Override - public TranslatableRewriter getComponentRewriter() { + public JsonNBTComponentRewriter getComponentRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/ComponentRewriter1_21.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/ComponentRewriter1_21.java index 5225d88b..49dc1d4c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/ComponentRewriter1_21.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/ComponentRewriter1_21.java @@ -20,7 +20,7 @@ import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.IntArrayTag; import com.viaversion.nbt.tag.ListTag; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_21to1_20_5.Protocol1_21To1_20_5; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.Attributes1_20_5; @@ -33,7 +33,7 @@ import com.viaversion.viaversion.util.UUIDUtil; import java.util.UUID; -public final class ComponentRewriter1_21 extends TranslatableRewriter { +public final class ComponentRewriter1_21 extends JsonNBTComponentRewriter { public ComponentRewriter1_21(final Protocol1_21To1_20_5 protocol) { super(protocol, ReadType.NBT); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_9_1to1_9/Protocol1_9_1To1_9.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_9_1to1_9/Protocol1_9_1To1_9.java index d61de19f..d3b9bc87 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_9_1to1_9/Protocol1_9_1To1_9.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_9_1to1_9/Protocol1_9_1To1_9.java @@ -18,15 +18,12 @@ package com.viaversion.viabackwards.protocol.v1_9_1to1_9; import com.viaversion.viabackwards.api.BackwardsProtocol; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; -import com.viaversion.viaversion.api.protocol.AbstractProtocol; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; -import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ServerboundPackets1_9; -import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; public class Protocol1_9_1To1_9 extends BackwardsProtocol { @@ -66,7 +63,7 @@ else if (sound >= 416) // Act like the Elytra sound never existed } }); - TranslatableRewriter componentRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + JsonNBTComponentRewriter componentRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); componentRewriter.registerComponentPacket(ClientboundPackets1_9.CHAT); } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_9_3to1_9_1/Protocol1_9_3To1_9_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_9_3to1_9_1/Protocol1_9_3To1_9_1.java index e90ab61e..6a5648e8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_9_3to1_9_1/Protocol1_9_3To1_9_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_9_3to1_9_1/Protocol1_9_3To1_9_1.java @@ -18,7 +18,7 @@ package com.viaversion.viabackwards.protocol.v1_9_3to1_9_1; import com.viaversion.viabackwards.api.BackwardsProtocol; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; +import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter; import com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.data.BlockEntity1_9_1; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.ClientWorld; @@ -34,7 +34,7 @@ import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ServerboundPackets1_9; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase; public class Protocol1_9_3To1_9_1 extends BackwardsProtocol { @@ -111,7 +111,7 @@ public void register() { } }); - TranslatableRewriter componentRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); + JsonNBTComponentRewriter componentRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON); componentRewriter.registerComponentPacket(ClientboundPackets1_9_3.CHAT); }