Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-20 06:50:10 +01:00
Handle translatables in 1.13.1 entity display names
Dieser Commit ist enthalten in:
Ursprung
a07550363e
Commit
68e578a04e
@ -175,17 +175,32 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
}
|
||||
}
|
||||
|
||||
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockType, @Nullable MetaType particleType, @Nullable MetaType optionalComponentType) {
|
||||
public void registerMetaTypeHandler(
|
||||
@Nullable MetaType itemType,
|
||||
@Nullable MetaType blockType,
|
||||
@Nullable MetaType particleType,
|
||||
@Nullable MetaType optionalComponentType
|
||||
) {
|
||||
this.registerMetaTypeHandler(itemType, blockType, particleType, optionalComponentType, null);
|
||||
}
|
||||
|
||||
public void registerMetaTypeHandler(
|
||||
@Nullable MetaType itemType,
|
||||
@Nullable MetaType blockType,
|
||||
@Nullable MetaType particleType,
|
||||
@Nullable MetaType optionalComponentType,
|
||||
@Nullable MetaType componentType
|
||||
) {
|
||||
filter().handler((event, meta) -> {
|
||||
MetaType type = meta.metaType();
|
||||
if (itemType != null && type == itemType) {
|
||||
if (type == itemType) {
|
||||
protocol.getItemRewriter().handleItemToClient(meta.value());
|
||||
} else if (blockType != null && type == blockType) {
|
||||
} else if (type == blockType) {
|
||||
int data = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (particleType != null && type == particleType) {
|
||||
} else if (type == particleType) {
|
||||
rewriteParticle(meta.value());
|
||||
} else if (optionalComponentType != null && type == optionalComponentType) {
|
||||
} else if (type == optionalComponentType || type == componentType) {
|
||||
JsonElement text = meta.value();
|
||||
if (text != null) {
|
||||
protocol.getTranslatableRewriter().processText(text);
|
||||
|
@ -49,6 +49,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.13.2", "1.13", Protocol1_13_1To1_13.class);
|
||||
private final EntityPackets1_13_1 entityRewriter = new EntityPackets1_13_1(this);
|
||||
private final InventoryPackets1_13_1 itemRewriter = new InventoryPackets1_13_1(this);
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this);
|
||||
|
||||
public Protocol1_13To1_13_1() {
|
||||
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
|
||||
@ -60,7 +61,6 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
WorldPackets1_13_1.register(this);
|
||||
|
||||
TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this);
|
||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT);
|
||||
@ -227,4 +227,9 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public InventoryPackets1_13_1 getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableRewriter<ClientboundPackets1_13> getTranslatableRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ 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;
|
||||
|
||||
@ -139,6 +140,9 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
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) {
|
||||
JsonElement element = meta.value();
|
||||
protocol.getTranslatableRewriter().processText(element);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_3;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_4;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
@ -161,6 +162,9 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
|
||||
event.setIndex(2);
|
||||
meta.setMetaType(Types1_19_3.META_TYPES.optionalComponentType);
|
||||
event.createExtraMeta(new Metadata(3, Types1_19_3.META_TYPES.booleanType, true)); // Show custom name
|
||||
|
||||
final JsonElement element = meta.value();
|
||||
protocol.getTranslatableRewriter().processText(element);
|
||||
}));
|
||||
filter().filterFamily(Entity1_19_4Types.DISPLAY).handler((event, meta) -> {
|
||||
// TODO Maybe spawn an extra entity to ride the armor stand for blocks and items
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren