3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-27 08:30:10 +01:00

fix display name

Dieser Commit ist enthalten in:
Gerrygames 2019-05-21 21:50:57 +02:00
Ursprung 96b05bcd4f
Commit dd454d56f3
2 geänderte Dateien mit 12 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -30,6 +30,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
import us.myles.ViaVersion.exception.CancelException; import us.myles.ViaVersion.exception.CancelException;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -51,6 +52,9 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
@Getter(AccessLevel.PROTECTED) @Getter(AccessLevel.PROTECTED)
@Setter(AccessLevel.PROTECTED) @Setter(AccessLevel.PROTECTED)
private int displayNameIndex = 2; private int displayNameIndex = 2;
@Getter(AccessLevel.PROTECTED)
@Setter(AccessLevel.PROTECTED)
private boolean isDisplayNameJson = false;
protected AbstractEntityType getEntityType(UserConnection connection, int id) { protected AbstractEntityType getEntityType(UserConnection connection, int id) {
return getEntityTracker(connection).getEntityType(id); return getEntityTracker(connection).getEntityType(id);
@ -149,7 +153,11 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
if (entData.getMobName() != null && if (entData.getMobName() != null &&
(data.getValue() == null || ((String) data.getValue()).isEmpty()) && (data.getValue() == null || ((String) data.getValue()).isEmpty()) &&
data.getMetaType().getTypeID() == getDisplayNameMetaType().getTypeID()) { data.getMetaType().getTypeID() == getDisplayNameMetaType().getTypeID()) {
data.setValue(entData.getMobName()); String mobName = entData.getMobName();
if (isDisplayNameJson) {
mobName = ChatRewriter.legacyTextToJson(mobName);
}
data.setValue(mobName);
} }
} }

Datei anzeigen

@ -288,6 +288,9 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
setDisplayNameJson(true);
setDisplayNameMetaType(MetaType1_13_2.OptChat);
regEntType(EntityType1_14.EntityType.CAT, EntityType1_14.EntityType.OCELOT).mobName("Cat").spawnMetadata(e -> { regEntType(EntityType1_14.EntityType.CAT, EntityType1_14.EntityType.OCELOT).mobName("Cat").spawnMetadata(e -> {
// e.add(new Metadata(13, MetaType1_13_2.Byte, (byte) 0x4)); // Tamed cat // e.add(new Metadata(13, MetaType1_13_2.Byte, (byte) 0x4)); // Tamed cat
}); });