From 3f296e32a1c20b2619238a52e8a8ca006e8bad23 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Tue, 30 Nov 2021 21:28:32 -0500 Subject: [PATCH] Boss bar colors now work in Bedrock 1.18!! --- .../org/geysermc/geyser/session/cache/BossBar.java | 12 +++++++++++- ...BedrockSetLocalPlayerAsInitializedTranslator.java | 4 ++++ .../protocol/java/JavaBossEventTranslator.java | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/BossBar.java b/core/src/main/java/org/geysermc/geyser/session/cache/BossBar.java index 9595a3daf..ffb98c958 100644 --- a/core/src/main/java/org/geysermc/geyser/session/cache/BossBar.java +++ b/core/src/main/java/org/geysermc/geyser/session/cache/BossBar.java @@ -42,7 +42,7 @@ public class BossBar { private final long entityId; private Component title; private float health; - private final int color; + private int color; private final int overlay; private final int darkenSky; @@ -86,6 +86,16 @@ public class BossBar { session.sendUpstreamPacket(bossEventPacket); } + public void updateColor(int color) { + this.color = color; + BossEventPacket bossEventPacket = new BossEventPacket(); + bossEventPacket.setBossUniqueEntityId(entityId); + bossEventPacket.setAction(BossEventPacket.Action.UPDATE_STYLE); + bossEventPacket.setColor(color); + + session.sendUpstreamPacket(bossEventPacket); + } + public void removeBossBar() { BossEventPacket bossEventPacket = new BossEventPacket(); bossEventPacket.setBossUniqueEntityId(entityId); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java index bc6d1f4e4..b30d9be81 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java @@ -46,6 +46,10 @@ public class BedrockSetLocalPlayerAsInitializedTranslator extends PacketTranslat } // else we were able to log the user in } + if (session.isLoggedIn()) { + // Sigh + session.getEntityCache().updateBossBars(); + } } } } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaBossEventTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaBossEventTranslator.java index 2c49baa56..c9512b87b 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaBossEventTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaBossEventTranslator.java @@ -41,7 +41,7 @@ public class JavaBossEventTranslator extends PacketTranslator