Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boss Bar API #337

Closed
rj00a opened this issue May 23, 2023 · 3 comments
Closed

Boss Bar API #337

rj00a opened this issue May 23, 2023 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@rj00a
Copy link
Member

rj00a commented May 23, 2023

Describe the problem related to your feature request.

There is no API for boss bars.

What solution would you like?

Create a new crate called valence_boss_bar. Every boss bar is an entity with the following components:

  • BossBarTitle
  • BossBarHealth
  • BossBarStyle (contains color and division)
  • BossBarFlags
  • Uuid (defined in valence_entity currently)
  • BossBarViewers. Contains the set of client entities viewing this boss bar. When the boss bar is despawned with the Despawned component, the boss bar is removed from all viewers.

Change detection on the components is used to send packets to the boss bar viewers.

Also might be good to use another component containing a Vec<u8> to cache boss bar packets before sending them to viewers.

What alternative(s) have you considered?

When entity relations in bevy_ecs become a thing, the BossBarViewers component could probably be replaced with a boss bar -> client relation for each viewer.

Additional context

See the BossBarS2c packet.

@rj00a rj00a added enhancement New feature or request good first issue Good for newcomers labels May 23, 2023
@SamantaTarun
Copy link

@rj00a I am interested to work on this issue. But I need some help.

@dyc3
Copy link
Collaborator

dyc3 commented May 23, 2023

Here some some references/pointers to get you started:

All you need to do is make the components and implement the systems to actually send the packets, preferably with unit tests.

rj00a pushed a commit that referenced this issue Jun 20, 2023
## Description

Hey, I started working on this issue
#337.

### So far:
- I created a crate "**valence_boss_bar**" and I moved this packet there
https://github.com/valence-rs/valence/blob/2ed5a8840da244d8f1f91f1df43750664952be46/crates/valence_core/src/protocol/packet.rs#L612
- I initialized the plugin and added a system that removes the players
when a boss bar is despawned.
- I created/moved the boss bar components (BossBarTitle, BossBarHealth,
BossBarStyle, BossBarFlags and BossBarViewers)
- I added systems that handle the update of boss bar attributes and
player disconnection
- I documented the code
- I made unit tests

### Playground
I've tested the API in playground and it works fine.


https://github.com/valence-rs/valence/assets/29759371/5661873b-c3a7-4a5d-b9e6-6c739bef4c2f

---------

Co-authored-by: pepperoni21 <pepperoni2100@gmail.com>
@JackCrumpLeys
Copy link
Contributor

This should be closed.

@dyc3 dyc3 closed this as completed Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants