mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Boss bar colors now work in Bedrock 1.18!!
This commit is contained in:
parent
75d1a6364c
commit
3f296e32a1
3 changed files with 18 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class JavaBossEventTranslator extends PacketTranslator<ClientboundBossEve
|
|||
switch (packet.getAction()) {
|
||||
case ADD:
|
||||
long entityId = session.getEntityCache().getNextEntityId().incrementAndGet();
|
||||
bossBar = new BossBar(session, entityId, packet.getTitle(), packet.getHealth(), 0, 1, 0);
|
||||
bossBar = new BossBar(session, entityId, packet.getTitle(), packet.getHealth(), packet.getColor().ordinal(), 1, 0);
|
||||
session.getEntityCache().addBossBar(packet.getUuid(), bossBar);
|
||||
break;
|
||||
case UPDATE_TITLE:
|
||||
|
@ -54,6 +54,8 @@ public class JavaBossEventTranslator extends PacketTranslator<ClientboundBossEve
|
|||
session.getEntityCache().removeBossBar(packet.getUuid());
|
||||
break;
|
||||
case UPDATE_STYLE:
|
||||
if (bossBar != null) bossBar.updateColor(packet.getColor().ordinal());
|
||||
break;
|
||||
case UPDATE_FLAGS:
|
||||
//todo
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue