aboutsummaryrefslogtreecommitdiff
path: root/util/helperFunctions.js
diff options
context:
space:
mode:
authorNinjune <enderknight537@gmail.com>2022-12-02 17:42:08 -0600
committerNinjune <enderknight537@gmail.com>2022-12-02 17:42:08 -0600
commit1d26a47068b357c4a9f4cb0225aa063134e9a0d9 (patch)
treef5d62828a9330c47f4e3675197625c464f8a9400 /util/helperFunctions.js
parent86417e52fa78ea4096a155c2e70183d34aeaf530 (diff)
downloadcoleweight-1.6.11.tar.gz
coleweight-1.6.11.tar.bz2
coleweight-1.6.11.zip
v1.6.10v1.6.11
Diffstat (limited to 'util/helperFunctions.js')
-rw-r--r--util/helperFunctions.js49
1 files changed, 45 insertions, 4 deletions
diff --git a/util/helperFunctions.js b/util/helperFunctions.js
index 2bea5d0..7a3927d 100644
--- a/util/helperFunctions.js
+++ b/util/helperFunctions.js
@@ -1,10 +1,51 @@
-/*
-Created 11/11/2022 by Ninjune.
-*/
export function addCommas(num) {
try {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
} catch (error) {
return 0;
}
-}// credit to senither for the regex, just don't care to make my own lol \ No newline at end of file
+}// credit to senither for the regex, just don't care to make my own lol
+
+
+export function waypointRender(waypoints, yellow=false)
+{
+ if(waypoints.length < 1) return
+ waypoints.forEach((waypoint) => {
+ if(yellow)
+ Tessellator.drawString(Math.floor((Math.abs(parseInt(Player.getX()) - waypoint[0]) + Math.abs(parseInt(Player.getY()) - waypoint[1]) + Math.abs(parseInt(Player.getZ()) - waypoint[2]))/3) + "m", waypoint[0], waypoint[1], waypoint[2], 0xFAFD01)
+ else
+ Tessellator.drawString(Math.floor((Math.abs(parseInt(Player.getX()) - waypoint[0]) + Math.abs(parseInt(Player.getY()) - waypoint[1]) + Math.abs(parseInt(Player.getZ()) - waypoint[2]))/3) + "m", waypoint[0], waypoint[1], waypoint[2])
+ })
+}
+
+
+export class textGui // first class I've made, gonna be dog
+// guiObject format: { leftValues: [], rightValues: [] } (must have same amount of each or error).
+{
+ constructor(guiObject, x, y)
+ {
+ this.guiObject = guiObject
+ this.x = x
+ this.y = y
+ }
+
+
+ renderGui()
+ {
+ let string = ""
+ this.guiObject.leftValues.forEach((leftValue, index) => {
+ if(leftValue == "Uptime")
+ {
+ let uptime = this.guiObject.rightValues[index],
+ uptimeHr = Math.floor(uptime/60/60)
+
+ if(uptimeHr >= 1)
+ string += `&aUptime: &b${uptimeHr}h ${Math.floor(uptime/60) - uptimeHr*60}m\n`
+ else
+ string += `&aUptime: &b${Math.floor(uptime/60)}m ${Math.floor(uptime%60)}s\n`
+ }
+ else
+ string += `&a${leftValue}: &b${this.guiObject.rightValues[index]}\n`
+ })
+ Renderer.drawStringWithShadow(string, this.x, this.y) }
+} \ No newline at end of file