aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/FishingSpawnAlerts.java
blob: 3f11dfceb296d44172604d9ec0124b810e3ae4e9 (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
52
53
54
55
56
57
58
59
60
package me.Danker.features;

import me.Danker.DankersSkyblockMod;
import me.Danker.commands.ToggleCommand;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StringUtils;
import net.minecraft.world.World;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

import java.util.List;

public class FishingSpawnAlerts {

    static boolean lastThunder = false;
    static boolean lastJawbus = false;

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

        World world = Minecraft.getMinecraft().theWorld;
        if (DankersSkyblockMod.tickAmount % 10 == 0) {
            if (ToggleCommand.fishingAlert && Utils.tabLocation.equals("Crimson Isle") && world != null) {
                boolean thunder = false;
                boolean jawbus = false;
                List<Entity> entities = world.getLoadedEntityList();

                for (Entity entity : entities) {
                    if (entity instanceof EntityArmorStand) {
                        String name = StringUtils.stripControlCodes(entity.getName());
                        if (name.contains("Thunder")) {
                            thunder = true;
                        } else if (name.contains("Lord Jawbus")) {
                            jawbus = true;
                        }
                    }
                }

                if (thunder && !lastThunder) Utils.createTitle(EnumChatFormatting.AQUA + "THUNDER", 2);
                if (jawbus && !lastJawbus) Utils.createTitle(EnumChatFormatting.AQUA + "JAWBUS", 2);

                lastThunder = thunder;
                lastJawbus = jawbus;
            }
        }
    }

    @SubscribeEvent
    public void onWorldChange(WorldEvent.Load event) {
        lastThunder = false;
        lastJawbus = false;
    }

}