Search in sources :

Example 1 with IMorePlanetsBoss

use of stevekung.mods.moreplanets.utils.IMorePlanetsBoss in project MorePlanets by SteveKunG.

the class ClientEventHandler method onBossBarRender.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onBossBarRender(RenderGameOverlayEvent.BossInfo event) {
    int y = event.getY();
    int width = event.getResolution().getScaledWidth();
    UUID uuid = event.getBossInfo().getUniqueId();
    int bossBarWidth = 200;
    int bossBarHeight = 16;
    int barX = width / 2 - bossBarWidth / 2;
    int barY = y + 4;
    int percent = (int) (bossBarWidth * event.getBossInfo().getPercent());
    for (IMorePlanetsBoss boss : ClientEventHandler.BOSSES) {
        if (boss.getBossUUID().equals(uuid)) {
            String bossType = boss.getBossType().getName();
            String name = boss.getBossName();
            // start render custom boss bar
            event.setCanceled(true);
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            this.mc.getTextureManager().bindTexture(BOSS_BAR);
            this.mc.ingameGUI.drawTexturedModalRect(barX, barY, 0, 0, bossBarWidth, bossBarHeight);
            this.mc.ingameGUI.drawTexturedModalRect(barX, barY, 0, 16, percent, bossBarHeight);
            this.mc.ingameGUI.getFontRenderer().drawStringWithShadow(bossType, width / 2 - this.mc.ingameGUI.getFontRenderer().getStringWidth(bossType) / 2, y - 8, 16777215);
            this.mc.ingameGUI.getFontRenderer().drawStringWithShadow(TextFormatting.ITALIC + name, width / 2 - this.mc.ingameGUI.getFontRenderer().getStringWidth(name) / 2, y + 8, boss.getBossTextColor());
            event.setIncrement(bossBarHeight * 2);
        }
    }
}
Also used : IMorePlanetsBoss(stevekung.mods.moreplanets.utils.IMorePlanetsBoss) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 IMorePlanetsBoss (stevekung.mods.moreplanets.utils.IMorePlanetsBoss)1