From 0d4257f2285c8940afc8742199d284046f6348f5 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 20 Mar 2023 10:05:46 +0100 Subject: [PATCH] Don't override getTranslatableRewriter in 1.13->1.12, 1.14->1.13 protocols The method is used in item handling and would otherwise mess up the lore --- .../api/rewriters/ItemRewriter.java | 4 +++- .../Protocol1_12_2To1_13.java | 4 ++-- .../packets/EntityPackets1_13.java | 2 +- .../Protocol1_13To1_13_1.java | 3 +-- .../packets/EntityPackets1_13_1.java | 20 +++++++++++++++++-- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java index 3b283af8..9740ead2 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java @@ -63,7 +63,9 @@ public class ItemRewriter getTranslatableRewriter() { + // Don't override the parent method + public TranslatableRewriter translatableRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java index d575f9e5..c0cf467e 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java @@ -279,7 +279,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter getTranslatableRewriter() { + public TranslatableRewriter translatableRewriter() { return translatableRewriter; } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java index cce84361..8c4d79cb 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java @@ -22,10 +22,13 @@ import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter; import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1; import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; import com.viaversion.viaversion.api.minecraft.entities.EntityType; +import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.Particle; import com.viaversion.viaversion.api.type.types.version.Types1_13; +import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import java.util.List; @@ -127,8 +130,21 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter { + if (meta.metaType() == Types1_13.META_TYPES.itemType) { + protocol.getItemRewriter().handleItemToClient((Item) meta.getValue()); + } else if (meta.metaType() == Types1_13.META_TYPES.blockStateType) { + // Convert to new block id + int data = (int) meta.getValue(); + meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); + } else if (meta.metaType() == Types1_13.META_TYPES.particleType) { + rewriteParticle((Particle) meta.getValue()); + } else if (meta.metaType() == Types1_13.META_TYPES.optionalComponentType || meta.metaType() == Types1_13.META_TYPES.componentType) { + JsonElement element = meta.value(); + protocol.translatableRewriter().processText(element); + } + }); // Remove shooter UUID filter().filterFamily(Entity1_13Types.EntityType.ABSTRACT_ARROW).cancel(7);