3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-04 23:30:17 +01:00

Boss bar colors now work in Bedrock 1.18!!

Dieser Commit ist enthalten in:
Camotoy 2021-11-30 21:28:32 -05:00
Ursprung 75d1a6364c
Commit 3f296e32a1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
3 geänderte Dateien mit 18 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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);

Datei anzeigen

@ -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();
}
}
}
}

Datei anzeigen

@ -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
}