3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-11-17 13:30:14 +01:00

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
Dieser Commit ist enthalten in:
Nassim Jahnke 2023-03-20 10:05:46 +01:00
Ursprung 614207aeef
Commit 0d4257f228
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
5 geänderte Dateien mit 25 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -63,7 +63,9 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
if (lore != null) {
boolean changed = false;
for (Tag loreEntryTag : lore) {
if (!(loreEntryTag instanceof StringTag)) continue;
if (!(loreEntryTag instanceof StringTag)) {
continue;
}
StringTag loreEntry = (StringTag) loreEntryTag;
String newValue = protocol.getTranslatableRewriter().processText(loreEntry.getValue()).toString();

Datei anzeigen

@ -142,8 +142,8 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
return blockItemPackets;
}
@Override
public TranslatableRewriter<ClientboundPackets1_13> getTranslatableRewriter() {
// Don't override the parent method
public TranslatableRewriter<ClientboundPackets1_13> translatableRewriter() {
return translatableRewriter;
}

Datei anzeigen

@ -279,7 +279,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
int typeId = meta.metaType().typeId();
if (typeId == 4) {
JsonElement element = meta.value();
protocol.getTranslatableRewriter().processText(element);
protocol.translatableRewriter().processText(element);
meta.setMetaType(MetaType1_12.Chat);
} else if (typeId == 5) {
// Rewrite optional chat to string

Datei anzeigen

@ -228,8 +228,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
return itemRewriter;
}
@Override
public TranslatableRewriter<ClientboundPackets1_13> getTranslatableRewriter() {
public TranslatableRewriter<ClientboundPackets1_13> translatableRewriter() {
return translatableRewriter;
}
}

Datei anzeigen

@ -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<ClientboundPackets
@Override
protected void registerRewrites() {
registerMetaTypeHandler(Types1_13.META_TYPES.itemType, Types1_13.META_TYPES.blockStateType, Types1_13.META_TYPES.particleType,
Types1_13.META_TYPES.optionalComponentType, Types1_13.META_TYPES.componentType);
// Rewrite items & blocks
filter().handler((event, meta) -> {
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);