Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 16:40:10 +01:00
Handle show_entity type field
Dieser Commit ist enthalten in:
Ursprung
57b37457d6
Commit
7825a1e460
@ -160,12 +160,11 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
|
||||
@Override
|
||||
protected void handleHoverEvent(final CompoundTag hoverEventTag) {
|
||||
final StringTag actionTag = hoverEventTag.getStringTag("action");
|
||||
if (actionTag == null || !actionTag.getValue().equals("show_item")) {
|
||||
return;
|
||||
}
|
||||
if (actionTag == null) return;
|
||||
|
||||
if (actionTag.getValue().equals("show_item")) {
|
||||
final Tag valueTag = hoverEventTag.remove("value");
|
||||
if (valueTag != null) { // Convert legacy hover event to new format for rewriting
|
||||
if (valueTag != null) { // Convert legacy hover event to new format for rewriting (Doesn't handle all cases, but good enough)
|
||||
final CompoundTag tag = ComponentUtil.deserializeShowItem(valueTag, SerializerVersion.V1_20_3);
|
||||
final CompoundTag contentsTag = new CompoundTag();
|
||||
contentsTag.put("id", tag.getStringTag("id"));
|
||||
@ -235,6 +234,26 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
|
||||
}
|
||||
contentsTag.put("components", components);
|
||||
}
|
||||
} else if (actionTag.getValue().equals("show_entity")) {
|
||||
final Tag valueTag = hoverEventTag.remove("value");
|
||||
if (valueTag != null) { // Convert legacy hover event to new format for rewriting (Doesn't handle all cases, but good enough)
|
||||
final CompoundTag tag = ComponentUtil.deserializeShowItem(valueTag, SerializerVersion.V1_20_3);
|
||||
final CompoundTag contentsTag = new CompoundTag();
|
||||
contentsTag.put("type", tag.getStringTag("type"));
|
||||
contentsTag.put("id", tag.getStringTag("id"));
|
||||
contentsTag.put("name", SerializerVersion.V1_20_3.toTag(SerializerVersion.V1_20_3.toComponent(tag.getString("name"))));
|
||||
hoverEventTag.put("contents", contentsTag);
|
||||
}
|
||||
|
||||
final CompoundTag contentsTag = hoverEventTag.getCompoundTag("contents");
|
||||
if (contentsTag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.protocol.getMappingData().getEntityMappings().mappedId(contentsTag.getString("type")) == -1) {
|
||||
contentsTag.put("type", new StringTag("pig"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected CompoundTag toTag(final Map<StructuredDataKey<?>, StructuredData<?>> data, final boolean empty) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren