aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java
blob: 6f06f405d95a8d92feffd94e7c8e69ff68c888b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.thatgravyboat.skyblockhud.handlers;

import com.thatgravyboat.skyblockhud.SkyblockHud;
import com.thatgravyboat.skyblockhud.Utils;
import com.thatgravyboat.skyblockhud.location.DwarvenMineHandler;
import com.thatgravyboat.skyblockhud.location.LocationHandler;
import com.thatgravyboat.skyblockhud.location.Locations;
import net.minecraft.entity.boss.BossStatus;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class BossbarHandler {

    public static boolean bossBarRendered = true;

    @SubscribeEvent(priority = EventPriority.LOWEST)
    public void onBossbarRender(RenderGameOverlayEvent.Pre event) {
        if (event.type == RenderGameOverlayEvent.ElementType.BOSSHEALTH && BossStatus.bossName != null) {
            bossBarRendered = !event.isCanceled();
            if (!SkyblockHud.config.main.bossShiftHud) {
                bossBarRendered = false;
            }
            String bossName = Utils.removeColor(BossStatus.bossName);
            if (
                SkyblockHud.config.renderer.hideBossBar &&
                DwarvenMineHandler.currentEvent == DwarvenMineHandler.Event.NONE &&
                !LocationHandler.getCurrentLocation().equals(Locations.CATACOMBS)
            ) {
                if (bossName.equalsIgnoreCase("wither")) {
                    event.setCanceled(true);
                    bossBarRendered = false;
                }
                if (bossName.toLowerCase().startsWith("objective:")) {
                    event.setCanceled(true);
                    bossBarRendered = false;
                }
            }
        }
    }
}