Boss Bars - Skizzium/Project-Lib GitHub Wiki

Everyone knows about them, they're something standard and very important in a boss fight. Our current implementation of boss bars is based heavily on vanilla. The only two differences are the networking code and the colors / overlays.

In this page, we'll tell you how to use our implementation and we'll give you some examples. For more examples, check out the vanilla boss bars in the WitherBoss and the EnderDragon classes. Keep in mind you need to use our BossEvent classes instead of the ones used in vanilla. You can also check out Skizzik & Co. for more examples.

Basic Usage

It's actually really easy! (Since Beta #6) First off, you'll need to implement BossEntity. It will handle almost everything for you. You'll need to create a new field in your entity's class that will store your boss bar. After that you override the getBossBar method provided by BossEntity and you return the field you just created. BossEntity will handle rendering and updating for you unless their respective properties are set to false.

You can define the display name and the visual (and audio) properties of your bar. You must also pass your entity. The available properties are:

  • Darken Screen
  • Create World Fog
  • Auto Render & Update
  • Combined Health (Whether or not you want the main bar to display it's entity's health combined with all Minibar healths)
  • Music
  • Custom Color
  • Color
  • Overlay

You can set these properties by calling their individual methods in a similar fashion to the ItemProperties.

private final PL_ServerBossEvent bossBar = new PL_ServerBossEvent(this, this.getDisplayName(), new PL_BossEvent.BossEventProperties());
@Override
public PL_ServerBossEvent getBossBar() {
    return this.bossBar;
}

Custom Colors

Tired of the defaults? Well now you have the whole RGB (HEX in this case) palette available to you! You can either pass your HEX when creating the bar instead of passing a value from the color enum or instead, you can set it via PL_ServerBossEvent#setColor. You can also set it to null to remove the custom coloring. If a custom color is not defined, the color from the color enum will be used. If that isn't defined either, the boss bar will fall back to the white template bar.

Changing the properties

You can change your boss bar's properties at any time you want by calling the property's corresponding method. Keep in mind PL_ServerBossEvent#setProgress needs a float between 0.0F and 1.0F and not a percentage. Also, you can pass null in PL_ServerBossEvent#setMusic to stop the sound.