diff options
author | Ninjune x <enderknight537@gmail.com> | 2022-11-29 21:19:03 -0600 |
---|---|---|
committer | Ninjune x <enderknight537@gmail.com> | 2022-11-29 21:19:03 -0600 |
commit | ad055ba90a3055db32f04ff5163ff4e1c85dfdfa (patch) | |
tree | aee8962d031dffddd27fa702262a0ef7c66c08ce | |
parent | 00f4ecbc69216d4aee44bcdac92955c4eb774298 (diff) | |
download | coleweight-ad055ba90a3055db32f04ff5163ff4e1c85dfdfa.tar.gz coleweight-ad055ba90a3055db32f04ff5163ff4e1c85dfdfa.tar.bz2 coleweight-ad055ba90a3055db32f04ff5163ff4e1c85dfdfa.zip |
-rw-r--r-- | chat/message.js | 46 | ||||
-rw-r--r-- | commandManager.js | 37 | ||||
-rw-r--r-- | commands/claim.js | 50 | ||||
-rw-r--r-- | commands/divans.js | 83 | ||||
-rw-r--r-- | commands/grieferList.js | 23 | ||||
-rw-r--r-- | commands/help.js | 49 | ||||
-rw-r--r-- | commands/leaderboard.js | 14 | ||||
-rw-r--r-- | commands/markingLobbies.js | 17 | ||||
-rw-r--r-- | commands/spiral.js | 51 | ||||
-rw-r--r-- | commands/throne.js | 46 | ||||
-rw-r--r-- | commands/yog.js | 62 | ||||
-rw-r--r-- | index.js | 25 | ||||
-rw-r--r-- | metadata.json | 6 | ||||
-rw-r--r-- | render/bobombOverlay.js | 22 | ||||
-rw-r--r-- | render/coordsGui.js | 96 | ||||
-rw-r--r-- | render/downtimeGui.js | 85 | ||||
-rw-r--r-- | render/naturals.js | 39 | ||||
-rw-r--r-- | settings.js | 91 | ||||
-rw-r--r-- | util/constants.js | 6 | ||||
-rw-r--r-- | util/helperFunctions.js | 49 |
20 files changed, 748 insertions, 149 deletions
diff --git a/chat/message.js b/chat/message.js index 333b823..79b6be1 100644 --- a/chat/message.js +++ b/chat/message.js @@ -22,17 +22,12 @@ register("chat", (level, typeOfChat, hypixelRank, username, playerMessage, event if(!onward || cwlbData == undefined) return cwlbPlayerData = cwlbData.filter(player => player.name == username)[0] if(cwlbPlayerData == undefined) return - cancel(event) newMessage = new Message() message = ChatLib.getChatMessage(event, true), messagePrefix = message + cancel(event) - if(cwlbPlayerData.rank > 0 && cwlbPlayerData.rank < 501) - messagePrefix = message.slice(0, message.indexOf(':')) + ` &8[&6#${addCommas(cwlbPlayerData.rank)}&8]&f: ` - else if(hypixelRank == "" && typeOfChat == "") - messagePrefix = message.slice(0, message.indexOf(':')) + `&7: ` - else - messagePrefix = message.slice(0, message.indexOf(':')) + `&f: ` + messagePrefix = message.slice(0, message.indexOf(':')) + ` &8[&6#${addCommas(cwlbPlayerData.rank)}&8]&f: ` newMessage.addTextComponent(messagePrefix) @@ -45,8 +40,43 @@ register("chat", (level, typeOfChat, hypixelRank, username, playerMessage, event ChatLib.chat(newMessage) }).setCriteria(/^(\[\d+\] )?((?:(?:Guild|Party|Co-op) > )|(?:\[:v:\] ))?(\[\w+\+{0,2}\] )?(\w{1,16})(?: \[\w{1,6}\])?: (.*)$/g) +register("messageSent", (origMessage, event) => { // emotes! this was fun to make :) + let commandState = 0, + command = "", + colonIndex1 = -1, + message = "" + + for(let charIndex = 0; charIndex < origMessage.length; charIndex++) + { + if(origMessage[charIndex] == ":" && commandState == 0) + { + colonIndex1 = charIndex + commandState = 1 + } + else if (origMessage[charIndex] == ":" && commandState == 1) + { + commandState = 2 + command = origMessage.slice(colonIndex1 + 1, charIndex).toLowerCase() + } + } + if(command == "shrug") + { + cancel(event) + emote = "¯\\_(ツ)_/¯" + } + else if (command == "lenny") + { + cancel(event) + emote = "( ͡° ͜ʖ ͡°)" + } + else + return + message = origMessage.slice(0, colonIndex1) + emote + origMessage.slice(colonIndex1 + 2 + command.length, origMessage.length) + ChatLib.say(`${message}`) +}) + register("worldLoad", () => { - axios.get(`https://ninjune.dev/api/coleweight-leaderboard`) + axios.get(`https://ninjune.dev/api/coleweight-leaderboard?length=500`) .then(res => { cwlbData = res.data }) diff --git a/commandManager.js b/commandManager.js index 66b05e3..cf28a8c 100644 --- a/commandManager.js +++ b/commandManager.js @@ -1,12 +1,15 @@ import { openTimerGui } from "./render/timerGui.js" import { openPowderGui } from "./render/powertrackerGui" +import { openCoordsGui } from "./render/coordsGui.js" +import { openDowntimeGui } from "./render/downtimeGui.js" import { openCwGui } from "./render/cwGui" -import { help } from "./commands/help.js" -import { reload } from "./commands/reload.js" -import { setkey } from "./commands/setkey.js" -import { spiral } from "./commands/spiral.js" -import { throne } from "./commands/throne.js" -import { leaderboard } from "./commands/leaderboard.js" +import { help } from "./commands/help" +import { reload } from "./commands/reload" +import { setkey } from "./commands/setkey" +import { spiral } from "./commands/spiral" +import { throne } from "./commands/throne" +import { yog } from "./commands/yog" +import { leaderboard } from "./commands/leaderboard" import { update } from "./commands/update" import { fetchDiscord } from "./commands/fetchDiscord" import { findColeweight } from "./commands/findColeweight" @@ -16,6 +19,8 @@ import { time } from "./commands/time" import { info } from "./commands/info" import Settings from "./settings" import constants from "./util/constants" +import { clearLobbies } from "./commands/markingLobbies" +import { divans } from "./commands/divans.js" register("command", (arg, arg2, arg3) => { if (arg == undefined) {findColeweight(arg); return} @@ -41,6 +46,9 @@ register("command", (arg, arg2, arg3) => { case "timer": openTimerGui() break + case "downtime": + openDowntimeGui() + break default: ChatLib.chat(`${constants.PREFIX}&cNo such gui as '${arg2}'.`) } @@ -79,12 +87,27 @@ register("command", (arg, arg2, arg3) => { case "info": info() break + case "clearlobbies": + clearLobbies() + break + case "yog": + yog(arg2) + break + case "divans": + case "divan": + divans(arg2) + break + case "coord": + case "coords": + openCoordsGui() + break default: findColeweight(arg) } }).setTabCompletions((args) => { let output = [], - commands = ["setkey", "help", "move", "toggle", "throne", "spiral", "reload", "leaderboard", "settings", "claim", "tick", "time", "info"] + commands = ["setkey", "help", "move", "toggle", "throne", "spiral", "reload", "leaderboard", + "settings", "claim", "tick", "time", "info", "clearlobbies", "yog", "divan", "coords"] if(args[0].length == 0 || args[0] == undefined) output = commands diff --git a/commands/claim.js b/commands/claim.js index d549056..ae20924 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -2,7 +2,7 @@ import axios from "../../axios" import settings from "../settings" import constants from "../util/constants" const PREFIX = constants.PREFIX - +const serverId = java.util.UUID.randomUUID().toString().replace("-", "") export function claim(structure) { @@ -23,35 +23,56 @@ export function claim(structure) ChatLib.chat(`${PREFIX}&cPlease enter the structure you wish to claim! (&3throne&c or &3spiral&c)`) return } - - axios.get(`https://ninjune.dev/api/claim?type=${structure}&id=${constants.serverData.server}&key=${constants.data.api_key}`) + + axios.get(`https://ninjune.dev/api/claim?type=${structure}&lobby=${constants.serverData.server}&username=${Player.getName()}&serverID=${serverId}`) .then(res => { if(res.data.success) ChatLib.chat(`${PREFIX}&aSuccessfully claimed ${constants.serverData.server} as your server!`) else - ChatLib.chat(`${PREFIX}&cError: ${res.data.reason}`) + { + ChatLib.chat(`${PREFIX}&cError: ${res.data.reason}.`) + if(res.data.code == 501) + { + ChatLib.chat(`${PREFIX}&cError: Not logged into the auth server. Try running the command again.`) + Client.getMinecraft().func_152347_ac().joinServer(Client.getMinecraft().func_110432_I().func_148256_e(), Client.getMinecraft().func_110432_I().func_148254_d(), serverId) + } + } }) .catch(err => { ChatLib.chat(`${PREFIX}&cError: ${err}`) }) - // key is used above to verify that the player trying to claim the lobby is the intended player, don't know a better way of doing this. + } +register('gameLoad', (event) => { + Client.getMinecraft().func_152347_ac().joinServer(Client.getMinecraft().func_110432_I().func_148256_e(), Client.getMinecraft().func_110432_I().func_148254_d(), serverId) +}) register('worldLoad', () => { if(!settings.claiming) return - + axios.get(`https://ninjune.dev/api/unclaim?username=${Player.getName()}&serverID=${serverId}`) + .then(res => { + if(settings.debug && !res.data.success) + ChatLib.chat("Unclaim: " + res.data.reason) + if(res.data.code == 501) + Client.getMinecraft().func_152347_ac().joinServer(Client.getMinecraft().func_110432_I().func_148256_e(), Client.getMinecraft().func_110432_I().func_148254_d(), serverId) + }) + .catch(err => { + if(settings.debug) + ChatLib.chat(`${PREFIX}&cError: ${err}`) + }) + // unclaims the lobby, isn't needed but will allow another player to claim lobby after claimer leaves. setTimeout(() => { const NetHandlerPlayClient = Client.getConnection(), - PlayerMap = NetHandlerPlayClient.func_175106_d() // getPlayerInfoMap + PlayerMap = NetHandlerPlayClient.func_175106_d() // getPlayerInfoMap if(settings.debug) console.log(constants.serverData.server) - axios.get(`https://ninjune.dev/api/claim?claimedlobby=${constants.serverData.server}`) + axios.get(`https://ninjune.dev/api/claimed?serverID=${constants.serverData.server}&authServer=${serverId}&passedName=${Player.getName()}`) .then(res => { if(res.data.claimed) { - PlayerMap.filter(player => player.func_178853_c() > 0 && !player.func_178845_a().name.startsWith("!")).forEach((PlayerMP) => { - let player = PlayerMP.func_178845_a().name + PlayerMap.filter(player => player.func_178853_c() /* getResponseTime */ > 0 && !player.func_178845_a()/* getGameProfile */.name.startsWith("!")).forEach((PlayerMP) => { + let player = PlayerMP.func_178845_a()/* getGameProfile */.name res.data.structures.forEach((structure) => { if (player == structure.player) @@ -60,15 +81,14 @@ register('worldLoad', () => { }) }) } + else if (res.data.err && settings.debug) + { + ChatLib.chat("Check claim: " + res.data.reason) + } }) .catch(err => { if(!settings.debug) return ChatLib.chat(`${PREFIX}&cError: ${err}`) }) }, 2000) -}) - -register('worldUnload', () => { - axios.get(`https://ninjune.dev/api/unclaim?claimedlobby=${constants.serverData.server}&key=${constants.data.api_key}`) - // unclaims the lobby, isn't needed but will allow another player to claim lobby after claimer leaves. key used to verify identity of unclaimer. })
\ No newline at end of file diff --git a/commands/divans.js b/commands/divans.js new file mode 100644 index 0000000..c5e618a --- /dev/null +++ b/commands/divans.js @@ -0,0 +1,83 @@ +import constants from "../util/constants" +import { waypointRender } from "../util/helperFunctions" + +const PREFIX = constants.PREFIX +let divanWaypoints = [] + +export function divans(arg2) +{ + const WAYPOINTNAME = "Divan" + + if(arg2 != "toggle") + { + new TextComponent(`${PREFIX}&bGo to the middle of jade crystal then do /cw coords divans toggle.`) + .chat() + } + else + { + if(divanWaypoints[0] == undefined) + { + let startPos = [Player.getX(), Player.getY(), Player.getZ()], + x = startPos[0], + y = startPos[1], + z = startPos[2] + + console.log(x + " " + y + " " + z) + divanWaypoints.push([x + 1, y + -40, z + -20]) + divanWaypoints.push([x + 30, y + -39, z + -25]) + divanWaypoints.push([x + -31, y + -39, z + -12]) + divanWaypoints.push([x + 1, y + -39, z + 20]) + divanWaypoints.push([x + -14, y + -39, z + 43]) + divanWaypoints.push([x + -12, y + -39, z + -44]) + divanWaypoints.push([x + -20, y + -40, z + 0]) + divanWaypoints.push([x + 22, y + -39, z + -14]) + divanWaypoints.push([x + 29, y + -39, z + -44]) + divanWaypoints.push([x + 12, y + -39, z + 7]) + divanWaypoints.push([x + 23, y + -40, z + -39]) + divanWaypoints.push([x + -37, y + -39, z + 11]) + divanWaypoints.push([x + 7, y + -39, z + 11]) + divanWaypoints.push([x + 6, y + -39, z + 11]) + divanWaypoints.push([x + -38, y + -40, z + 26]) + divanWaypoints.push([x + 12, y + -40, z + -22]) + divanWaypoints.push([x + -5, y + -39, z + 16]) + divanWaypoints.push([x + 40, y + -40, z + -30]) + divanWaypoints.push([x + 42, y + -37, z + -41]) + divanWaypoints.push([x + -23, y + -40, z + 40]) + divanWaypoints.push([x + 20, y + -40, z + 0]) + divanWaypoints.push([x + -24, y + -40, z + 12]) + divanWaypoints.push([x + 38, y + -40, z + -26]) + divanWaypoints.push([x + 43, y + -39, z + -16]) + divanWaypoints.push([x + -40, y + -40, z + 18]) + divanWaypoints.push([x + -17, y + -39, z + 20]) + divanWaypoints.push([x + 19, y + -40, z + 29]) + divanWaypoints.push([x + -37, y + -39, z + -14]) + divanWaypoints.push([x + -14, y + -39, z + 22]) + divanWaypoints.push([x + -42, y + -38, z + -28]) + divanWaypoints.push([x + -43, y + -40, z + -40]) + divanWaypoints.push([x + 25, y + -40, z + 17]) + divanWaypoints.push([x + 12, y + -40, z + 31]) + divanWaypoints.push([x + -31, y + -39, z + -40]) + divanWaypoints.push([x + -36, y + -38, z + 42]) + divanWaypoints.push([x + 7, y + -39, z + 22]) + divanWaypoints.push([x + 20, y + -39, z + -26]) + divanWaypoints.push([x + 12, y + -39, z + -43]) + ChatLib.chat(`${PREFIX}&b${WAYPOINTNAME} waypoints turned on!`) + } + else + { + divanWaypoints = [] + ChatLib.chat(`${PREFIX}&b${WAYPOINTNAME} waypoints turned off!`) + } + } +} + +register("renderWorld", () => { + waypointRender(divanWaypoints) +}) + + +register("worldLoad", () => { + divanWaypoints = [] +}) + +export default ""
\ No newline at end of file diff --git a/commands/grieferList.js b/commands/grieferList.js new file mode 100644 index 0000000..0762f8e --- /dev/null +++ b/commands/grieferList.js @@ -0,0 +1,23 @@ +/*import settings from "../settings" // future +import constants from "../util/constants" +const PREFIX = constants.PREFIX + +export function grieferList(arg2, arg3) +{ + switch(arg2) + { + case "list": + break + case "add": + let griefers = JSON.parse(FileLib.read("Coleweight", "config/grieferlist.txt")) + griefers.push({griefers: [name]}) + FileLib.write("Coleweight", "config/grieferlist.txt", `${JSON.stringify(griefers)}`) + ChatLib.chat(`${PREFIX}&aAdded ${arg3} to griefer list!`) + break + case "remove": + break + default: + ChatLib.chat(`${PREFIX}&cArgument '${arg2 ?? ""}' not found`) + break + } +}*/
\ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 3c20b01..05c5a04 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,21 +1,34 @@ -import constants from "../util/constants" -const PREFIX = constants.PREFIX +const PREFIX = "◆" export function help() { - ChatLib.chat("") - ChatLib.chat(`${PREFIX}&b/cw [username] => Gets coleweight`) - ChatLib.chat(`${PREFIX}&b/cw help => This menu.`) - ChatLib.chat(`${PREFIX}&b/cw settings => Open settings.`) - ChatLib.chat(`${PREFIX}&b/cw time => Prints time on timer (timer gui doesn't have to be visible).`) - ChatLib.chat(`${PREFIX}&b/cw tick <mining speed> <('r','jade', etc) || breaking power of block> => Shows tick data.`) - ChatLib.chat(`${PREFIX}&b/cw info => Prints coleweight info.`) - ChatLib.chat(`${PREFIX}&b/cw claim <throne || spiral> => Claims a chollows sapphire structure in a lobby.`) - ChatLib.chat(`${PREFIX}&b/cw setkey <key> => Sets API key (can also use /api new)`) - ChatLib.chat(`${PREFIX}&b/cw reload => Reloads the gui.`) - ChatLib.chat(`${PREFIX}&b/cw throne => Guide for setting up waypoints for throne.`) - ChatLib.chat(`${PREFIX}&b/cw spiral => Guide for setting up waypoints for spiral.`) - ChatLib.chat(`${PREFIX}&b/cw leaderboard => Gets leaderboard within a specific range (like 20 40)`) - ChatLib.chat(`${PREFIX}&b/fetchdiscord (username) => Gets discord of username (if linked)`) - ChatLib.chat("") -}
\ No newline at end of file + ChatLib.chat("&b--------------[ &a&lColeweight &b]--------------") + ChatLib.chat(ChatLib.getCenteredText("&a&lInfo")) + helpCommand("", "Gets Coleweight of specified user", "(username)") + helpCommand("help", "This menu.", "") + helpCommand("time", "Prints time on timer (timer gui doesn't have to be visible).", "") + helpCommand("tick", "Shows tick data.", "(mining speed) (('r','jade', etc) || breaking power of block))") + helpCommand("leaderboard", "Shows leaderboard.", "(min) [max]") + helpCommand("info", "Prints coleweight info.", "") + ChatLib.chat(ChatLib.getCenteredText("&a&lSettings")) + helpCommand("settings", "Opens settings.", "") + helpCommand("claim", "Claims a chollows sapphire structure in a lobby.", "(throne || spiral)") + helpCommand("setkey", "Sets API key (can also use /api new)-", "(key)") + helpCommand("reload", "Reloads the gui.", "") + ChatLib.chat(ChatLib.getCenteredText("&a&lWaypoints")) + helpCommand("coords", "Opens coords gui.", "") + helpCommand("throne", "Guide for setting up waypoints for throne.", "[toggle]") + helpCommand("spiral", "Guide for setting up waypoints for spiral", "[toggle]") + helpCommand("yog", "Shows instructions for yog waypoints.", "[toggle]") + helpCommand("divans", "Guide for setting up waypoints for Mines of Divan treasures.", "[toggle]") + ChatLib.chat(ChatLib.getCenteredText("&a&lMiscellaneous")) + ChatLib.chat(`&a${PREFIX} /fetchdiscord (username) => &bGets discord of username (if linked)`) + ChatLib.chat("&b------------------------------------------") +} + +// Made by Almighty Stylla <3 +function helpCommand(command, desc, usage) +{ + ChatLib.chat(new TextComponent(`&a${PREFIX} /cw ${command} => &b${desc}`).setHoverValue(`${"/cw " + command + " " + usage}`)) +} + diff --git a/commands/leaderboard.js b/commands/leaderboard.js index 2b2699f..80a3448 100644 --- a/commands/leaderboard.js +++ b/commands/leaderboard.js @@ -4,13 +4,13 @@ const PREFIX = constants.PREFIX export function leaderboard(arg2, arg3) { - if(arg2 != undefined && parseInt(arg2) == arg2 && !isNaN(parseInt(arg2, 10))) + if(arg2 != undefined && parseInt(arg2) == arg2 && !isNaN(parseInt(arg2))) { - if(arg3 == undefined && parseInt(arg2) == arg2 && !isNaN(parseInt(arg2, 10))) + if(arg3 == undefined && parseInt(arg2) == arg2 && !isNaN(parseInt(arg2))) { - axios.get(`https://ninjune.dev/api/coleweight-leaderboard`) + axios.get(`https://ninjune.dev/api/coleweight-leaderboard?length=${arg2}`) .then(res => { - for(let i = 0; i < arg2; i++) + for(let i = 0; i < res.data.length; i++) { ChatLib.chat(`&a${res.data[i].rank}. &b${res.data[i].name}: &f${res.data[i].coleweight}`) } @@ -19,11 +19,11 @@ export function leaderboard(arg2, arg3) ChatLib.chat(`${PREFIX}&4Error! &eApi might be down.`) }) } - else if(parseInt(arg3) == arg3 && !isNaN(parseInt(arg3, 10))) + else if(parseInt(arg3) == arg3 && !isNaN(parseInt(arg3))) { - axios.get(`https://ninjune.dev/api/coleweight-leaderboard`) + axios.get(`https://ninjune.dev/api/coleweight-leaderboard?length=${arg3}`) .then(res => { - for(let i = arg2 - 1; i < arg3; i++) + for(let i = arg2 - 1; i < res.data.length; i++) { ChatLib.chat(`&a${res.data[i].rank}. &b${res.data[i].name}: &f${res.data[i].coleweight}`) } diff --git a/commands/markingLobbies.js b/commands/markingLobbies.js new file mode 100644 index 0000000..6db976e --- /dev/null +++ b/commands/markingLobbies.js @@ -0,0 +1,17 @@ +import settings from "../settings" +import constants from "../util/constants" +const PREFIX = constants.PREFIX +let lobbies = [] + +export function clearLobbies() +{ + lobbies = [] +} + +register('chat', (server) => { + if(!settings.lobbyMarking) return + if(lobbies.indexOf(server) > 0) + ChatLib.chat(`${PREFIX}&aYou've been in this lobby!`) + else + lobbies.push(server) +}).setCriteria(/Sending to server ([A-Za-z0-9]+)\.\.\./g)
\ No newline at end of file diff --git a/commands/spiral.js b/commands/spiral.js index 122ee08..6574f18 100644 --- a/commands/spiral.js +++ b/commands/spiral.js @@ -1,5 +1,8 @@ import constants from "../util/constants" +import { waypointRender } from "../util/helperFunctions" + const PREFIX = constants.PREFIX +let spiralWaypoints = [] export function spiral(arg2) { @@ -12,31 +15,41 @@ export function spiral(arg2) } else { - if(constants.spiralValues[0] == undefined) + if(spiralWaypoints[0] == undefined) { let startPos = [Player.getX(), Player.getY(), Player.getZ()] - constants.spiralValues.push([startPos[0]+2, startPos[1]-3, startPos[2]+14]) - constants.spiralValues.push([startPos[0]+3, startPos[1]-21, startPos[2]+6]) - constants.spiralValues.push([startPos[0]+6, startPos[1]-23, startPos[2]-1]) - constants.spiralValues.push([startPos[0]+19, startPos[1]+4, startPos[2]-5]) - constants.spiralValues.push([startPos[0]+21, startPos[1]-7, startPos[2]]) - constants.spiralValues.push([startPos[0]+25, startPos[1]-35, startPos[2]-8]) - constants.spiralValues.push([startPos[0]+39, startPos[1]-36, startPos[2]]) - constants.spiralValues.push([startPos[0]+52, startPos[1]-24, startPos[2]+1]) - constants.spiralValues.push([startPos[0]+48, startPos[1]+3, startPos[2]+3]) - constants.spiralValues.push([startPos[0]+47, startPos[1]+4, startPos[2]+22]) - constants.spiralValues.push([startPos[0]+55, startPos[1]-8, startPos[2]+42]) - constants.spiralValues.push([startPos[0]+46, startPos[1]-11, startPos[2]+49]) - constants.spiralValues.push([startPos[0]+26, startPos[1]+5, startPos[2]+39]) - constants.spiralValues.push([startPos[0]+20, startPos[1]+3, startPos[2]+41]) - constants.spiralValues.push([startPos[0]+8, startPos[1]-23, startPos[2]+32]) - constants.spiralValues.push([startPos[0]+4, startPos[1]-23, startPos[2]+28]) + spiralWaypoints.push([startPos[0]+2, startPos[1]-3, startPos[2]+14]) + spiralWaypoints.push([startPos[0]+3, startPos[1]-21, startPos[2]+6]) + spiralWaypoints.push([startPos[0]+6, startPos[1]-23, startPos[2]-1]) + spiralWaypoints.push([startPos[0]+19, startPos[1]+4, startPos[2]-5]) + spiralWaypoints.push([startPos[0]+21, startPos[1]-7, startPos[2]]) + spiralWaypoints.push([startPos[0]+25, startPos[1]-35, startPos[2]-8]) + spiralWaypoints.push([startPos[0]+39, startPos[1]-36, startPos[2]]) + spiralWaypoints.push([startPos[0]+52, startPos[1]-24, startPos[2]+1]) + spiralWaypoints.push([startPos[0]+48, startPos[1]+3, startPos[2]+3]) + spiralWaypoints.push([startPos[0]+47, startPos[1]+4, startPos[2]+22]) + spiralWaypoints.push([startPos[0]+55, startPos[1]-8, startPos[2]+42]) + spiralWaypoints.push([startPos[0]+46, startPos[1]-11, startPos[2]+49]) + spiralWaypoints.push([startPos[0]+26, startPos[1]+5, startPos[2]+39]) + spiralWaypoints.push([startPos[0]+20, startPos[1]+3, startPos[2]+41]) + spiralWaypoints.push([startPos[0]+8, startPos[1]-23, startPos[2]+32]) + spiralWaypoints.push([startPos[0]+4, startPos[1]-23, startPos[2]+28]) ChatLib.chat(`${PREFIX}&bSpiral waypoints turned on!`) } else { - constants.spiralValues = [] + spiralWaypoints = [] ChatLib.chat(`${PREFIX}&bSpiral waypoints turned off!`) } } -}
\ No newline at end of file +} + +register("renderWorld", () => { + waypointRender(spiralWaypoints, true) +}) + +register("worldLoad", () => { + spiralWaypoints = [] +}) + +export default ""
\ No newline at end of file diff --git a/commands/throne.js b/commands/throne.js index 717ba3c..517c93d 100644 --- a/commands/throne.js +++ b/commands/throne.js @@ -1,5 +1,9 @@ import constants from "../util/constants" +import { waypointRender } from "../util/helperFunctions" + const PREFIX = constants.PREFIX +let throneWaypoints = [] + export function throne(arg2) { @@ -9,28 +13,38 @@ export function throne(arg2) } else { - if(constants.throneValues[0] == undefined) + if(throneWaypoints[0] == undefined) { let startPos = [Player.getX()-24, Player.getY()+6, Player.getZ()-59] // calculated below values at a weird start so adjusting them - constants.throneValues.push([startPos[0]+8, startPos[1]+2, startPos[2]-5]) - constants.throneValues.push([startPos[0]+11, startPos[1]-35, startPos[2]-3]) - constants.throneValues.push([startPos[0]+2, startPos[1]-34, startPos[2]-4]) - constants.throneValues.push([startPos[0]+-2, startPos[1]-1, startPos[2]+49]) - constants.throneValues.push([startPos[0]+2, startPos[1]-13, startPos[2]+52]) - constants.throneValues.push([startPos[0]+27, startPos[1]-9, startPos[2]+51]) - constants.throneValues.push([startPos[0]+38, startPos[1]-15, startPos[2]+47]) - constants.throneValues.push([startPos[0]+41, startPos[1]-44, startPos[2]+46]) - constants.throneValues.push([startPos[0]+50, startPos[1]-28, startPos[2]+38]) - constants.throneValues.push([startPos[0]+55, startPos[1]-36, startPos[2]+29]) - constants.throneValues.push([startPos[0]+49, startPos[1]-31, startPos[2]+1]) - constants.throneValues.push([startPos[0]+50, startPos[1]-1, startPos[2]+10]) - constants.throneValues.push([startPos[0]+45, startPos[1]-3, startPos[2]-4]) + throneWaypoints.push([startPos[0]+8, startPos[1]+2, startPos[2]-5]) + throneWaypoints.push([startPos[0]+11, startPos[1]-35, startPos[2]-3]) + throneWaypoints.push([startPos[0]+2, startPos[1]-34, startPos[2]-4]) + throneWaypoints.push([startPos[0]+-2, startPos[1]-1, startPos[2]+49]) + throneWaypoints.push([startPos[0]+2, startPos[1]-13, startPos[2]+52]) + throneWaypoints.push([startPos[0]+27, startPos[1]-9, startPos[2]+51]) + throneWaypoints.push([startPos[0]+38, startPos[1]-15, startPos[2]+47]) + throneWaypoints.push([startPos[0]+41, startPos[1]-44, startPos[2]+46]) + throneWaypoints.push([startPos[0]+50, startPos[1]-28, startPos[2]+38]) + throneWaypoints.push([startPos[0]+55, startPos[1]-36, startPos[2]+29]) + throneWaypoints.push([startPos[0]+49, startPos[1]-31, startPos[2]+1]) + throneWaypoints.push([startPos[0]+50, startPos[1]-1, startPos[2]+10]) + throneWaypoints.push([startPos[0]+45, startPos[1]-3, startPos[2]-4]) ChatLib.chat(`${PREFIX}&bThrone waypoints turned on!`) } else { - constants.throneValues = [] + throneWaypoints = [] ChatLib.chat(`${PREFIX}&bThrone waypoints turned off!`) } } -}
\ No newline at end of file +} + + +register("renderWorld", () => { + waypointRender(throneWaypoints, true) +}) + + +register("worldLoad", () => { + throneWaypoints = [] +}) diff --git a/commands/yog.js b/commands/yog.js new file mode 100644 index 0000000..1544553 --- /dev/null +++ b/commands/yog.js @@ -0,0 +1,62 @@ +import constants from "../util/constants" +import { waypointRender } from "../util/helperFunctions" + +const PREFIX = constants.PREFIX +let yogWaypoints = [] + +export function yog(arg2) +{ + const WAYPOINTNAME = "Yog" + + if(arg2 != "toggle") + { + new TextComponent(`${PREFIX}&bGo to the leftmost corner of the topaz crystal facing bal close to bal then do /cw coords yog toggle.`) + .chat() + } + else + { + if(yogWaypoints[0] == undefined) + { + let startPos = [Player.getX(), Player.getY(), Player.getZ()], + x = startPos[0], + y = startPos[1], + z = startPos[2] + + console.log(x + " " + y + " " + z) + yogWaypoints.push([x + 10, y - 7, z - 27]) + yogWaypoints.push([x + 10, y - 7, z - 27]) + yogWaypoints.push([x + 28, y - 8, z + 15]) + yogWaypoints.push([x - 41, y - 3, z + 26]) + yogWaypoints.push([x - 32, y - 3, z + 45]) + yogWaypoints.push([x - 22, y - 3, z - 34]) + yogWaypoints.push([x + 28, y - 8, z + 36]) + yogWaypoints.push([x - 47, y - 3, z + 32]) + yogWaypoints.push([x - 43, y - 1, z + 4]) + yogWaypoints.push([x - 47, y + 2, z - 20]) + yogWaypoints.push([x + 11, y - 13, z + 40]) + yogWaypoints.push([x + 15, y - 13, z + 43]) + yogWaypoints.push([x - 44, y + 2, z - 29]) + yogWaypoints.push([x + 33, y - 4, z - 15]) + yogWaypoints.push([x - 6, y - 4, z - 34]) + yogWaypoints.push([x + 19, y - 12, z + 35]) + yogWaypoints.push([x + 16, y - 9, z - 15]) + ChatLib.chat(`${PREFIX}&b${WAYPOINTNAME} waypoints turned on!`) + } + else + { + yogWaypoints = [] + ChatLib.chat(`${PREFIX}&b${WAYPOINTNAME} waypoints turned off!`) + } + } +} + +register("renderWorld", () => { + if(yogWaypoints.length < 1) return + waypointRender(yogWaypoints) +}) + +register("worldLoad", () => { + yogWaypoints = [] +}) + +export default ""
\ No newline at end of file @@ -1,8 +1,9 @@ +import './render/naturals' +import './render/tabList' +import './commands/yog' import './chat/apiNew' import './chat/message' - import './chat/serverdata' -import './render/tabList' import './commandManager' import './util/updater' import './util/grieferTrack' @@ -10,26 +11,6 @@ import axios from '../axios' import constants from './util/constants'; const PREFIX = constants.PREFIX -//world update (coords) -register("renderWorld", () => { - if(constants.throneValues[0] != undefined) - { - for(let i = 0; i < constants.throneValues.length; i++) - { - Tessellator.drawString(i+1, constants.throneValues[i][0], constants.throneValues[i][1], constants.throneValues[i][2]) - } - } - if(constants.spiralValues[0] != undefined) - { - for(let i = 0; i < constants.spiralValues.length; i++) - { - Tessellator.drawString(i+1, constants.spiralValues[i][0], constants.spiralValues[i][1], constants.spiralValues[i][2]) - } - } - -}) - - //update every second (dogshit code) register("step", () => { // first time check diff --git a/metadata.json b/metadata.json index 10fa70f..e177ffb 100644 --- a/metadata.json +++ b/metadata.json @@ -2,7 +2,7 @@ "name": "Coleweight", "creator": "Ninjune", "entry": "index.js", - "description": "Simple Coleweight module to measure mining progression.", - "version": "1.6.3", - "requires": ["axios", "PogData", "Vigilance"] + "description": "Mining utilities.", + "version": "1.6.9", + "requires": ["axios", "PogData", "Vigilance", "Elementa"] }
\ No newline at end of file diff --git a/render/bobombOverlay.js b/render/bobombOverlay.js deleted file mode 100644 index 02526bd..0000000 --- a/render/bobombOverlay.js +++ /dev/null @@ -1,22 +0,0 @@ -/*import RenderLib from "../../RenderLib/index.js"; -Disabled. -register('renderWorld', () => { - try{ - if(Player.getHeldItem().getItemNBT().getTag('tag').getTag('ExtraAttributes').getTag("id").toString() != `"BOB_OMB"`) return - } catch(e) {return} - - const boxR = 0.3, - boxB = 0.5, - boxG = 0, - boxAlpha = 0.3 - - let x = Math.floor(Player.getX()) + 0.5, - y = Math.floor(Player.getY()) - z = Math.floor(Player.getZ()) + 0.5 - - - - RenderLib.drawInnerEspBox(x, y - 1, z - 8, 1, 1, boxR, boxB, boxG, boxAlpha, true) - RenderLib.drawInnerEspBox(x + 1, y + 1, z - 7, 1, 1, boxR, boxB, boxG, boxAlpha, true) - RenderLib.drawInnerEspBox(x + 1, y + 1, z - 7, 1, 1, boxR, boxB, boxG, boxAlpha, true) -})*/
\ No newline at end of file diff --git a/render/coordsGui.js b/render/coordsGui.js new file mode 100644 index 0000000..9fd5f43 --- /dev/null +++ b/render/coordsGui.js @@ -0,0 +1,96 @@ +import { + AdditiveConstraint, + animate, + Animations, + CenterConstraint, + ChildBasedMaxSizeConstraint, + ChildBasedSizeConstraint, + ConstantColorConstraint, + FillConstraint, + MaxConstraint, + ScissorEffect, + SiblingConstraint, + SubtractiveConstraint, + UIBlock, + UIImage, + UIWrappedText, + UIMultilineTextInput, + UIText, + WindowScreen, + } from "../../Elementa" + +// stylla made 2 lines of code (gamer) +const Color = Java.type("java.awt.Color"), + URL = Java.type("java.net.URL"), + WIDTH = 3.5, // not actually width more like reverse of width lmao, bigger = smaller + HEIGHT = 2.877 // ^ +let ScreenW = Renderer.screen.getWidth(), + ScreenH = Renderer.screen.getHeight() + +function coordsWindow(row, column, title, command, desc, image=false, alternateText="") +{ + const coordWindow = new UIBlock(new Color(0, 0, 0, 0.5)) // 320 960 + .setX(((ScreenW/3*(column))-ScreenW/3.25).pixels()) + .setY((ScreenH/2*(row-1)+ScreenH/10.8).pixels()) + .setWidth((ScreenW/WIDTH).pixels()) + .setHeight((ScreenH/HEIGHT).pixels()) + .onMouseClick(() => { + ChatLib.command(command, true) + }) + new UIText(title, false) + .setX(new CenterConstraint()) + .setY((2).pixels()) + .setTextScale((2).pixels()) + .setColor(new ConstantColorConstraint(Color.GREEN.darker())) + .setChildOf(coordWindow) + if(image == true) + { + new UIWrappedText(alternateText) + .setX((12).pixels()) + .setY((25).pixels()) + .setWidth((ScreenW/5).pixels()) + .setTextScale((1).pixels()) + .setColor(new ConstantColorConstraint(Color.WHITE)) + .setChildOf(coordWindow) + new UIImage.ofURL(new URL(desc)) + .setX(new CenterConstraint()) + .setY(new AdditiveConstraint(new CenterConstraint(), (4).pixels())) + .setWidth((ScreenW/3.7).pixels()) + .setHeight((ScreenH/3.7).pixels()) + .setChildOf(coordWindow) + } + else + { + new UIWrappedText(desc) + .setX((2).pixels()) + .setY((25).pixels()) + .setWidth((ScreenW/3.7).pixels()) + .setTextScale((1).pixels()) + .setColor(new ConstantColorConstraint(Color.WHITE)) + .setChildOf(coordWindow) + } + + return coordWindow +} + +export function openCoordsGui() +{ + ScreenW = Renderer.screen.getWidth() + ScreenH = Renderer.screen.getHeight() + const CoordsGui = new JavaAdapter(WindowScreen, { + init() { + coordsWindow(1, 1, "Spiral", "cw spiral toggle", "https://i.imgur.com/dyL30GD.png", true, "Do /cw spiral to see image. (image isn't loading.)").setChildOf(this.getWindow()) + coordsWindow(1, 2, "Throne", "cw throne toggle", "https://i.imgur.com/7BWzO1c.jpg", true, "Go back of throne. (image isn't loading)").setChildOf(this.getWindow()) + coordsWindow(1, 3, "Yog", "cw yog toggle", "https://i.imgur.com/DojoypL.jpg", true, "Go to the leftmost corner of the topaz crystal facing bal close to bal. (image isn't loading)").setChildOf(this.getWindow()) + coordsWindow(2, 1, "Divans", "cw divans toggle", "https://i.imgur.com/bkC6yp3.jpg", true, "Go to the middle of jade crystal. (image isn't loading)").setChildOf(this.getWindow()) + new UIText("Click box to enable/disable.") + .setX(new CenterConstraint()) + .setY((ScreenH-ScreenH/12).pixels()) + .setTextScale((2).pixels()) + .setColor(Color.WHITE) + .setChildOf(this.getWindow()) + }, + }) + CoordsGui.init() + GuiHandler.openGui(CoordsGui) +}
\ No newline at end of file diff --git a/render/downtimeGui.js b/render/downtimeGui.js new file mode 100644 index 0000000..538c590 --- /dev/null +++ b/render/downtimeGui.js @@ -0,0 +1,85 @@ +import settings from "../settings" +import constants from "../util/constants" +import { textGui } from "../util/helperFunctions" + +const downtimeMoveGui = new Gui() +const downtimeGui = new textGui() +let oldFuel = 0, + timeAtLastFuel = 0, + overallDowntime = 0, + trackingDowntime = false, + downtime = 0, + downtimeCount = 0, + uptime = 0 + + +export function openDowntimeGui() +{ + downtimeMoveGui.open() +} + + +register("dragged", (dx, dy, x, y) => { + if (!downtimeMoveGui.isOpen()) return + constants.downtimedata.x = x + constants.downtimedata.y = y + constants.downtimedata.save() +}) + +register('actionbar', (xp) => { + if(!settings.downtimeTracker) return + if(Player.getHeldItem() == null) return + let heldItem = Player.getHeldItem().getNBT().toObject()["tag"]["ExtraAttributes"], + newFuel = parseInt(heldItem["drill_fuel"]) // credit to DocilElm because I'm lazy. + + if(!newFuel) return + else if(oldFuel == 0) oldFuel = newFuel + else if(oldFuel !== newFuel) + { + if(timeAtLastFuel == 0) + { + timeAtLastFuel = Date.now() + return + } + downtime = Date.now() - timeAtLastFuel + overallDowntime += downtime + downtimeCount += 1 + timeAtLastFuel = Date.now() + trackingDowntime = true + oldFuel = newFuel + } +}).setCriteria('${*}+${xp} Mining ${*}') + + +register("renderOverlay", () => { + if (downtimeMoveGui.isOpen()) + { + let txt = "Drag to move." + Renderer.drawStringWithShadow(txt, Renderer.screen.getWidth()/2 - Renderer.getStringWidth(txt)/2, Renderer.screen.getHeight()/2) + downtimeGui.guiObject = {leftValues: ["Downtime", "Overall Downtime", "Average Downtime", "Uptime"], rightValues: [0, 0, 0, 0]} + downtimeGui.x = constants.downtimedata.x + downtimeGui.y = constants.downtimedata.y + downtimeGui.renderGui() + return + } + if (downtimeCount == 0 || !trackingDowntime || !settings.downtimeTracker) return + let avgDowntime = Math.ceil((overallDowntime/downtimeCount)*100) / 100 + downtimeGui.guiObject = {leftValues: ["Downtime", "Overall Downtime", "Average Downtime", "Uptime"], rightValues: [downtime, overallDowntime, avgDowntime, uptime]} + downtimeGui.x = constants.downtimedata.x + downtimeGui.y = constants.downtimedata.y + downtimeGui.renderGui() +}) + + +register("step", () => { + if((Date.now()-timeAtLastFuel)/1000 >= 60) + { + uptime = 0 + oldFuel = 0 + overallDowntime = 0 + timeAtLastFuel = 0 + trackingDowntime = false + } // over 60 seconds then stop making gui + else if(trackingDowntime) + uptime += 1 +}).setFps(1)
\ No newline at end of file diff --git a/render/naturals.js b/render/naturals.js new file mode 100644 index 0000000..595c32d --- /dev/null +++ b/render/naturals.js @@ -0,0 +1,39 @@ +import axios from "../../axios" +import settings from "../settings" +import constants from "../util/constants" +import { waypointRender } from "../util/helperFunctions" +const PREFIX = constants.PREFIX +let coords = [] + + +register("step", () => { + if(constants.serverData.map != "Crystal Hollows") return + axios.get(`https://ninjune.dev/api/coords`) + .then((res) => { + coords = [] + res.data.filter(coord => + (((-1 * settings.naturalRange)/2 < (parseInt(Player.getX()) - coord.x)) && ((parseInt(Player.getX()) - coord.x) < settings.naturalRange/2) + && ((-1 * settings.naturalRange)/2 < (parseInt(Player.getY()) - coord.y)) && ((parseInt(Player.getY()) - coord.y) < settings.naturalRange/2) + && ((-1 * settings.naturalRange)/2 < (parseInt(Player.getZ()) - coord.z)) && ((parseInt(Player.getZ()) - coord.z) < settings.naturalRange/2)) + ).forEach(coord => { + coords.push([coord.x, coord.y, coord.z]) + }) + }) + .catch((err) => { + console.log(err) + }) +}).setFps(1) + + +register("renderWorld", () => { + if(!settings.showNaturals) return + if(coords.length < 1) return + waypointRender(coords) +}) + +register("worldUnload", () => { + coords = [] +}) + + +export default ""
\ No newline at end of file diff --git a/settings.js b/settings.js index cc6382e..92c13d2 100644 --- a/settings.js +++ b/settings.js @@ -1,10 +1,11 @@ -import { @Vigilant, @ButtonProperty, @SwitchProperty, @SelectorProperty } from 'Vigilance' +import { @Vigilant, @ButtonProperty, @SwitchProperty, @SelectorProperty, @SliderProperty } from 'Vigilance' @Vigilant("Coleweight") class Settings { @SwitchProperty({ name: "Coleweight tracker", description: "Enables the Coleweight tracker.", + subcategory: "Coleweight Tracker", category: "General" }) cwToggle = true; @@ -12,6 +13,7 @@ class Settings { @ButtonProperty({ name: "Change Coleweight tracker position", description: "Move the location of the coleweight tracker.", + subcategory: "Coleweight Tracker", category: "General", placeholder: "Open" }) @@ -22,6 +24,7 @@ class Settings { @SwitchProperty({ name: "Rank chat", description: "Enables the Coleweight rank message after a name in chat.", + subcategory: "Ranked Chat", category: "General" }) rankChat = true; @@ -29,6 +32,7 @@ class Settings { @SwitchProperty({ name: "Rank everywhere", description: "Enables showing Coleweight rank everywhere. (instead of just in crystal hollows)", + subcategory: "Ranked Chat", category: "General" }) rankEverywhere = false; @@ -36,6 +40,7 @@ class Settings { @SwitchProperty({ name: "Track griefers", description: "Check lobbies for griefers (on join and when new players join.)", + subcategory: "Random Features", category: "General" }) trackGriefers = true; @@ -43,35 +48,77 @@ class Settings { @SwitchProperty({ name: "Claiming", description: "Enables lobby claiming (/claim).", + subcategory: "Random Features", category: "General" }) claiming = true; @SwitchProperty({ - name: "Timer", - description: "Toggles visibility of CHollows timer", + name: "Downtime tracker", + description: "Tracks downtime.", + subcategory: "Downtime", category: "General" }) - timerVisible = false; + downtimeTracker = false; @ButtonProperty({ - name: "Change timer position", - description: "Move the location of the timer.", + name: "Change downtime tracker position", + description: "Move the location of the downtime tracker.", + subcategory: "Downtime", category: "General", placeholder: "Open" }) - moveTimerLocation() { - ChatLib.command("cw move timer", true); + moveDowntimeLocation() { + ChatLib.command("cw move downtime", true); } @SwitchProperty({ name: "Debug", description: "Toggles debug mode.", + subcategory: "Random Features", category: "General" }) debug = false; @SwitchProperty({ + name: "Marked lobbies", + description: "Enables lobby marking (automatic).", + category: "General", + subcategory: "Marking" + }) + lobbyMarking = false; + + @ButtonProperty({ + name: "Clear lobbies", + description: "Clears marked lobbies.", + category: "General", + subcategory: "Marking", + placeholder: "Clear" + }) + clearLobbies() { + ChatLib.command("cw clearlobbies", true); + } + + @SwitchProperty({ + name: "Timer", + description: "Toggles visibility of CHollows timer", + subcategory: "Timer", + category: "General" + }) + timerVisible = false; + + @ButtonProperty({ + name: "Change timer position", + description: "Move the location of the timer.", + subcategory: "Timer", + category: "General", + placeholder: "Open" + }) + moveTimerLocation() { + ChatLib.command("cw move timer", true); + } + + @SwitchProperty({ name: "Show powdertracker", description: "If the tracker overlay should be visible.", category: "Powdertracker" @@ -110,6 +157,22 @@ class Settings { ChatLib.command("cw move powdertracker", true); } + @SwitchProperty({ + name: "Show naturals", + description: "If natural veins should show.", + category: "Naturals" + }) + showNaturals = false + + @SliderProperty({ + name: "Natural range", + description: "Range that naturals will show up in", + category: "Naturals", + min: 16, + max: 64 + }) + naturalRange = 32 + constructor() { this.initialize(this); this.registerListener("Rank chat", value => { @@ -124,9 +187,15 @@ class Settings { this.registerListener("Claiming", value => { this.claiming = value; }) + this.registerListener("Marked lobbies", value => { + this.lobbyMarking = value; + }) this.registerListener("Timer", value => { this.timerVisible = value; }) + this.registerListener("Downtime tracker", value => { + this.downtimeTracker = value; + }) this.registerListener("Debug", value => { this.debug = value; }) @@ -142,6 +211,12 @@ class Settings { this.registerListener("Alignment", value => { this.trackerAlignment = value; }) + this.registerListener("Show naturals", value => { + this.showNaturals = value; + }) + this.registerListener("Natural range", value => { + this.naturalRange = value; + }) } } diff --git a/util/constants.js b/util/constants.js index 16cd037..51345fe 100644 --- a/util/constants.js +++ b/util/constants.js @@ -22,6 +22,11 @@ let TimerData = new PogObject("Coleweight", { "timer": 0 }, "config/.timer_data.json") +let DowntimeData = new PogObject("Coleweight", { + "x": 0, + "y": 0 +}, "config/.downtime_data.json") + export default { PREFIX: "&2[CW] ", @@ -29,6 +34,7 @@ export default data: PogData, powderdata: PowderData, timerdata: TimerData, + downtimedata: DowntimeData, cwValues: [], calcCwPerHr: false, upTimeTrack: false, 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 |