Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 08:10:11 +01:00
Update EmotePacket creation for 1.20 (#3841)
Include xuid and platformId in EmotePacket
Dieser Commit ist enthalten in:
Ursprung
ab577f66ac
Commit
53d002656f
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren