diff --git a/api/src/main/java/com/viaversion/viaversion/api/rewriter/EntityRewriter.java b/api/src/main/java/com/viaversion/viaversion/api/rewriter/EntityRewriter.java index d0d6e9696..136f2cf74 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/rewriter/EntityRewriter.java +++ b/api/src/main/java/com/viaversion/viaversion/api/rewriter/EntityRewriter.java @@ -58,6 +58,14 @@ public interface EntityRewriter> extends Rewriter */ int newEntityId(int id); + /** + * Returns the mapped entity (or the same if it has not changed). + * + * @param identifier unmapped entity identifier + * @return mapped entity identifier + */ + String mappedEntityIdentifier(String identifier); + /** * Handles and transforms entity data of an entity. * diff --git a/api/src/main/java/com/viaversion/viaversion/api/rewriter/ItemRewriter.java b/api/src/main/java/com/viaversion/viaversion/api/rewriter/ItemRewriter.java index c92b699fa..a70929627 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/rewriter/ItemRewriter.java +++ b/api/src/main/java/com/viaversion/viaversion/api/rewriter/ItemRewriter.java @@ -51,7 +51,8 @@ public interface ItemRewriter> extends Rewriter implements com.v final CompoundTag contents = hoverEventTag.getCompoundTag("contents"); if (contents != null) { processTag(connection, contents.get("name")); + + final StringTag typeTag = contents.getStringTag("type"); + if (typeTag != null && protocol.getEntityRewriter() != null) { + typeTag.setValue(protocol.getEntityRewriter().mappedEntityIdentifier(typeTag.getValue())); + } } } else if (action.equals("show_item")) { convertLegacyContents(hoverEventTag); diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java index 89ae537fd..63f0f456b 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java @@ -24,6 +24,7 @@ import com.viaversion.nbt.tag.NumberTag; import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.data.FullMappings; import com.viaversion.viaversion.api.data.Int2IntMapMappings; import com.viaversion.viaversion.api.data.Mappings; import com.viaversion.viaversion.api.data.ParticleMappings; @@ -60,7 +61,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; public abstract class EntityRewriter> extends RewriterBase implements com.viaversion.viaversion.api.rewriter.EntityRewriter { - private static final EntityData[] EMPTY_ARRAY = new EntityData[0]; protected final List entityDataFilters = new ArrayList<>(); protected final boolean trackMappedType; protected Mappings typeMappings; @@ -156,6 +156,17 @@ public abstract class EntityRewriter