aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorNinjune <enderknight537@gmail.com>2022-12-22 03:21:02 -0600
committerNinjune <enderknight537@gmail.com>2022-12-22 03:21:02 -0600
commit329dccf50ed5e9f87531580f679522238b6a019b (patch)
tree3053852d322db744822a7dd2a05fd59d2b1e90b7 /util
parent1ffc0a89be42fcde95a04a87cc00dbc347b27ece (diff)
downloadcoleweight-329dccf50ed5e9f87531580f679522238b6a019b.tar.gz
coleweight-329dccf50ed5e9f87531580f679522238b6a019b.tar.bz2
coleweight-329dccf50ed5e9f87531580f679522238b6a019b.zip
v1.8.3
Diffstat (limited to 'util')
-rw-r--r--util/constants.js29
-rw-r--r--util/helperFunctions.js148
-rw-r--r--util/renderUtil.js15
3 files changed, 179 insertions, 13 deletions
diff --git a/util/constants.js b/util/constants.js
index 5155132..16a0e6e 100644
--- a/util/constants.js
+++ b/util/constants.js
@@ -1,4 +1,6 @@
import PogObject from "PogData"
+import axios from "../../axios"
+import settings from "../settings"
let PogData = new PogObject("Coleweight", {
"api_key": "",
@@ -6,7 +8,6 @@ let PogData = new PogObject("Coleweight", {
"jungle_amulet": true,
"x": 0.5,
"y": 141,
- "coleweight": 0,
"first_time": true
}, "config/.cw_data.json")
@@ -34,20 +35,34 @@ let CollectionData = new PogObject("Coleweight", {
"y": 0
}, "config/.collection_data.json")
+let AbilityData = new PogObject("Coleweight", {
+ "x": 0,
+ "y": 0
+}, "config/.ability_data.json")
+
const PREFIX = "&2[CW] "
-export default
-{
+export default constants = {
PREFIX: PREFIX,
CALCULATEERRORMESSAGE: `${PREFIX}&cInvalid arguments. '/cw calculate help' for more information.`,
INVALIDARGS: `${PREFIX}&cInvalid arguments. '/cw help' for more information.`,
VERSION: (JSON.parse(FileLib.read("Coleweight", "metadata.json"))).version,
+ CWINFO: undefined,
data: PogData,
powderdata: PowderData,
timerdata: TimerData,
- collectiondata: DowntimeData,
+ downtimedata: DowntimeData,
collectiondata: CollectionData,
- throneValues: [],
- spiralValues: [],
+ abilitydata: AbilityData,
beta: false,
serverData: {}
-} \ No newline at end of file
+}
+
+register("gameLoad", () => {
+ axios.get(`https://ninjune.dev/api/cwinfo?new=true`)
+ .then((res) => {
+ constants.CWINFO = res.data
+ })
+ .catch((e) => {
+ if(settings.debug) console.log(`[CW] Error loading CWINFO: ${e}`)
+ })
+}) \ No newline at end of file
diff --git a/util/helperFunctions.js b/util/helperFunctions.js
index 8c51cdb..ea91b68 100644
--- a/util/helperFunctions.js
+++ b/util/helperFunctions.js
@@ -77,12 +77,15 @@ export class textGui
this.guiObject = guiObject
this.x = x
this.y = y
+ this.alignment = 0
+ this.moveGuiObject = new Gui()
}
renderGui()
{
let string = ""
+
this.guiObject.leftValues.forEach((leftValue, index) => {
if(leftValue == "Uptime")
{
@@ -99,7 +102,55 @@ export class textGui
string += `&a${leftValue}: &b${this.guiObject.rightValues[index]}\n`
}
})
- Renderer.drawStringWithShadow(string, this.x, this.y)
+
+ let text = new Text(string)
+ if (this.alignment == 1)
+ text.setAlign("CENTER")
+ else if (this.alignment == 2)
+ text.setAlign("RIGHT")
+ text.setShadow(true)
+ .setX(this.x)
+ .setY(this.y)
+
+ if (this.moveGuiObject.isOpen())
+ {
+ let txt = "Drag to move."
+
+ Renderer.drawStringWithShadow(txt, Renderer.screen.getWidth()/2 - Renderer.getStringWidth(txt)/2, Renderer.screen.getHeight()/2)
+ }
+
+ text.draw()
+ }
+
+
+ moveGui()
+ {
+ this.moveGuiObject.open()
+ }
+
+
+ findDrawValues()
+ {
+ let string = ""
+
+ this.guiObject.leftValues.forEach((leftValue, index) => {
+ if(leftValue == "Uptime")
+ {
+ let uptime = this.guiObject.rightValues[index] ?? 0,
+ 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`
+ }
+ })
+
+ return string
}
}
@@ -139,8 +190,9 @@ export class trackerGui
return this.itemGui.renderGui()
}
if(!renderGui) return
- if(this.itemValues[0] != undefined && this.trackingItem && this.calcItemPerHour)
+ if(this.itemValues[0] != undefined && /*this.trackingItem && */this.calcItemPerHour)
{
+ this.itemValuesSum = 0
for(let i = 0; i < this.itemValues.length; i++)
this.itemValuesSum += this.itemValues[i]
let eq = Math.ceil((this.itemValuesSum*(3600/this.uptimeSeconds)) * 100) / 100
@@ -225,15 +277,14 @@ export class trackerGui
}
-function getObjectValue(obj, path, def)
+export function getObjectValue(obj, path, def)
{
let current = obj
-
+ if(path == undefined) return undefined
for (let i = 0; i < path.length; i++)
- current = current[path[i]] // could be source of issues
+ current = current[path[i]]
return current
-
}
@@ -263,4 +314,89 @@ export function getSelectedProfile(res)
if(res.data.profiles[i].selected == true)
return res.data.profiles[i]
}
+}
+
+export function capitalizeFirst(sentence)
+{
+ let words = sentence.split(" "),
+ capitalized = words.map(word => {
+ return word[0].toUpperCase() + word.slice(1);
+ })
+
+ return capitalized.join(" ")
+}
+
+export function drawTitle(text, drawTimestamp, scale = 5, time = 3000, sound = "random.orb",)
+{
+ let object = {}
+ if(drawTimestamp == undefined)
+ {
+ World.playSound(sound, 1, 1)
+ object.drawTimestamp = Date.now()
+ object.drawTitle = 1
+ }
+ else if (Date.now() - drawTimestamp > time)
+ {
+ object.drawTimestamp = undefined
+ object.drawTitle = 2
+ }
+ else
+ {
+ let title = new Text(text, Renderer.screen.getWidth()/2, Renderer.screen.getHeight()/2)
+ title.setAlign("CENTER")
+ .setShadow(true)
+ .setScale(scale)
+ .draw()
+ object.drawTimestamp = drawTimestamp
+ object.drawTitle = 1
+ }
+ return object
+}
+
+const hollowsLocations = ["Goblin", "Jungle", "Mithril", "Precursor", "Magma", "Crystal", "Khazad", "Divan", "City"]
+export function checkInHollows()
+{
+ const scoreboard = Scoreboard.getLines()
+
+ for(let lineIndex = 0; lineIndex < scoreboard.length; lineIndex++)
+ {
+ for(let locationsIndex = 0; locationsIndex < hollowsLocations.length; locationsIndex++)
+ {
+ if(scoreboard[lineIndex].toString().includes(hollowsLocations[locationsIndex]))
+ return true
+ }
+ }
+ return false
+}
+
+const dwarvenLocations = ["Dwarven", "Royal", "Palace", "Library", "Mist", "Cliffside", "Quarry", "Gateway", "Wall", "Forge", "Far", "Burrows", "Springs", "Upper"]
+export function checkInDwarven()
+{
+ const scoreboard = Scoreboard.getLines()
+
+ for(let lineIndex = 0; lineIndex < scoreboard.length; lineIndex++)
+ {
+ for(let locationsIndex = 0; locationsIndex < dwarvenLocations.length; locationsIndex++)
+ {
+ if(scoreboard[lineIndex].toString().includes(dwarvenLocations[locationsIndex]))
+ return true
+ }
+ }
+ return false
+}
+
+const foragingLocations = ["Dark", "Birch", "Spruce", "Savanna", "Jungle", "Forest"]
+export function checkInPark()
+{
+ const scoreboard = Scoreboard.getLines()
+
+ for(let lineIndex = 0; lineIndex < scoreboard.length; lineIndex++)
+ {
+ for(let locationsIndex = 0; locationsIndex < foragingLocations.length; locationsIndex++)
+ {
+ if(scoreboard[lineIndex].toString().includes(foragingLocations[locationsIndex]))
+ return true
+ }
+ }
+ return false
} \ No newline at end of file
diff --git a/util/renderUtil.js b/util/renderUtil.js
new file mode 100644
index 0000000..f989cde
--- /dev/null
+++ b/util/renderUtil.js
@@ -0,0 +1,15 @@
+export function trace(x, y, z, red, green, blue, alpha)
+{
+ GL11.glLineWidth(2.0)
+ GlStateManager.func_179090_x() // disableTexture2D
+
+ Tessellator.begin(1).colorize(red, green, blue, alpha)
+ if(Player.isSneaking())
+ Tessellator.pos(Player.getRenderX(), Player.getRenderY()+1.54, Player.getRenderZ()).tex(0, 0)
+ else
+ Tessellator.pos(Player.getRenderX(), Player.getRenderY()+1.6203, Player.getRenderZ()).tex(0, 0)
+ Tessellator.pos(x, y, z).tex(0, 0)
+ Tessellator.draw()
+
+ GlStateManager.func_179098_w() // enableTexture2D
+} \ No newline at end of file