-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoldenFishTimer.js
49 lines (42 loc) · 1.83 KB
/
GoldenFishTimer.js
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
import location from "../../utils/location";
import settings from "../../utils/settings"
import { BOLD, DARK_RED, GOLD, RESET, WHITE } from "../../utils/constants";
import { getTime } from "../../utils/functions/format";
import { Overlay } from "../../utils/overlay";
import { data, registerWhen } from "../../utils/variables";
/**
* Variables used to track and display fishing timer.
*/
let lastCast = 0;
let lastFish = 0;
const fishExample =
`${GOLD + BOLD}Last Cast: ${RESET}Yee
${GOLD + BOLD}Last Fish: ${RESET}Haw`;
const fishOverlay = new Overlay("goldenFishAlert", ["Crimson Isle"], () => true, data.TL, "moveGolden", fishExample);
/**
* Increments time and updates Golden Fish Overlay every second.
*/
registerWhen(register("step", () => {
lastCast += 1;
lastFish += 1;
if (lastCast > 270)
lastFish = 0;
fishOverlay.setMessage(
`${GOLD + BOLD}Last Cast: ${lastCast > 240 ? DARK_RED : WHITE + getTime(lastCast)}
${GOLD + BOLD}Last Fish: ${RESET + getTime(lastCast > 270 ? 0 : lastFish)}`);
}).setFps(1), () => location.getWorld() === "Crimson Isle" && settings.goldenFishAlert);
/**
* Resets "lastCast" variable whenever player right clicks with a fishing rod in hand.
*/
registerWhen(register("clicked", (x, y, button, state) => {
if (!button || !state || Player.getHeldItem() === null) return;
if (Player.getHeldItem().getNBT().getCompoundTag("tag").getCompoundTag("ExtraAttributes").getString("id").includes("ROD"))
lastCast = 0;
}), () => location.getWorld() === "Crimson Isle" && settings.goldenFishAlert);
/**
* Resets "lastFish" variable whenever the Golden Fish message appears in chat.
*/
registerWhen(register("chat", () => {
lastFish = 0;
}).setCriteria("You spot a Golden Fish surface from beneath the lava!"),
() => location.getWorld() === "Crimson Isle" && settings.goldenFishAlert);