aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/EndOfFarmAlert.java
blob: ecbf3ee967ba8726bf95e3e1a1a8f8761a2307e2 (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
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.player.EntityPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

public class EndOfFarmAlert {

    static boolean alerted = false;
    public static double min = -78.5;
    public static double max = 79.5;

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

        EntityPlayer player = Minecraft.getMinecraft().thePlayer;
        if (DankersSkyblockMod.tickAmount % 10 == 0) {
            if (ToggleCommand.endOfFarmAlert && Utils.isInScoreboard("Your Island")) {
                double x = player.posX;
                double z = player.posZ;

                if (x <= min || x >= max || z <= min || z >= max) {
                    if (!alerted) {
                        alerted = true;
                        Utils.createTitle(EnumChatFormatting.RED + "END OF FARM", 1);
                    }
                } else {
                    alerted = false;
                }
            }
        }
    }

}