3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 00:23:03 +01:00

Check for instance of TranslationMessage (#722)

Checks for class of custom name ID in case it's translation message.
Dieser Commit ist enthalten in:
Camotoy 2020-06-02 10:45:33 -04:00 committet von GitHub
Ursprung 05024dde8c
Commit 18891a22f1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -34,6 +34,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace; import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.github.steveice10.mc.protocol.data.message.TextMessage; import com.github.steveice10.mc.protocol.data.message.TextMessage;
import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
@ -253,9 +254,15 @@ public class Entity {
} }
break; break;
case 2: // custom name case 2: // custom name
if (entityMetadata.getValue() instanceof TextMessage) {
TextMessage name = (TextMessage) entityMetadata.getValue(); TextMessage name = (TextMessage) entityMetadata.getValue();
if (name != null) if (name != null)
metadata.put(EntityData.NAMETAG, MessageUtils.getBedrockMessage(name)); metadata.put(EntityData.NAMETAG, MessageUtils.getBedrockMessage(name));
} else if (entityMetadata.getValue() instanceof TranslationMessage) {
TranslationMessage message = (TranslationMessage) entityMetadata.getValue();
if (message != null)
metadata.put(EntityData.NAMETAG, MessageUtils.getTranslatedBedrockMessage(message, session.getClientData().getLanguageCode(), true));
}
break; break;
case 3: // is custom name visible case 3: // is custom name visible
if (!this.is(PlayerEntity.class)) if (!this.is(PlayerEntity.class))