aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/FirePillarDisplay.java
blob: 34b2288d503f09d11d33716f6fae58f9d4ff5be4 (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
42
43
44
45
46
47
48
49
50
51
package me.Danker.features;

import me.Danker.DankersSkyblockMod;
import me.Danker.commands.MoveCommand;
import me.Danker.commands.ScaleCommand;
import me.Danker.commands.ToggleCommand;
import me.Danker.events.RenderOverlayEvent;
import me.Danker.handlers.TextRenderer;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.util.StringUtils;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

import java.util.List;

public class FirePillarDisplay {

    static Entity pillar = null;

    @SubscribeEvent
    public void onTick(TickEvent.ClientTickEvent event) {
        if (event.phase != TickEvent.Phase.START) return;

        World world = Minecraft.getMinecraft().theWorld;
        if (DankersSkyblockMod.tickAmount % 20 == 0) {
            pillar = null;
            if (ToggleCommand.firePillar && world != null && Utils.tabLocation.equals("Crimson Isle") && Utils.isInScoreboard("Slay the boss!")) {
                List<Entity> entities = world.getLoadedEntityList();

                for (Entity entity : entities) {
                    String name = StringUtils.stripControlCodes(entity.getName());
                    if (name.endsWith(" hits") && name.charAt(1) == 's') {
                        pillar = entity;
                        break;
                    }
                }
            }
        }
    }

    @SubscribeEvent
    public void renderPlayerInfo(RenderOverlayEvent event) {
        if (ToggleCommand.firePillar && pillar != null) {
            new TextRenderer(Minecraft.getMinecraft(), Utils.removeBold(pillar.getName()), MoveCommand.firePillarXY[0], MoveCommand.firePillarXY[1], ScaleCommand.firePillarScale);
        }
    }

}