mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-22 16:38:20 +01:00
parent
9bc943ea67
commit
7be7139241
@ -58,6 +58,14 @@ public interface EntityRewriter<T extends Protocol<?, ?, ?, ?>> 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.
|
||||
*
|
||||
|
@ -51,7 +51,8 @@ public interface ItemRewriter<T extends Protocol<?, ?, ?, ?>> extends Rewriter<T
|
||||
@Nullable
|
||||
Item handleItemToServer(UserConnection connection, @Nullable Item item);
|
||||
|
||||
void rewriteParticle(UserConnection connection, Particle particle);
|
||||
default void rewriteParticle(UserConnection connection, Particle particle) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item type of the current protocol.
|
||||
|
@ -390,6 +390,11 @@ public class ComponentRewriter<C extends ClientboundPacketType> 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);
|
||||
|
@ -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<C extends ClientboundPacketType, T extends Protocol<C, ?, ?, ?>>
|
||||
extends RewriterBase<T> implements com.viaversion.viaversion.api.rewriter.EntityRewriter<T> {
|
||||
private static final EntityData[] EMPTY_ARRAY = new EntityData[0];
|
||||
protected final List<EntityDataFilter> entityDataFilters = new ArrayList<>();
|
||||
protected final boolean trackMappedType;
|
||||
protected Mappings typeMappings;
|
||||
@ -156,6 +156,17 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
||||
return typeMappings != null ? typeMappings.getNewIdOrDefault(id, id) : id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mappedEntityIdentifier(final String identifier) {
|
||||
if (typeMappings instanceof final FullMappings fullMappings) {
|
||||
final String mappedIdentifier = fullMappings.mappedIdentifier(identifier);
|
||||
if (mappedIdentifier != null) {
|
||||
return mappedIdentifier;
|
||||
}
|
||||
}
|
||||
return identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps an entity type.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user