mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Translates nametags for bedrock edition
This commit is contained in:
parent
c556fa94ea
commit
3afa54527d
2 changed files with 16 additions and 1 deletions
|
|
@ -141,7 +141,6 @@ public class Entity {
|
|||
flags.setFlag(EntityFlag.NO_AI, false);
|
||||
|
||||
EntityDataDictionary dictionary = new EntityDataDictionary();
|
||||
dictionary.put(EntityData.NAMETAG, "");
|
||||
dictionary.put(EntityData.ENTITY_AGE, 0);
|
||||
dictionary.put(EntityData.SCALE, 1f);
|
||||
dictionary.put(EntityData.MAX_AIR, (short) 400);
|
||||
|
|
|
|||
|
|
@ -25,11 +25,16 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityMetadataPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.utils.MessageUtils;
|
||||
|
||||
public class JavaEntityMetadataTranslator extends PacketTranslator<ServerEntityMetadataPacket> {
|
||||
|
||||
|
|
@ -48,6 +53,17 @@ public class JavaEntityMetadataTranslator extends PacketTranslator<ServerEntityM
|
|||
entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
entityDataPacket.getMetadata().putAll(entity.getMetadata());
|
||||
|
||||
//Translate Java nametag to Bedrock
|
||||
for(EntityMetadata meta : packet.getMetadata()) {
|
||||
switch(meta.getType()) {
|
||||
case OPTIONAL_CHAT:
|
||||
if(meta.getValue() != null) {
|
||||
Message nametag = (Message) meta.getValue();
|
||||
entityDataPacket.getMetadata().put(EntityData.NAMETAG, MessageUtils.getBedrockMessage(nametag));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
session.getUpstream().sendPacket(entityDataPacket);
|
||||
} else {
|
||||
entity.spawnEntity(session);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue