Skip to content

Commit

Permalink
send system chat overlay and actionbar as jukebox_popup messages (#3941)
Browse files Browse the repository at this point in the history
* send actionbar and systemchat overlay messages as jukebox text to avoid clashes with armor/air UI

* add explaining comment
  • Loading branch information
onebeastchris authored Jul 29, 2023
1 parent 3949fb1 commit d147ee3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void translate(GeyserSession session, ClientboundSystemChatPacket packet)
textPacket.setPlatformChatId("");
textPacket.setSourceName("");
textPacket.setXuid(session.getAuthData().xuid());
textPacket.setType(packet.isOverlay() ? TextPacket.Type.TIP : TextPacket.Type.SYSTEM);
textPacket.setType(packet.isOverlay() ? TextPacket.Type.JUKEBOX_POPUP : TextPacket.Type.SYSTEM);

textPacket.setNeedsTranslation(false);
textPacket.setMessage(MessageTranslator.convertMessage(packet.getContent(), session.locale()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
package org.geysermc.geyser.translator.protocol.java.title;

import com.github.steveice10.mc.protocol.packet.ingame.clientbound.title.ClientboundSetActionBarTextPacket;
import org.cloudburstmc.protocol.bedrock.packet.SetTitlePacket;
import org.cloudburstmc.protocol.bedrock.packet.TextPacket;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
Expand All @@ -44,11 +44,14 @@ public void translate(GeyserSession session, ClientboundSetActionBarTextPacket p
text = MessageTranslator.convertMessage(packet.getText(), session.locale());
}

SetTitlePacket titlePacket = new SetTitlePacket();
titlePacket.setType(SetTitlePacket.Type.ACTIONBAR);
titlePacket.setText(text);
titlePacket.setXuid("");
titlePacket.setPlatformOnlineId("");
session.sendUpstreamPacket(titlePacket);
// Type seems wrong, but is intentional to avoid collisions with armor/remaining air bars
TextPacket textPacket = new TextPacket();
textPacket.setType(TextPacket.Type.JUKEBOX_POPUP);
textPacket.setNeedsTranslation(false);
textPacket.setSourceName("");
textPacket.setMessage(text);
textPacket.setXuid("");
textPacket.setPlatformChatId("");
session.sendUpstreamPacket(textPacket);
}
}

0 comments on commit d147ee3

Please sign in to comment.