mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Update EmotePacket creation for 1.20 (#3841)
Include xuid and platformId in EmotePacket
This commit is contained in:
parent
ab577f66ac
commit
53d002656f
2 changed files with 26 additions and 7 deletions
|
@ -1949,8 +1949,10 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||
}
|
||||
|
||||
EmotePacket packet = new EmotePacket();
|
||||
packet.setEmoteId(emoteId);
|
||||
packet.setRuntimeEntityId(entity.getGeyserId());
|
||||
packet.setXuid("");
|
||||
packet.setPlatformId(""); // BDS sends empty
|
||||
packet.setEmoteId(emoteId);
|
||||
sendUpstreamPacket(packet);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,21 +56,38 @@ public class BedrockEmoteTranslator extends PacketTranslator<EmotePacket> {
|
|||
}
|
||||
|
||||
int javaId = session.getPlayerEntity().getEntityId();
|
||||
String xuid = session.getAuthData().xuid();
|
||||
String emote = packet.getEmoteId();
|
||||
for (GeyserSession otherSession : session.getGeyser().getSessionManager().getSessions().values()) {
|
||||
if (otherSession != session) {
|
||||
if (otherSession.isClosed()) continue;
|
||||
if (otherSession.getEventLoop().inEventLoop()) {
|
||||
playEmote(otherSession, javaId, packet.getEmoteId());
|
||||
playEmote(otherSession, javaId, xuid, emote);
|
||||
} else {
|
||||
otherSession.executeInEventLoop(() -> playEmote(otherSession, javaId, packet.getEmoteId()));
|
||||
otherSession.executeInEventLoop(() -> playEmote(otherSession, javaId, xuid, emote));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void playEmote(GeyserSession otherSession, int javaId, String emoteId) {
|
||||
Entity otherEntity = otherSession.getEntityCache().getEntityByJavaId(javaId); // Must be ran on same thread
|
||||
if (!(otherEntity instanceof PlayerEntity otherPlayer)) return;
|
||||
otherSession.showEmote(otherPlayer, emoteId);
|
||||
/**
|
||||
* Play an emote by an emoter to the given session.
|
||||
* This method must be called within the session's event loop.
|
||||
*
|
||||
* @param session the session to show the emote to
|
||||
* @param emoterJavaId the java id of the emoter
|
||||
* @param emoterXuid the xuid of the emoter
|
||||
* @param emoteId the emote to play
|
||||
*/
|
||||
private static void playEmote(GeyserSession session, int emoterJavaId, String emoterXuid, String emoteId) {
|
||||
Entity emoter = session.getEntityCache().getEntityByJavaId(emoterJavaId); // Must be ran on same thread
|
||||
if (emoter instanceof PlayerEntity) {
|
||||
EmotePacket packet = new EmotePacket();
|
||||
packet.setRuntimeEntityId(emoter.getGeyserId());
|
||||
packet.setXuid(emoterXuid);
|
||||
packet.setPlatformId(""); // BDS sends empty
|
||||
packet.setEmoteId(emoteId);
|
||||
session.sendUpstreamPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue