Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-19 14:30:16 +01:00
Serialize to 1.20.3 components in conversion
Aside from hover events, only reading of components changed and we need the 1.20.3 hover input. Hover events are already handled by us.
Dieser Commit ist enthalten in:
Ursprung
34bc5b9d36
Commit
71ab15b331
@ -99,6 +99,7 @@ import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.Either;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.SerializerVersion;
|
||||
import com.viaversion.viaversion.util.UUIDUtil;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
@ -1111,7 +1112,8 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
}
|
||||
|
||||
private Tag jsonToTag(final UserConnection connection, final StringTag stringTag) {
|
||||
final Tag tag = ComponentUtil.jsonStringToTag(stringTag.getValue());
|
||||
// Use the same version for deserializing and serializing, as the only write changes are in hovers, which we handle ourselves
|
||||
final Tag tag = ComponentUtil.jsonStringToTag(stringTag.getValue(), SerializerVersion.V1_20_3, SerializerVersion.V1_20_3);
|
||||
protocol.getComponentRewriter().processTag(connection, tag);
|
||||
return tag;
|
||||
}
|
||||
|
@ -102,14 +102,14 @@ public final class ComponentUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable Tag jsonStringToTag(@Nullable final String json) {
|
||||
public static @Nullable Tag jsonStringToTag(@Nullable final String json, final SerializerVersion from, final SerializerVersion to) {
|
||||
if (json == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
final ATextComponent component = TextComponentSerializer.V1_20_3.deserialize(json);
|
||||
return SerializerVersion.V1_20_5.toTag(component);
|
||||
final ATextComponent component = from.jsonSerializer.deserialize(json);
|
||||
return to.toTag(component);
|
||||
} catch (final Exception e) {
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting component: " + json, e);
|
||||
return new StringTag("<error>");
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren