diff options
Diffstat (limited to 'util/helperFunctions.js')
-rw-r--r-- | util/helperFunctions.js | 49 |
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 |