Class EntityBossBar

java.lang.Object
net.ixdarklord.coolcatcanvas.api.bossbar.EntityBossBar

public final class EntityBossBar extends Object
A boss bar that belongs to a living entity and keeps itself: its name is the entity's, its progress the entity's health, and it shows to the players near it while it is to be shown. Make one from the server, show() it, and it runs by itself every tick until the entity is removed, or hide() is called.
EntityBossBar bar = EntityBossBar.of(this)
        .style(MyMod.id("warden"))          // drawn by a renderer of that id on the client
        .color(BossBarColor.RED).overlay(BossBarOverlay.NOTCHED_10)
        .range(48).darkenScreen(true)
        .showWhen(boss -> !((MyBoss) boss).isAsleep())
        .show();
For a bar an entity drives itself (its own progress, phases, names), give it a ServerBossEvent of its own and style it with CustomBossBars.style(ServerBossEvent, Identifier).
  • Method Details

    • of

      public static EntityBossBar of(net.minecraft.world.entity.LivingEntity entity)
    • style

      public EntityBossBar style(@Nullable @Nullable net.minecraft.resources.Identifier style)
      The style it is drawn in on the client (BossBarRenderers); null for the game's own bar.
    • color

      public EntityBossBar color(net.minecraft.world.BossEvent.BossBarColor color)
    • overlay

      public EntityBossBar overlay(net.minecraft.world.BossEvent.BossBarOverlay overlay)
    • darkenScreen

      public EntityBossBar darkenScreen(boolean darken)
    • playBossMusic

      public EntityBossBar playBossMusic(boolean music)
    • createWorldFog

      public EntityBossBar createWorldFog(boolean fog)
    • range

      public EntityBossBar range(double blocks)
      How near, in blocks, a player must be to see it. 48 by default.
    • showWhen

      public EntityBossBar showWhen(Predicate<net.minecraft.world.entity.LivingEntity> condition)
      When it shows at all, asked every tick: a boss asleep, or not yet woken, need not show its bar.
    • show

      public EntityBossBar show()
      Starts it: from now on it keeps itself every tick, until the entity is gone or hide().
    • hide

      public void hide()
      Stops it, and takes it off every screen.
    • entity

      public net.minecraft.world.entity.LivingEntity entity()
    • event

      public net.minecraft.server.level.ServerBossEvent event()
      The bar itself, for anything not covered here.
    • style

      @Nullable public @Nullable net.minecraft.resources.Identifier style()
    • tick

      public boolean tick()
      One server tick of it; false once it is done. Called by CoolCatLib.