From dd6bc4f1db0e17af35545e98baddc8a77860cbf0 Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Fri, 5 Jul 2024 16:09:43 +0200 Subject: [PATCH] Handle translatables in lore tag conversion in 1.14->1.13.2 (#810) --- .../viabackwards/api/rewriters/TranslatableRewriter.java | 2 +- .../v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java index 9e94723d..a6f85112 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java @@ -87,7 +87,7 @@ public class TranslatableRewriter extends Compo return translatables.get(translationKey); } - public Map getTranslatableMappings(final String sectionIdentifier) { + public static Map getTranslatableMappings(final String sectionIdentifier) { return TRANSLATABLES.get(sectionIdentifier); } } 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 ebd21777..287e929a 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 @@ -20,6 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter; import com.google.common.collect.ImmutableSet; 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; @@ -48,6 +49,8 @@ import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.nbt.tag.ListTag; import com.viaversion.nbt.tag.StringTag; import com.viaversion.viaversion.libs.gson.JsonParseException; +import com.viaversion.viaversion.libs.mcstructs.text.utils.TextUtils; +import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; 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_13_2to1_14.Protocol1_13_2To1_14; @@ -477,6 +480,8 @@ public class BlockItemPacketRewriter1_14 extends BackwardsItemRewriter Protocol1_12_2To1_13.MAPPINGS.getMojangTranslation(). + getOrDefault(s, TranslatableRewriter.getTranslatableMappings("1.14").get(s))); loreEntry.setValue(component.asLegacyFormatString()); } } catch (final JsonParseException e) {