Boss events: one path from the host's diff to every overlay
The host diffed each viewer's boss events into a Change enum, then turned the changes into packets for guests and, through a second match, into setter calls on the window's own overlay; the client turned packets into the same setters a third way. The diff now yields ClientboundBossEventPacket values, guests get them as packets and the local overlay applies them with BossOverlay::apply, the same function a server's packets reach. Gone: Change, Snap, Sent, apply_local, boss_packet and the overlay's nine-argument add and setters. UUIDUtil.uuidFromIntArray joins uuid_ints in lan::playerdata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
//! `BossHealthOverlay` and `LerpingBossEvent`: the boss bars a client is
|
||||
//! showing, in the order their add packets arrived.
|
||||
use crate::{hud_overlays::BossBar, text::Text};
|
||||
use crate::{
|
||||
hud_overlays::BossBar,
|
||||
scoreboard::{comp_text, tag_to_json},
|
||||
text::Text,
|
||||
};
|
||||
use horizon_protocol::packets::play::{BossAction, BossEvent};
|
||||
|
||||
/// `LerpingBossEvent.LERP_MILLISECONDS`.
|
||||
const LERP_MS: u128 = 100;
|
||||
@@ -57,61 +62,62 @@ impl BossOverlay {
|
||||
pub fn reset(&mut self) {
|
||||
*self = Self::default();
|
||||
}
|
||||
/// `Handler.add`. An id already shown keeps its place.
|
||||
pub fn add(
|
||||
&mut self,
|
||||
id: u128,
|
||||
name: Text,
|
||||
progress: f32,
|
||||
color: u8,
|
||||
overlay: u8,
|
||||
darken: bool,
|
||||
music: bool,
|
||||
fog: bool,
|
||||
now: u128,
|
||||
) {
|
||||
let event = Event {
|
||||
id,
|
||||
/// `ClientboundBossEventPacket.dispatch` into `BossHealthOverlay`'s
|
||||
/// handler. An id already shown keeps its place when added again.
|
||||
pub fn apply(&mut self, packet: &BossEvent, now: u128) {
|
||||
// An ordinal past the enum shows as its last value.
|
||||
let color = |c: i32| c.clamp(0, 6) as u8;
|
||||
let overlay = |o: i32| o.clamp(0, 4) as u8;
|
||||
let id = packet.id;
|
||||
if let BossAction::Add {
|
||||
name,
|
||||
progress,
|
||||
target: progress,
|
||||
set_at: now,
|
||||
color: color.min(6),
|
||||
overlay: overlay.min(4),
|
||||
color: c,
|
||||
overlay: o,
|
||||
darken,
|
||||
music,
|
||||
fog,
|
||||
} = &packet.action
|
||||
{
|
||||
let event = Event {
|
||||
id,
|
||||
name: comp_text(&tag_to_json(name)),
|
||||
progress: *progress,
|
||||
target: *progress,
|
||||
set_at: now,
|
||||
color: color(*c),
|
||||
overlay: overlay(*o),
|
||||
darken: *darken,
|
||||
music: *music,
|
||||
fog: *fog,
|
||||
};
|
||||
match self.events.iter_mut().find(|e| e.id == id) {
|
||||
Some(slot) => *slot = event,
|
||||
None => self.events.push(event),
|
||||
}
|
||||
return;
|
||||
}
|
||||
if let BossAction::Remove = packet.action {
|
||||
self.events.retain(|e| e.id != id);
|
||||
return;
|
||||
}
|
||||
let Some(e) = self.events.iter_mut().find(|e| e.id == id) else {
|
||||
return;
|
||||
};
|
||||
if let Some(slot) = self.events.iter_mut().find(|e| e.id == id) {
|
||||
*slot = event;
|
||||
} else {
|
||||
self.events.push(event);
|
||||
}
|
||||
}
|
||||
pub fn remove(&mut self, id: u128) {
|
||||
self.events.retain(|e| e.id != id);
|
||||
}
|
||||
pub fn set_progress(&mut self, id: u128, progress: f32, now: u128) {
|
||||
if let Some(e) = self.events.iter_mut().find(|e| e.id == id) {
|
||||
e.set_progress(progress, now);
|
||||
}
|
||||
}
|
||||
pub fn set_name(&mut self, id: u128, name: Text) {
|
||||
if let Some(e) = self.events.iter_mut().find(|e| e.id == id) {
|
||||
e.name = name;
|
||||
}
|
||||
}
|
||||
pub fn set_style(&mut self, id: u128, color: u8, overlay: u8) {
|
||||
if let Some(e) = self.events.iter_mut().find(|e| e.id == id) {
|
||||
e.color = color.min(6);
|
||||
e.overlay = overlay.min(4);
|
||||
}
|
||||
}
|
||||
pub fn set_properties(&mut self, id: u128, darken: bool, music: bool, fog: bool) {
|
||||
if let Some(e) = self.events.iter_mut().find(|e| e.id == id) {
|
||||
e.darken = darken;
|
||||
e.music = music;
|
||||
e.fog = fog;
|
||||
match &packet.action {
|
||||
BossAction::UpdateProgress { progress } => e.set_progress(*progress, now),
|
||||
BossAction::UpdateName { name } => e.name = comp_text(&tag_to_json(name)),
|
||||
BossAction::UpdateStyle {
|
||||
color: c,
|
||||
overlay: o,
|
||||
} => {
|
||||
e.color = color(*c);
|
||||
e.overlay = overlay(*o);
|
||||
}
|
||||
BossAction::UpdateProperties { darken, music, fog } => {
|
||||
(e.darken, e.music, e.fog) = (*darken, *music, *fog);
|
||||
}
|
||||
BossAction::Add { .. } | BossAction::Remove => {}
|
||||
}
|
||||
}
|
||||
/// `GameRenderer.tick` while the level runs.
|
||||
@@ -157,26 +163,54 @@ impl BossOverlay {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use horizon_world::nbt::Tag;
|
||||
|
||||
fn add(id: u128, name: &str, progress: f32, darken: bool, fog: bool) -> BossEvent {
|
||||
BossEvent {
|
||||
id,
|
||||
action: BossAction::Add {
|
||||
name: Tag::String(name.into()),
|
||||
progress,
|
||||
color: 5,
|
||||
overlay: 0,
|
||||
darken,
|
||||
music: false,
|
||||
fog,
|
||||
},
|
||||
}
|
||||
}
|
||||
fn progress(id: u128, progress: f32) -> BossEvent {
|
||||
BossEvent {
|
||||
id,
|
||||
action: BossAction::UpdateProgress { progress },
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn progress_lerps_over_a_tenth_of_a_second() {
|
||||
let mut overlay = BossOverlay::default();
|
||||
overlay.add(1, Text::literal("W"), 0.0, 5, 0, true, false, false, 0);
|
||||
overlay.set_progress(1, 1.0, 0);
|
||||
overlay.apply(&add(1, "W", 0.0, true, false), 0);
|
||||
overlay.apply(&progress(1, 1.0), 0);
|
||||
assert!((overlay.bars(50)[0].progress - 0.5).abs() < 1.0e-5);
|
||||
assert!((overlay.bars(100)[0].progress - 1.0).abs() < 1.0e-5);
|
||||
// A new target starts from the value on screen.
|
||||
overlay.set_progress(1, 0.0, 50);
|
||||
overlay.apply(&progress(1, 0.0), 50);
|
||||
assert!((overlay.bars(150)[0].progress - 0.0).abs() < 1.0e-5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn darken_ramps_and_fades() {
|
||||
let mut overlay = BossOverlay::default();
|
||||
overlay.add(1, Text::literal("W"), 1.0, 5, 0, true, false, false, 0);
|
||||
overlay.apply(&add(1, "W", 1.0, true, false), 0);
|
||||
overlay.tick_darken(true);
|
||||
assert!((overlay.darken_amount(1.0) - 0.05).abs() < 1.0e-5);
|
||||
overlay.remove(1);
|
||||
overlay.apply(
|
||||
&BossEvent {
|
||||
id: 1,
|
||||
action: BossAction::Remove,
|
||||
},
|
||||
0,
|
||||
);
|
||||
overlay.tick_darken(true);
|
||||
assert!((overlay.darken - 0.0375).abs() < 1.0e-5);
|
||||
assert!(!overlay.should_play_music());
|
||||
@@ -185,9 +219,11 @@ mod tests {
|
||||
#[test]
|
||||
fn bars_keep_arrival_order() {
|
||||
let mut overlay = BossOverlay::default();
|
||||
overlay.add(2, Text::literal("b"), 1.0, 0, 0, false, true, true, 0);
|
||||
overlay.add(1, Text::literal("a"), 1.0, 0, 0, false, false, false, 0);
|
||||
overlay.add(2, Text::literal("c"), 0.5, 1, 2, false, true, true, 0);
|
||||
overlay.apply(&add(2, "b", 1.0, false, true), 0);
|
||||
overlay.apply(&add(1, "a", 1.0, false, false), 0);
|
||||
overlay.apply(&add(2, "c", 0.5, false, true), 0);
|
||||
// An update for a bar this client never got is ignored.
|
||||
overlay.apply(&progress(9, 0.5), 0);
|
||||
let names: Vec<_> = overlay
|
||||
.bars(0)
|
||||
.into_iter()
|
||||
@@ -195,7 +231,13 @@ mod tests {
|
||||
.collect();
|
||||
assert_eq!(names, ["c", "a"]);
|
||||
assert!(overlay.should_create_world_fog());
|
||||
overlay.remove(2);
|
||||
overlay.apply(
|
||||
&BossEvent {
|
||||
id: 2,
|
||||
action: BossAction::Remove,
|
||||
},
|
||||
0,
|
||||
);
|
||||
assert!(!overlay.should_create_world_fog());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use horizon_client::{
|
||||
command::{Arg, Context},
|
||||
mobs::Species,
|
||||
save,
|
||||
scoreboard::{self as sb, Comp, comp_text, json_to_tag, tag_to_json},
|
||||
scoreboard::{self as sb, Comp, json_to_tag},
|
||||
scoreboard_cmd::format_list,
|
||||
text::Text,
|
||||
};
|
||||
@@ -23,7 +23,7 @@ pub(super) struct BossState {
|
||||
pub bars: BossBars,
|
||||
loaded: bool,
|
||||
/// What each viewer was last sent, so a change becomes one packet.
|
||||
sent: HashMap<u128, HashMap<u128, Sent>>,
|
||||
sent: HashMap<u128, HashMap<u128, Offer>>,
|
||||
}
|
||||
|
||||
fn num(n: impl std::fmt::Display) -> Text {
|
||||
@@ -418,12 +418,11 @@ impl Game<'_> {
|
||||
let mut packets = Vec::new();
|
||||
for viewer in &viewers {
|
||||
let desired = self.boss_events_for(viewer);
|
||||
let changes = self.diff_boss_events(viewer, &desired);
|
||||
if viewer.local {
|
||||
apply_local(&mut self.boss_overlay, &changes, now);
|
||||
} else if let Some(conn) = viewer.conn {
|
||||
for change in changes {
|
||||
packets.push((conn, boss_packet(change)));
|
||||
for event in self.diff_boss_events(viewer, desired) {
|
||||
if viewer.local {
|
||||
self.boss_overlay.apply(&event, now);
|
||||
} else if let Some(conn) = viewer.conn {
|
||||
packets.push((conn, C::BossEvent(event)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -446,7 +445,7 @@ impl Game<'_> {
|
||||
if local && let Some(p) = &self.player {
|
||||
let ints = self.level.player_uuid.unwrap_or_else(|| self.acting_uuid());
|
||||
out.push(Viewer {
|
||||
uuid: ints_to_uuid(ints),
|
||||
uuid: horizon_client::lan::playerdata::ints_uuid(ints),
|
||||
ints,
|
||||
at: [p.position.x, p.position.y, p.position.z],
|
||||
alive: !p.health.dead_or_dying(),
|
||||
@@ -552,8 +551,8 @@ impl Game<'_> {
|
||||
id: b.uuid,
|
||||
name: json_to_tag(&b.name),
|
||||
progress: b.progress(),
|
||||
color: color_index(&b.color) as u8,
|
||||
overlay: style_index(&b.style) as u8,
|
||||
color: color_index(&b.color),
|
||||
overlay: style_index(&b.style),
|
||||
darken: b.darken,
|
||||
music: b.music,
|
||||
fog: b.fog,
|
||||
@@ -562,108 +561,66 @@ impl Game<'_> {
|
||||
}
|
||||
out
|
||||
}
|
||||
fn diff_boss_events(&mut self, viewer: &Viewer, desired: &[Offer]) -> Vec<Change> {
|
||||
/// The packets that take `viewer` from what it was last sent to `desired`
|
||||
/// (`ServerBossEvent`'s broadcasts).
|
||||
fn diff_boss_events(&mut self, viewer: &Viewer, desired: Vec<Offer>) -> Vec<play::BossEvent> {
|
||||
let full = viewer.local;
|
||||
let dim = self.dim;
|
||||
let sent = self.bosses.sent.entry(viewer.uuid).or_default();
|
||||
let mut changes = Vec::new();
|
||||
let gone: Vec<u128> = sent
|
||||
.iter()
|
||||
.filter(|(id, prev)| {
|
||||
let owned = full || prev.scope == Scope::Global || prev.scope == Scope::Level(dim);
|
||||
owned && !desired.iter().any(|e| e.id == **id)
|
||||
})
|
||||
.map(|(id, _)| *id)
|
||||
.collect();
|
||||
for id in gone {
|
||||
sent.remove(&id);
|
||||
changes.push(Change::Remove(id));
|
||||
}
|
||||
for event in desired {
|
||||
let snap = event.snap();
|
||||
match sent.get(&event.id).map(|s| s.snap.clone()) {
|
||||
None => {
|
||||
sent.insert(
|
||||
event.id,
|
||||
Sent {
|
||||
snap,
|
||||
scope: event.scope,
|
||||
},
|
||||
);
|
||||
changes.push(Change::Add(event.clone()));
|
||||
}
|
||||
Some(prev) => {
|
||||
if prev.progress != snap.progress {
|
||||
changes.push(Change::Progress(event.id, snap.progress));
|
||||
}
|
||||
if prev.name != snap.name {
|
||||
changes.push(Change::Name(event.id, snap.name.clone()));
|
||||
}
|
||||
if prev.color != snap.color || prev.overlay != snap.overlay {
|
||||
changes.push(Change::Style(event.id, snap.color, snap.overlay));
|
||||
}
|
||||
if prev.darken != snap.darken
|
||||
|| prev.music != snap.music
|
||||
|| prev.fog != snap.fog
|
||||
{
|
||||
changes.push(Change::Properties(
|
||||
event.id,
|
||||
snap.darken,
|
||||
snap.music,
|
||||
snap.fog,
|
||||
));
|
||||
}
|
||||
sent.insert(
|
||||
event.id,
|
||||
Sent {
|
||||
snap,
|
||||
scope: event.scope,
|
||||
},
|
||||
);
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
let event = |id, action| play::BossEvent { id, action };
|
||||
sent.retain(|id, prev| {
|
||||
let owned = full || prev.scope == Scope::Global || prev.scope == Scope::Level(dim);
|
||||
let keep = !owned || desired.iter().any(|e| e.id == *id);
|
||||
if !keep {
|
||||
out.push(event(*id, BossAction::Remove));
|
||||
}
|
||||
keep
|
||||
});
|
||||
for offer in desired {
|
||||
let Some(prev) = sent.get(&offer.id) else {
|
||||
out.push(event(
|
||||
offer.id,
|
||||
BossAction::Add {
|
||||
name: offer.name.clone(),
|
||||
progress: offer.progress,
|
||||
color: offer.color,
|
||||
overlay: offer.overlay,
|
||||
darken: offer.darken,
|
||||
music: offer.music,
|
||||
fog: offer.fog,
|
||||
},
|
||||
));
|
||||
sent.insert(offer.id, offer);
|
||||
continue;
|
||||
};
|
||||
let id = offer.id;
|
||||
if prev.progress != offer.progress {
|
||||
let progress = offer.progress;
|
||||
out.push(event(id, BossAction::UpdateProgress { progress }));
|
||||
}
|
||||
if prev.name != offer.name {
|
||||
let name = offer.name.clone();
|
||||
out.push(event(id, BossAction::UpdateName { name }));
|
||||
}
|
||||
if (prev.color, prev.overlay) != (offer.color, offer.overlay) {
|
||||
let (color, overlay) = (offer.color, offer.overlay);
|
||||
out.push(event(id, BossAction::UpdateStyle { color, overlay }));
|
||||
}
|
||||
if (prev.darken, prev.music, prev.fog) != (offer.darken, offer.music, offer.fog) {
|
||||
let (darken, music, fog) = (offer.darken, offer.music, offer.fog);
|
||||
out.push(event(
|
||||
id,
|
||||
BossAction::UpdateProperties { darken, music, fog },
|
||||
));
|
||||
}
|
||||
sent.insert(id, offer);
|
||||
}
|
||||
changes
|
||||
out
|
||||
}
|
||||
/// `ClientPacketListener.handleBossUpdate`.
|
||||
pub(super) fn apply_boss_event(&mut self, packet: play::BossEvent) {
|
||||
let now = boss_overlay::now_millis();
|
||||
let ord = |v: i32| v.clamp(0, 255) as u8;
|
||||
match packet.action {
|
||||
BossAction::Add {
|
||||
name,
|
||||
progress,
|
||||
color,
|
||||
overlay,
|
||||
darken,
|
||||
music,
|
||||
fog,
|
||||
} => self.boss_overlay.add(
|
||||
packet.id,
|
||||
component_text(&name),
|
||||
progress,
|
||||
ord(color),
|
||||
ord(overlay),
|
||||
darken,
|
||||
music,
|
||||
fog,
|
||||
now,
|
||||
),
|
||||
BossAction::Remove => self.boss_overlay.remove(packet.id),
|
||||
BossAction::UpdateProgress { progress } => {
|
||||
self.boss_overlay.set_progress(packet.id, progress, now)
|
||||
}
|
||||
BossAction::UpdateName { name } => {
|
||||
self.boss_overlay.set_name(packet.id, component_text(&name))
|
||||
}
|
||||
BossAction::UpdateStyle { color, overlay } => {
|
||||
self.boss_overlay
|
||||
.set_style(packet.id, ord(color), ord(overlay))
|
||||
}
|
||||
BossAction::UpdateProperties { darken, music, fog } => self
|
||||
.boss_overlay
|
||||
.set_properties(packet.id, darken, music, fog),
|
||||
}
|
||||
pub(super) fn apply_boss_event(&mut self, packet: &play::BossEvent) {
|
||||
self.boss_overlay.apply(packet, boss_overlay::now_millis());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -673,27 +630,20 @@ fn insecure_uuid(random: &mut impl RandomSource) -> u128 {
|
||||
let least = random.next_long() & 4_611_686_018_427_387_903 | i64::MIN;
|
||||
((most as u64 as u128) << 64) | (least as u64 as u128)
|
||||
}
|
||||
fn ints_to_uuid(ints: [i32; 4]) -> u128 {
|
||||
ints.iter()
|
||||
.fold(0u128, |acc, &i| (acc << 32) | u128::from(i as u32))
|
||||
}
|
||||
fn translate_tag(key: &str) -> Tag {
|
||||
Tag::compound([("translate", Tag::String(key.into()))])
|
||||
}
|
||||
fn color_index(color: &str) -> usize {
|
||||
fn color_index(color: &str) -> i32 {
|
||||
bossbar::COLORS
|
||||
.iter()
|
||||
.position(|c| *c == color)
|
||||
.unwrap_or(6)
|
||||
.unwrap_or(6) as i32
|
||||
}
|
||||
fn style_index(style: &str) -> usize {
|
||||
fn style_index(style: &str) -> i32 {
|
||||
bossbar::STYLES
|
||||
.iter()
|
||||
.position(|s| *s == style)
|
||||
.unwrap_or(0)
|
||||
}
|
||||
fn component_text(tag: &Tag) -> Text {
|
||||
comp_text(&tag_to_json(tag))
|
||||
.unwrap_or(0) as i32
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
@@ -701,20 +651,6 @@ enum Scope {
|
||||
Global,
|
||||
Level(Dim),
|
||||
}
|
||||
#[derive(Clone)]
|
||||
struct Snap {
|
||||
name: Tag,
|
||||
progress: f32,
|
||||
color: u8,
|
||||
overlay: u8,
|
||||
darken: bool,
|
||||
music: bool,
|
||||
fog: bool,
|
||||
}
|
||||
struct Sent {
|
||||
snap: Snap,
|
||||
scope: Scope,
|
||||
}
|
||||
struct Viewer {
|
||||
uuid: u128,
|
||||
ints: [i32; 4],
|
||||
@@ -725,92 +661,16 @@ struct Viewer {
|
||||
conn: Option<u32>,
|
||||
view_chunks: i32,
|
||||
}
|
||||
#[derive(Clone)]
|
||||
/// A boss event as one viewer should see it, and as it was last sent.
|
||||
struct Offer {
|
||||
id: u128,
|
||||
name: Tag,
|
||||
progress: f32,
|
||||
color: u8,
|
||||
overlay: u8,
|
||||
/// `BossBarColor` and `BossBarOverlay` ordinals.
|
||||
color: i32,
|
||||
overlay: i32,
|
||||
darken: bool,
|
||||
music: bool,
|
||||
fog: bool,
|
||||
scope: Scope,
|
||||
}
|
||||
impl Offer {
|
||||
fn snap(&self) -> Snap {
|
||||
Snap {
|
||||
name: self.name.clone(),
|
||||
progress: self.progress,
|
||||
color: self.color,
|
||||
overlay: self.overlay,
|
||||
darken: self.darken,
|
||||
music: self.music,
|
||||
fog: self.fog,
|
||||
}
|
||||
}
|
||||
}
|
||||
enum Change {
|
||||
Add(Offer),
|
||||
Remove(u128),
|
||||
Progress(u128, f32),
|
||||
Name(u128, Tag),
|
||||
Style(u128, u8, u8),
|
||||
Properties(u128, bool, bool, bool),
|
||||
}
|
||||
fn apply_local(overlay: &mut boss_overlay::BossOverlay, changes: &[Change], now: u128) {
|
||||
for change in changes {
|
||||
match change {
|
||||
Change::Add(e) => overlay.add(
|
||||
e.id,
|
||||
component_text(&e.name),
|
||||
e.progress,
|
||||
e.color,
|
||||
e.overlay,
|
||||
e.darken,
|
||||
e.music,
|
||||
e.fog,
|
||||
now,
|
||||
),
|
||||
Change::Remove(id) => overlay.remove(*id),
|
||||
Change::Progress(id, progress) => overlay.set_progress(*id, *progress, now),
|
||||
Change::Name(id, name) => overlay.set_name(*id, component_text(name)),
|
||||
Change::Style(id, color, overlay_style) => {
|
||||
overlay.set_style(*id, *color, *overlay_style)
|
||||
}
|
||||
Change::Properties(id, darken, music, fog) => {
|
||||
overlay.set_properties(*id, *darken, *music, *fog)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fn boss_packet(change: Change) -> C {
|
||||
let (id, action) = match change {
|
||||
Change::Add(e) => (
|
||||
e.id,
|
||||
BossAction::Add {
|
||||
name: e.name,
|
||||
progress: e.progress,
|
||||
color: i32::from(e.color),
|
||||
overlay: i32::from(e.overlay),
|
||||
darken: e.darken,
|
||||
music: e.music,
|
||||
fog: e.fog,
|
||||
},
|
||||
),
|
||||
Change::Remove(id) => (id, BossAction::Remove),
|
||||
Change::Progress(id, progress) => (id, BossAction::UpdateProgress { progress }),
|
||||
Change::Name(id, name) => (id, BossAction::UpdateName { name }),
|
||||
Change::Style(id, color, overlay) => (
|
||||
id,
|
||||
BossAction::UpdateStyle {
|
||||
color: i32::from(color),
|
||||
overlay: i32::from(overlay),
|
||||
},
|
||||
),
|
||||
Change::Properties(id, darken, music, fog) => {
|
||||
(id, BossAction::UpdateProperties { darken, music, fog })
|
||||
}
|
||||
};
|
||||
C::BossEvent(play::BossEvent { id, action })
|
||||
}
|
||||
|
||||
@@ -2642,7 +2642,7 @@ impl Game<'_> {
|
||||
}
|
||||
// ClientPacketListener.setActionBarText, setTitleText,
|
||||
// setSubtitleText, setTitlesAnimation and handleTitlesClear.
|
||||
C::BossEvent(p) => self.apply_boss_event(p),
|
||||
C::BossEvent(p) => self.apply_boss_event(&p),
|
||||
C::SetActionBarText(p) => self.titles.set_overlay(remote_text(&p.text), false),
|
||||
C::SetTitleText(p) => self.titles.set_title(remote_text(&p.text)),
|
||||
C::SetSubtitleText(p) => self.titles.set_subtitle(remote_text(&p.text)),
|
||||
|
||||
@@ -27,6 +27,11 @@ pub fn uuid_ints(uuid: u128) -> [i32; 4] {
|
||||
uuid as i32,
|
||||
]
|
||||
}
|
||||
/// `UUIDUtil.uuidFromIntArray`.
|
||||
pub fn ints_uuid(ints: [i32; 4]) -> u128 {
|
||||
ints.iter()
|
||||
.fold(0, |acc, &i| acc << 32 | u128::from(i as u32))
|
||||
}
|
||||
|
||||
/// Whether a saved file exists for this player.
|
||||
pub fn exists(world: &Path, uuid: u128) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user