diff options
-rw-r--r-- | features/agentlaiThings/hiddenRequirement.js | 8 | ||||
-rw-r--r-- | features/agentlaiThings/index.js | 195 | ||||
-rw-r--r-- | features/agentlaiThings/metadata.json | 8 | ||||
-rw-r--r-- | features/bestiary/index.js | 240 | ||||
-rw-r--r-- | features/betterGuis/index.js | 2 | ||||
-rw-r--r-- | features/cosmetics/cosmetic/dragon/dragonWings.js | 360 | ||||
-rw-r--r-- | features/cosmetics/textures/dragon/classic.png | bin | 11845 -> 0 bytes | |||
-rw-r--r-- | features/cosmetics/textures/dragon/purple.png | bin | 19740 -> 0 bytes | |||
-rw-r--r-- | features/dataLoader/index.js | 20 | ||||
-rw-r--r-- | features/dungeonMap/index.js | 5 | ||||
-rw-r--r-- | features/dungeonSolvers/index.js | 64 | ||||
-rw-r--r-- | features/events/index.js | 2 | ||||
-rw-r--r-- | features/eventsGUI/index.js | 221 | ||||
-rw-r--r-- | features/globalSettings/index.js | 21 | ||||
-rw-r--r-- | features/hud/index.js | 25 | ||||
-rw-r--r-- | features/mining/index.js | 92 | ||||
-rw-r--r-- | features/nether/index.js | 10 | ||||
-rw-r--r-- | features/soopyGui/GuiPage.js | 8 | ||||
-rw-r--r-- | features/soopyGui/index.js | 92 | ||||
-rw-r--r-- | metadata.json | 4 | ||||
-rw-r--r-- | socketConnection.js | 42 | ||||
-rw-r--r-- | utils/numberUtils.js | 47 |
22 files changed, 958 insertions, 508 deletions
diff --git a/features/agentlaiThings/hiddenRequirement.js b/features/agentlaiThings/hiddenRequirement.js deleted file mode 100644 index effd23b..0000000 --- a/features/agentlaiThings/hiddenRequirement.js +++ /dev/null @@ -1,8 +0,0 @@ -let allowedUUIDS = [ - "f2bcfe6aa54c4eb9b37156b4f1d20beb", - "dc8c39647b294e03ae9ed13ebd65dd29" -] - -module.exports = {hidden: function(featureManager){ - return !allowedUUIDS.includes(Player.getUUID().toString().replace(/-/g, "")) -}}
\ No newline at end of file diff --git a/features/agentlaiThings/index.js b/features/agentlaiThings/index.js deleted file mode 100644 index 1654be4..0000000 --- a/features/agentlaiThings/index.js +++ /dev/null @@ -1,195 +0,0 @@ -/// <reference types="../../../CTAutocomplete" /> -/// <reference lib="es2015" /> -import { SoopyGui, SoopyRenderEvent } from "../../../guimanager"; -import SoopyBoxElement from "../../../guimanager/GuiElement/SoopyBoxElement"; -import SoopyGuiElement from "../../../guimanager/GuiElement/SoopyGuiElement"; -import renderLibs from "../../../guimanager/renderLibs"; -import Feature from "../../featureClass/class"; -import ToggleSetting from "../settings/settingThings/toggle"; - -class AgentThings extends Feature { - constructor() { - super() - } - - onEnable(){ - return; - this.initVariables() - - this.nearPlayerData = [] - while(this.nearPlayerData.length < 100){this.nearPlayerData.push({})} - - this.recordNearestPlayers = new ToggleSetting("Record nearby players", "You can then view this data with /nearplayers", false, "record_near_players", this) - - this.registerStep(false, 1, this.step) - - this.nearPlayersGui = new SoopyGui().setOpenCommand("nearplayers") - - this.nearPlayersGuiBox = new SoopyBoxElement().setLocation(0.25, 0.25, 0.5, 0.5) - this.nearPlayersGui.element.addChild(this.nearPlayersGuiBox) - - this.nearPlayersRenderElement = new SoopyGuiElement() - this.nearPlayersGuiBox.addChild(this.nearPlayersRenderElement) - - - let selected = undefined - let selectedDist = undefined - let lastXY = 0 - this.nearPlayersRenderElement.addEvent(new SoopyRenderEvent().setHandler((mouseX, mouseY)=>{ - let moved = lastXY !== mouseX+mouseY - lastXY = mouseX+mouseY - - let x = this.nearPlayersRenderElement.location.getXExact() - let y = this.nearPlayersRenderElement.location.getYExact() - let width = this.nearPlayersRenderElement.location.getWidthExact() - let height = this.nearPlayersRenderElement.location.getHeightExact() - - x+=width*0.125 - y+=height*0.125 - width*=0.75 - height*=0.75 - - Renderer.drawLine(Renderer.color(0, 0, 0), x, y+height, x+width, y+height, 2)//bottom axis line - Renderer.drawLine(Renderer.color(0, 0, 0), x, y, x, y+height, 2)//left axis line - - renderLibs.drawStringCentered("&0100s ago", x, y+height+6, Renderer.screen.getWidth()/1000) - renderLibs.drawStringCentered("&050s ago", x+width/2, y+height+6, Renderer.screen.getWidth()/1000) - renderLibs.drawStringCentered("&0Now", x+width, y+height+6, Renderer.screen.getWidth()/1000) //bottom axis markers - - - renderLibs.drawStringCenteredVertically("&025m away", x+3-Renderer.getStringWidth("&025m away")*Renderer.screen.getWidth()/1000, y, Renderer.screen.getWidth()/1000) - renderLibs.drawStringCenteredVertically("&020m away", x+3-Renderer.getStringWidth("&020m away")*Renderer.screen.getWidth()/1000, y+height/5*1, Renderer.screen.getWidth()/1000) - renderLibs.drawStringCenteredVertically("&010m away", x+3-Renderer.getStringWidth("&010m away")*Renderer.screen.getWidth()/1000, y+height/5*3, Renderer.screen.getWidth()/1000) - renderLibs.drawStringCenteredVertically("&00m away", x+3-Renderer.getStringWidth("&00m away")*Renderer.screen.getWidth()/1000, y+height-6, Renderer.screen.getWidth()/1000) - - if(moved){ - selected = undefined - selectedDist = undefined - } - let lastUuids = [] - this.nearPlayerData.forEach((data, i)=>{ - let newLastUuids = [] - Object.keys(data).forEach(uuid=>{ - newLastUuids.push(uuid) - lastUuids = lastUuids.filter(a=>a!==uuid) - - let dist = data[uuid].distance - let oldDist = this.nearPlayerData[i-1]?.[uuid]?.distance || 25 - - let thisX = x+(i)/100*width - let thisY = y+height-(dist/25)*height - - if(moved && (thisX-mouseX)**2 + (thisY-mouseY)**2 < 3){ - selected = uuid - selectedDist = dist - } - - if(i !== 0){ - Renderer.drawLine(Renderer.color(0, 0, 0), x+(i-1)/100*width, y+height-(oldDist/25)*height, thisX, thisY, 1) - } - - Renderer.drawRect(Renderer.color(0, 0, 0), thisX-1, thisY-1, 3, 3) - }) - - lastUuids.forEach(uuid=>{ - let dist = 25 - let oldDist = this.nearPlayerData[i-1]?.[uuid]?.distance || 25 - - let thisX = x+(i)/100*width - let thisY = y+height-(dist/25)*height - - if(i !== 0){ - Renderer.drawLine(Renderer.color(0, 0, 0), x+(i-1)/100*width, y+height-(oldDist/25)*height, thisX, thisY, 1) - } - }) - - lastUuids = newLastUuids - }) - - if(selected){ - width = this.nearPlayersRenderElement.location.getWidthExact() - height = this.nearPlayersRenderElement.location.getHeightExact() - - width*=0.75 - height*=0.75 - - renderLibs.scizzorFast(0,0,Renderer.screen.getWidth(), Renderer.screen.getHeight()) - let selectedIgn = undefined - let lastRenderedSelected = false - this.nearPlayerData.forEach((data, i)=>{ - if(data[selected]){ - lastRenderedSelected = true - - selectedIgn = data[selected].name - - let dist = data[selected].distance - let oldDist = this.nearPlayerData[i-1]?.[selected]?.distance || 25 - - let thisX = x+(i)/100*width - let thisY = y+height-(dist/25)*height - - if(i !== 0){ - Renderer.drawLine(Renderer.color(255, 0, 0), x+(i-1)/100*width, y+height-(oldDist/25)*height, thisX, thisY, 3) - } - }else{ - if(lastRenderedSelected){ - lastRenderedSelected = false - - let dist = 25 - let oldDist = this.nearPlayerData[i-1]?.[selected]?.distance || 25 - - let thisX = x+(i)/100*width - let thisY = y+height-(dist/25)*height - - if(i !== 0){ - Renderer.drawLine(Renderer.color(255, 0, 0), x+(i-1)/100*width, y+height-(oldDist/25)*height, thisX, thisY, 3) - } - } - } - }) - - let width = Math.max(Renderer.getStringWidth(selectedIgn)*2, Renderer.getStringWidth("Distance: " + selectedDist.toFixed(1)))+8 - let height = 32 - renderLibs.drawBox([255, 255, 255], mouseX+10, mouseY-height/2, width,height, 3) - renderLibs.drawString("&0" + selectedIgn, mouseX+14, mouseY-height/2+3, 2) - renderLibs.drawString("&0Distance: &7" + selectedDist.toFixed(1) , mouseX+14, mouseY-height/2+21, 1) - } - - })) - } - - step(){ - if(!this.recordNearestPlayers.getValue()) return - - let thisSecondPlayerData = {} - World.getAllPlayers().forEach(p=>{ - let distSq = (p.getX()-Player.getX())**2+(p.getY()-Player.getY())**2+(p.getZ()-Player.getZ())**2 - - if(distSq < 25*25 && distSq !== 0){ - thisSecondPlayerData[p.getUUID().toString()] = {name: p.getName(), distance: Math.sqrt(distSq)} - } - }) - - this.nearPlayerData.push(thisSecondPlayerData) - - if(this.nearPlayerData.length > 100) this.nearPlayerData.shift() - } - - initVariables(){ - this.recordNearestPlayers = undefined - this.nearPlayerData = undefined - this.nearPlayersGui = undefined - this.nearPlayersGuiBox = undefined - this.nearPlayersRenderElement = undefined - } - - onDisable(){ - this.nearPlayersGui.delete() - - this.initVariables() - } -} - -module.exports = { - class: new AgentThings() -}
\ No newline at end of file diff --git a/features/agentlaiThings/metadata.json b/features/agentlaiThings/metadata.json deleted file mode 100644 index e44e8fa..0000000 --- a/features/agentlaiThings/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "Agentlai Settings", - "description": "Settings only avalible to agentlai", - "isHidden": "hiddenRequirement.js", - "isTogglable": true, - "defaultEnabled": false, - "sortA": 0 -}
\ No newline at end of file diff --git a/features/bestiary/index.js b/features/bestiary/index.js index 3888ffb..00d5752 100644 --- a/features/bestiary/index.js +++ b/features/bestiary/index.js @@ -1,37 +1,257 @@ /// <reference types="../../../CTAutocomplete" /> /// <reference lib="es2015" /> -import { m } from "../../../mappings/mappings"; import Feature from "../../featureClass/class"; -import { drawCoolWaypoint } from "../../utils/renderUtils"; +import { numberWithCommas } from "../../utils/numberUtils"; +import HudTextElement from "../hud/HudTextElement"; +import DropdownSetting from "../settings/settingThings/dropdownSetting"; +import LocationSetting from "../settings/settingThings/location"; import SettingBase from "../settings/settingThings/settingBase"; import ToggleSetting from "../settings/settingThings/toggle"; +let dontUseApi = new Set() +dontUseApi.add("arachne") +dontUseApi.add("barbarian_duke_x") +dontUseApi.add("bladesoul") +dontUseApi.add("mage_outlaw") +dontUseApi.add("ashfang") +dontUseApi.add("magma_cube_boss") +dontUseApi.add("headless_horseman") +dontUseApi.add("dragon") -class Waypoints extends Feature { + +class Bestiary extends Feature { constructor() { super() } onEnable() { - this.initVariables() - this.bestiaryData = JSON.parse(FileLib.read("soopyAddonsData", "bestiaryData.json") || "{}") this.bestiaryChanged = false + + this.bestiaryApiTracking = {} + + this.registerStep(true, 5, this.scanInv) + this.registerStep(false, 5, this.saveData) + + + this.bestiaryStatTypes = { + "barbarian_duke_x": "Barbarian Duke X" + } + Object.keys(this.bestiaryData).forEach(k => { + if (this.bestiaryData[k].guiName) this.bestiaryStatTypes[k] = this.bestiaryData[k].guiName + }) + + new SettingBase("NOTE: u need to open ur bestiary menu", "before this will work", true, "info_bestiary", this) + this.hudStat = [] + for (let i = 0; i < 10; i++) { + this.hudStat[i] = {} + this.hudStat[i].enabled = new ToggleSetting("Bestiary Slot #" + (i + 1), "Allows you to render a custom besiary kills on your hud", false, "bestiary_stat_" + i, this) + this.hudStat[i].type = new DropdownSetting("Bestiary Slot #" + (i + 1) + " Type", "The bestiary type", "barbarian_duke_x", "bestiary_stat_" + i + "_type", this, this.bestiaryStatTypes) + this.hudStat[i].location = new LocationSetting("Bestiary Slot #" + (i + 1) + " Location", "Allows you to edit the location of the bestiary stat", "bestiary_stat_" + i + "_location", this, [10, 50 + i * 10, 1, 1]).editTempText("&6Bestiary Stat Stat&7> &f12,345") + this.hudStat[i].textElement = new HudTextElement().setToggleSetting(this.hudStat[i].enabled).setLocationSetting(this.hudStat[i].location).setText("&6Bestiary Stat&7> &fLoading...") + this.hudStat[i].onlySb = new ToggleSetting("Bestiary Slot #" + (i + 1) + " Only SB", "Only render this stat when you are in skyblock", true, "bestiary_stat_" + i + "_only_sb", this).requires(this.hudStat[i].enabled) + + this.hudStat[i].location.requires(this.hudStat[i].enabled) + this.hudStat[i].type.requires(this.hudStat[i].enabled) + if (this.hudStat[i - 1]) { + this.hudStat[i].enabled.requires(this.hudStat[i - 1].enabled) + } + } + + this.registerStep(false, 5, this.updateHudElements) + this.registerEvent("renderOverlay", this.renderHUD) + // TODO + // dragon + // headless_horseman + let lastThing = undefined + let lastThingTime = 0 + this.registerChat("${chat}", (chat) => { + let thing + switch (chat.trim()) { + case "MAGE OUTLAW DOWN!": + thing = "mage_outlaw" + break; + case "BARBARIAN DUKE X DOWN!": + thing = "barbarian_duke_x" + break; + case "BLADESOUL DOWN!": + thing = "bladesoul" + break; + case "ASHFANG DOWN!": + thing = "ashfang" + break; + // case "MAGMA BOSS DOWN!": + // thing = "magma_cube_boss" + // break; + case "ARACHNE DOWN!": + lastThing = "arachne" + lastThingTime = Date.now() + break; + case "HORSEMAN DOWN!": + lastThing = "arachne" + lastThingTime = Date.now() + break; + default: + break; + } + if (chat.includes("DRAGON")) { + lastThing = "dragon" + lastThingTime = Date.now() + } + + if (chat.trim().startsWith("Your Damage: ")) { + let dmg = parseInt(chat.trim().split("Your Damage: ")[1].split(" ")[0]) + if (dmg > 0 && Date.now() - lastThingTime < 1000) { + thing = lastThing + lastThing = "" + lastThingTime = 0 + } + } + + if (thing) { + this.bestiaryData[thing].guessCount++ + this.bestiaryChanged = true + } + }) + this.registerSoopy("apiLoad", this.apiLoad); + + if (this.FeatureManager.features["dataLoader"] && this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock_raw) { + this.apiLoad(this.FeatureManager.features["dataLoader"].class.lastApiData.skyblock_raw, "skyblock", false, true); + } + } + + renderHUD() { + for (let stat of this.hudStat) { + stat.textElement.render() + } } - initVariables() { + getBestiaryCount(id) { + if (!this.bestiaryData[id]) return "???" + let count = this.bestiaryData[id].count + + if (!dontUseApi.has(id)) { + let currApiData = this.bestiaryApiTracking[id] + + count += currApiData - this.bestiaryData[id].apiCount + } + count += this.bestiaryData[id].guessCount + + return count } - onDisable() { + updateHudElements() { + if (!this.FeatureManager.features["dataLoader"]) return + + let insb = this.FeatureManager.features["dataLoader"].class.isInSkyblock + + this.hudStat.forEach(stat => { + if (stat.enabled.getValue()) { + if (!insb && stat.onlySb.getValue()) { + stat.textElement.setText("") + return + } + + let type = stat.type.getValue() + + stat.textElement.setText(`&6${this.bestiaryData[type]?.guiName}&7> &f${numberWithCommas(this.getBestiaryCount(type))}`) + } + }) + } + + apiLoad(data, dataType, isSoopyServer, isLatest) { + if (isSoopyServer || !isLatest) return; + if (dataType !== "skyblock") return; + + let currentProfile = {} + let currentProfileTime = 0 + + data.profiles.forEach(p => { + if (p.members[Player.getUUID().toString().replace(/-/g, "")].last_save > currentProfileTime) { + currentProfileTime = p.members[Player.getUUID().toString().replace(/-/g, "")].last_save + currentProfile = p.members[Player.getUUID().toString().replace(/-/g, "")] + } + }) + + Object.keys(currentProfile.stats).forEach(key => { + if (key.startsWith("kills_")) { + this.bestiaryApiTracking[key.replace("kills_", "")] = currentProfile.stats[key] + } + }) + } + + scanInv() { + if (!Player.getContainer()) return + if (!Player.getContainer().getName().startsWith("Bestiary ➜ ")) return + let tempChanged = false + let seen = new Set() + + for (let item of Player.getContainer().getItems()) { + if (!item) continue + let name = ChatLib.removeFormatting(item.getName()).split(" ") + name.pop() + let apiName = name.join("_").toLowerCase() + if (seen.has(apiName)) continue + seen.add(apiName) + + if (apiName === "skeletor_prime") continue + + if (this.bestiaryApiTracking[apiName] || dontUseApi.has(apiName)) { + + let count = 0 + + for (let l of item.getLore()) { + l = ChatLib.removeFormatting(l) + + if (l.startsWith("Kills: ")) { + count = parseInt(l.split("Kills: ")[1].replace(/,/g, "")) + break; + } + } + + let needsChange = !this.bestiaryData[apiName] || this.bestiaryData[apiName].guiName !== name.join(" ") || this.bestiaryData[apiName].count !== count || this.bestiaryData[apiName].apiCount !== (this.bestiaryApiTracking[apiName] || 0) || this.bestiaryData[apiName].guessCount !== 0 + if (needsChange) { + this.bestiaryData[apiName] = { + guiName: name.join(" "), + count, + apiCount: this.bestiaryApiTracking[apiName] || 0, + guessCount: 0 + } + this.bestiaryChanged = true + + tempChanged = true + + } + } + } + + if (tempChanged) { + this.bestiaryStatTypes = {} + Object.keys(this.bestiaryData).forEach(k => { + if (this.bestiaryData[k]?.guiName) this.bestiaryStatTypes[k] = this.bestiaryData[k].guiName + }) + + this.hudStat.forEach(s => { + s.type.dropdownObject.setOptions(this.bestiaryStatTypes) + }) + + this.updateHudElements() + } + start = Date.now() + } + + saveData() { if (this.bestiaryChanged) { FileLib.write("soopyAddonsData", "bestiaryData.json", JSON.stringify(this.bestiaryData)) } + } - this.initVariables() + onDisable() { + this.saveData() } -} +} module.exports = { - class: new Waypoints() + class: new Bestiary() } diff --git a/features/betterGuis/index.js b/features/betterGuis/index.js index cb0b5a0..2d188bf 100644 --- a/features/betterGuis/index.js +++ b/features/betterGuis/index.js @@ -24,7 +24,7 @@ class BetterGuis extends Feature { this.reliableSbMenuClicks = { getValue: () => false }//removed because hypixel fixed, code kept incase hypixel adds back bug later //new ToggleSetting("Make SBMENU clicks reliable", "This will delay clicks on sbmenu to time them so they dont get canceled", true, "sbmenu_time", this) this.museumGuiEnabled = new ToggleSetting("Custom Museum GUI", "Custom gui for the Museum", true, "custom_museum_enabled", this) - this.dungeonReadyGuiEnabled = new ToggleSetting("Custom Dungeon Ready GUI (UNFINISHED)", "Custom gui for the dungeon ready up menu", false, "custom_dungeon_ready_enabled", this) + this.dungeonReadyGuiEnabled = new ToggleSetting("Custom Dungeon Ready GUI", "Custom gui for the dungeon ready up menu", false, "custom_dungeon_ready_enabled", this) this.chestSearchBar = new ToggleSetting("Inventory Search Bar", "u can use '&' to make it filter buy stuff that contains multiple things", false, "inv_search", this) diff --git a/features/cosmetics/cosmetic/dragon/dragonWings.js b/features/cosmetics/cosmetic/dragon/dragonWings.js index 0d7341f..f050141 100644 --- a/features/cosmetics/cosmetic/dragon/dragonWings.js +++ b/features/cosmetics/cosmetic/dragon/dragonWings.js @@ -1,10 +1,11 @@ +import renderLibs from "../../../../../guimanager/renderLibs.js"; import { f, m, m } from "../../../../../mappings/mappings.js"; import ToggleSetting from "../../../settings/settingThings/toggle.js"; import Cosmetic from "../../cosmetic.js"; const ModelDragon = Java.type("net.minecraft.client.model.ModelDragon") -if(!GlStateManager){ +if (!GlStateManager) { // var GL11 = Java.type("org.lwjgl.opengl.GL11"); //using var so it goes to global scope var GlStateManager = Java.type("net.minecraft.client.renderer.GlStateManager"); } @@ -13,10 +14,15 @@ const EssentialCosmeticSlot = Java.type("gg.essential.cosmetics.CosmeticSlot") const FACING = Java.type("net.minecraft.block.BlockDirectional").field_176387_N let dragon = new ModelDragon(0) //too lazy to make my own model so i just yoink it from modelDragon lmfao -let textures = {//TODO: dynamicly load textures from server - classic: new Image(javax.imageio.ImageIO.read(new java.io.File("./config/ChatTriggers/modules/SoopyV2/features/cosmetics/textures/dragon/classic.png"))), - purple: new Image(javax.imageio.ImageIO.read(new java.io.File("./config/ChatTriggers/modules/SoopyV2/features/cosmetics/textures/dragon/purple.png"))) +let textures = new Map() +let loadingTextures = new Set() +function loadTexture(id) { + new Thread(() => { + loadingTextures.add(id) + textures.set(id, renderLibs.getImage("http://soopymc.my.to/api/soopyv2/textures/cosmetic/dragon/" + id + "/img.png", true)) + }).start() } +loadTexture("classic") let wing = getField(dragon, f.wing) let wingTip = getField(dragon, f.wingTip) @@ -24,132 +30,136 @@ class DragonWings extends Cosmetic { constructor(player, parent) { super(player, parent, "dragon_wings"); - this.animOffset = Math.random()*20*Math.PI + this.animOffset = Math.random() * 20 * Math.PI this.lastRender = Date.now() this.lastFlapSound = this.animOffset this.i = 0 this.flying = false + + if (!textures.has(this.settings.texture) && !loadingTextures.has(this.settings.texture)) { + loadTexture(this.settings.texture) + } } - onRenderEntity(ticks, isInGui){ - - if(this.player.getPlayer()[m.isInvisibleToPlayer](Player.getPlayer()) || this.player.getPlayer()[m.isInvisible]()){ + onRenderEntity(ticks, isInGui) { + + if (this.player.getPlayer()[m.isInvisibleToPlayer](Player.getPlayer()) || this.player.getPlayer()[m.isInvisible]()) { return } - + if (!textures.has("classic")) return let isSelfPlayer = this.player.getUUID().toString() === Player.getUUID().toString() let isInInv = isSelfPlayer && ticks === 1 let thirdPersonView = Client.getMinecraft()[f.gameSettings.Minecraft][f.thirdPersonView] - if(!this.parent.firstPersonVisable.getValue() && thirdPersonView === 0 && isSelfPlayer && !isInInv) return + if (!this.parent.firstPersonVisable.getValue() && thirdPersonView === 0 && isSelfPlayer && !isInInv) return // return; // wing.func_78785_a(1) - let timeSince = (Date.now()-this.lastRender)/1000 + let timeSince = (Date.now() - this.lastRender) / 1000 this.lastRender = Date.now() - let rotation = isInInv?0:this.player.getPlayer()[f.prevRenderYawOffset]+(this.player.getPlayer()[f.renderYawOffset]-this.player.getPlayer()[f.prevRenderYawOffset])*ticks + let rotation = isInInv ? 0 : this.player.getPlayer()[f.prevRenderYawOffset] + (this.player.getPlayer()[f.renderYawOffset] - this.player.getPlayer()[f.prevRenderYawOffset]) * ticks // rotation += entity.field_70761_aq+(entity.field_70761_aq-entity.field_70760_ar)*ticks // console.log(rotation, entity.getEntity().field_70761_aq+(entity.getEntity().field_70761_aq-entity.getEntity().field_70760_ar)*ticks) - let horisontalSpeed = Math.hypot((this.player.getPlayer()[f.posX.Entity]-this.player.getPlayer()[f.lastTickPosX]),(this.player.getPlayer()[f.posZ.Entity]-this.player.getPlayer()[f.lastTickPosZ])) + let horisontalSpeed = Math.hypot((this.player.getPlayer()[f.posX.Entity] - this.player.getPlayer()[f.lastTickPosX]), (this.player.getPlayer()[f.posZ.Entity] - this.player.getPlayer()[f.lastTickPosZ])) + + let verticleSpeed = this.player.getPlayer()[f.posY.Entity] - this.player.getPlayer()[f.lastTickPosY] - let verticleSpeed = this.player.getPlayer()[f.posY.Entity]-this.player.getPlayer()[f.lastTickPosY] - - this.animOffset += Math.min(1, horisontalSpeed)*10*timeSince+1*timeSince + this.animOffset += Math.min(1, horisontalSpeed) * 10 * timeSince + 1 * timeSince let flapAmountMultiplyerNoEnd = 1 let flapAmountMultiplyer = 1 let wingEndOffsetThing = 0 - - flapAmountMultiplyerNoEnd += Math.min(5, (horisontalSpeed*5)) + + flapAmountMultiplyerNoEnd += Math.min(5, (horisontalSpeed * 5)) let flapMainOffsetThing = 0 let wingBackAmount = 0 let shouldStandStillWingCurve = true - if(this.player.getPlayer()[f.hurtResistantTime] > 17){ //damage tick - this.animOffset += 25*timeSince + if (this.player.getPlayer()[f.hurtResistantTime] > 17) { //damage tick + this.animOffset += 25 * timeSince } // if((this.player === Player &&this.player.getPlayer().field_71075_bZ.field_75100_b) || (this.player !== Player && Math.abs(verticleSpeed)<0.2 && !this.player.getPlayer().field_70122_E)){//playerCapabilities.isFlying - if(this.flying){ //flying + if (this.flying) { //flying shouldStandStillWingCurve = false - this.animOffset += 5*timeSince //flap in mid air + this.animOffset += 5 * timeSince //flap in mid air flapAmountMultiplyer *= 1.75 //flap harder - if(isSelfPlayer && thirdPersonView === 0){ - if(!this.parent.lessFirstPersonVisable.getValue()){ + if (isSelfPlayer && thirdPersonView === 0) { + if (!this.parent.lessFirstPersonVisable.getValue()) { flapAmountMultiplyerNoEnd += 0.4 flapMainOffsetThing = 0.3 } - }else{ + } else { flapAmountMultiplyer *= 1.25 flapAmountMultiplyer *= 0.9 flapMainOffsetThing = 0.1 - wingEndOffsetThing+= -0.1 + wingEndOffsetThing += -0.1 } wingEndOffsetThing += -0.75 - if(verticleSpeed > 0){ - this.animOffset += verticleSpeed*25*timeSince //flap when flying upwards + if (verticleSpeed > 0) { + this.animOffset += verticleSpeed * 25 * timeSince //flap when flying upwards } - }else{ - if(this.lastFlapSound < this.animOffset-this.animOffset%(Math.PI*2)){ - this.lastFlapSound = this.animOffset-this.animOffset%(Math.PI*2) + } else { + if (this.lastFlapSound < this.animOffset - this.animOffset % (Math.PI * 2)) { + this.lastFlapSound = this.animOffset - this.animOffset % (Math.PI * 2) } } - if(verticleSpeed < -0.5){ - wingBackAmount = Math.min(1, (verticleSpeed+0.5)*-1.5) //lift wings back further ur falling + if (verticleSpeed < -0.5) { + wingBackAmount = Math.min(1, (verticleSpeed + 0.5) * -1.5) //lift wings back further ur falling - this.animOffset += (verticleSpeed+0.5)*-3*timeSince + this.animOffset += (verticleSpeed + 0.5) * -3 * timeSince } GlStateManager[m.pushMatrix](); // pushMatrix Tessellator.colorize(this.settings.color.r, this.settings.color.g, this.settings.color.b); - if(!isSelfPlayer){ + if (!isSelfPlayer) { Tessellator.translate( - (this.player.getPlayer()[f.lastTickPosX] + (this.player.getPlayer()[f.posX.Entity]-this.player.getPlayer()[f.lastTickPosX]) * ticks) - (Player.getPlayer()[f.lastTickPosX] + (Player.getPlayer()[f.posX.Entity]-Player.getPlayer()[f.lastTickPosX]) * ticks), - (this.player.getPlayer()[f.lastTickPosY] + (this.player.getPlayer()[f.posY.Entity]-this.player.getPlayer()[f.lastTickPosY]) * ticks) - (Player.getPlayer()[f.lastTickPosY] + (Player.getPlayer()[f.posY.Entity]-Player.getPlayer()[f.lastTickPosY]) * ticks), - (this.player.getPlayer()[f.lastTickPosZ] + (this.player.getPlayer()[f.posZ.Entity]-this.player.getPlayer()[f.lastTickPosZ]) * ticks) - (Player.getPlayer()[f.lastTickPosZ] + (Player.getPlayer()[f.posZ.Entity]-Player.getPlayer()[f.lastTickPosZ]) * ticks)) + (this.player.getPlayer()[f.lastTickPosX] + (this.player.getPlayer()[f.posX.Entity] - this.player.getPlayer()[f.lastTickPosX]) * ticks) - (Player.getPlayer()[f.lastTickPosX] + (Player.getPlayer()[f.posX.Entity] - Player.getPlayer()[f.lastTickPosX]) * ticks), + (this.player.getPlayer()[f.lastTickPosY] + (this.player.getPlayer()[f.posY.Entity] - this.player.getPlayer()[f.lastTickPosY]) * ticks) - (Player.getPlayer()[f.lastTickPosY] + (Player.getPlayer()[f.posY.Entity] - Player.getPlayer()[f.lastTickPosY]) * ticks), + (this.player.getPlayer()[f.lastTickPosZ] + (this.player.getPlayer()[f.posZ.Entity] - this.player.getPlayer()[f.lastTickPosZ]) * ticks) - (Player.getPlayer()[f.lastTickPosZ] + (Player.getPlayer()[f.posZ.Entity] - Player.getPlayer()[f.lastTickPosZ]) * ticks)) } - if(textures[this.settings.texture || "classic"]){ - Tessellator.bindTexture(textures[this.settings.texture || "classic"]) //bind texture - }else{ - Tessellator.bindTexture(textures.classic) //bind default texture (classic) + if (textures.get(this.settings.texture || "classic")) { + Tessellator.bindTexture(textures.get(this.settings.texture || "classic")) //bind texture + } else { + Tessellator.bindTexture(textures.get("classic")) //bind default texture (classic) } - if(this.player.getPlayer()[f.ridingEntity.Entity]){ - rotation = this.player.getPlayer()[f.rotationYawHead]+(this.player.getPlayer()[f.rotationYawHead]-this.player.getPlayer()[f.prevRotationYawHead])*ticks + if (this.player.getPlayer()[f.ridingEntity.Entity]) { + rotation = this.player.getPlayer()[f.rotationYawHead] + (this.player.getPlayer()[f.rotationYawHead] - this.player.getPlayer()[f.prevRotationYawHead]) * ticks } - if(!this.player.getPlayer()[m.isPlayerSleeping]()){ //dont rotate when in bed - Tessellator.rotate((180-rotation),0,1,0) - - Tessellator.translate(0,1.2,0.1) - - if(this.player.getPlayer()[m.isSneaking.Entity]()){ //isSneaking - Tessellator.translate(0, -0.125,0) - Tessellator.rotate(-20, 1,0,0) - - Tessellator.translate(0, 0,0.1) - if(isSelfPlayer && thirdPersonView === 0){}else{ - Tessellator.translate(0, -0.125,0) + if (!this.player.getPlayer()[m.isPlayerSleeping]()) { //dont rotate when in bed + Tessellator.rotate((180 - rotation), 0, 1, 0) + + Tessellator.translate(0, 1.2, 0.1) + + if (this.player.getPlayer()[m.isSneaking.Entity]()) { //isSneaking + Tessellator.translate(0, -0.125, 0) + Tessellator.rotate(-20, 1, 0, 0) + + Tessellator.translate(0, 0, 0.1) + if (isSelfPlayer && thirdPersonView === 0) { } else { + Tessellator.translate(0, -0.125, 0) } } - - if(isSelfPlayer && !isInInv && thirdPersonView === 0){ + + if (isSelfPlayer && !isInInv && thirdPersonView === 0) { //Make wings less scuffed when in first person looking down/up - Tessellator.translate(0, 0.25, 0.003*(this.player.getPitch())) + Tessellator.translate(0, 0.25, 0.003 * (this.player.getPitch())) } } @@ -161,139 +171,139 @@ class DragonWings extends Cosmetic { let changeStandingStillWingThing = 0 - if(horisontalSpeed < 0.01){ - if(!(this.flying)){ //not flying - let amt = (this.animOffset+Math.PI/2)%(20*Math.PI) - if(amt < 1*Math.PI){ - this.animOffset += 2*timeSince*Math.min(1,(amt/(1*Math.PI))*2) + if (horisontalSpeed < 0.01) { + if (!(this.flying)) { //not flying + let amt = (this.animOffset + Math.PI / 2) % (20 * Math.PI) + if (amt < 1 * Math.PI) { + this.animOffset += 2 * timeSince * Math.min(1, (amt / (1 * Math.PI)) * 2) - flapAmountMultiplyer += (amt/(1*Math.PI))/2 - }else if(amt < 2*Math.PI){ - this.animOffset += 2*timeSince*Math.min(1,(1-(amt/(1*Math.PI)-1))*2) + flapAmountMultiplyer += (amt / (1 * Math.PI)) / 2 + } else if (amt < 2 * Math.PI) { + this.animOffset += 2 * timeSince * Math.min(1, (1 - (amt / (1 * Math.PI) - 1)) * 2) - flapAmountMultiplyer += (1-(amt/(1*Math.PI)-1))/2 + flapAmountMultiplyer += (1 - (amt / (1 * Math.PI) - 1)) / 2 } } - if(this.player.getPlayer()[m.isSneaking.Entity]()){ //isSneaking - if(this.player.getPlayer()[f.rotationPitch] > 20){ + if (this.player.getPlayer()[m.isSneaking.Entity]()) { //isSneaking + if (this.player.getPlayer()[f.rotationPitch] > 20) { shouldStandingStillWingThing = true shouldStandStillWingCurve = false - changeStandingStillWingThing = Math.max(0,this.player.getPlayer()[f.rotationPitch]/600) + changeStandingStillWingThing = Math.max(0, this.player.getPlayer()[f.rotationPitch] / 600) } } } - if(shouldStandingStillWingThing){ - wing[f.rotateAngleY] = 0.25+(changeStandingStillWingThing)*3 + if (shouldStandingStillWingThing) { + wing[f.rotateAngleY] = 0.25 + (changeStandingStillWingThing) * 3 } - if(this.player.getPlayer()[m.isPlayerSleeping]()){ //player in bed + if (this.player.getPlayer()[m.isPlayerSleeping]()) { //player in bed - try{ //try catch incase no bed at that location + try { //try catch incase no bed at that location let facing = World.getWorld().func_180495_p(this.player.getPlayer()[f.playerLocation])[m.getValue.BlockState$StateImplementation](FACING)[m.getHorizontalIndex]() //0-3 is S-W-N-E let rotation = 0 - switch(facing){ + switch (facing) { case 0: rotation = 180 - Tessellator.translate(0, 0,-0.5) + Tessellator.translate(0, 0, -0.5) break case 1: rotation = 90 - Tessellator.translate(0.5, 0,0) + Tessellator.translate(0.5, 0, 0) break case 2: rotation = 0 - Tessellator.translate(0, 0,0.5) + Tessellator.translate(0, 0, 0.5) break case 3: rotation = 270 - Tessellator.translate(-0.5, 0,0) + Tessellator.translate(-0.5, 0, 0) break } // console.log(rotation) // console.log(World.getBlockAt(this.player.getX(), this.player.getY(), this.player.getZ()).getState().func_177229_b(FACING)) Tessellator.rotate(rotation, 0, 1, 0) - }catch(e){} - Tessellator.translate(0, -this.settings.scale*25,0) + } catch (e) { } + Tessellator.translate(0, -this.settings.scale * 25, 0) wing[f.rotateAngleX] = 0; //rotateAngleX - wing[f.rotateAngleZ] = (-0.45+Math.sin(this.animOffset/5)*0.03); //rotateAngleZ + wing[f.rotateAngleZ] = (-0.45 + Math.sin(this.animOffset / 5) * 0.03); //rotateAngleZ + - - wingTip[f.rotateAngleZ] = -2.5+Math.sin(this.animOffset/5)*0.03 - }else if(wingBackAmount === 0){ + wingTip[f.rotateAngleZ] = -2.5 + Math.sin(this.animOffset / 5) * 0.03 + } else if (wingBackAmount === 0) { //tilt - let wing_goback_amount = 0.15/(Math.min(1, horisontalSpeed)*3+0.25) + let wing_goback_amount = 0.15 / (Math.min(1, horisontalSpeed) * 3 + 0.25) let temp_wing_thing = 1 - if(shouldStandingStillWingThing){ - wing_goback_amount /= 1+(changeStandingStillWingThing)/50 - flapAmountMultiplyer /= 1+(changeStandingStillWingThing)/50 + if (shouldStandingStillWingThing) { + wing_goback_amount /= 1 + (changeStandingStillWingThing) / 50 + flapAmountMultiplyer /= 1 + (changeStandingStillWingThing) / 50 - temp_wing_thing += changeStandingStillWingThing*50 + temp_wing_thing += changeStandingStillWingThing * 50 } - let wing_tilt_offset = -Math.min(0.8, horisontalSpeed*3)+0.3 //When go faster tilt wing back so its in direction of wind + let wing_tilt_offset = -Math.min(0.8, horisontalSpeed * 3) + 0.3 //When go faster tilt wing back so its in direction of wind + - - if(shouldStandingStillWingThing){ - wing_tilt_offset += (changeStandingStillWingThing)*4 + if (shouldStandingStillWingThing) { + wing_tilt_offset += (changeStandingStillWingThing) * 4 } - wing[f.rotateAngleX] = 0.85 - Math.cos(this.animOffset) * 0.2+wing_tilt_offset-(flapAmountMultiplyer-1)/3; //rotateAngleX + wing[f.rotateAngleX] = 0.85 - Math.cos(this.animOffset) * 0.2 + wing_tilt_offset - (flapAmountMultiplyer - 1) / 3; //rotateAngleX let temp_horis_wingthing = 0 - if(shouldStandingStillWingThing){ - temp_horis_wingthing = -(changeStandingStillWingThing)*0.75 + if (shouldStandingStillWingThing) { + temp_horis_wingthing = -(changeStandingStillWingThing) * 0.75 } - wing[f.rotateAngleZ] = (Math.sin(this.animOffset)/temp_wing_thing + 0.125) * wing_goback_amount*(1+(flapAmountMultiplyer-1)*1)*flapAmountMultiplyerNoEnd -0.4-wing_tilt_offset/3+temp_horis_wingthing+flapMainOffsetThing; //rotateAngleZ + wing[f.rotateAngleZ] = (Math.sin(this.animOffset) / temp_wing_thing + 0.125) * wing_goback_amount * (1 + (flapAmountMultiplyer - 1) * 1) * flapAmountMultiplyerNoEnd - 0.4 - wing_tilt_offset / 3 + temp_horis_wingthing + flapMainOffsetThing; //rotateAngleZ - let standStillCurveThing = shouldStandStillWingCurve?(2-flapAmountMultiplyer)*0.5:0 + let standStillCurveThing = shouldStandStillWingCurve ? (2 - flapAmountMultiplyer) * 0.5 : 0 - wingTip[f.rotateAngleZ] = standStillCurveThing-((Math.sin((this.animOffset+1.5+(1-temp_wing_thing)/8.5))/(1+(temp_wing_thing-1)/3) + 0.5)) * 0.75*(1+(flapAmountMultiplyer-1)*1)/(1+temp_horis_wingthing) - (1-flapAmountMultiplyer)*2-(1-temp_wing_thing)/10+wingEndOffsetThing; //rotateAngleZ - }else{ + wingTip[f.rotateAngleZ] = standStillCurveThing - ((Math.sin((this.animOffset + 1.5 + (1 - temp_wing_thing) / 8.5)) / (1 + (temp_wing_thing - 1) / 3) + 0.5)) * 0.75 * (1 + (flapAmountMultiplyer - 1) * 1) / (1 + temp_horis_wingthing) - (1 - flapAmountMultiplyer) * 2 - (1 - temp_wing_thing) / 10 + wingEndOffsetThing; //rotateAngleZ + } else { //tilt - let wing_tilt_offset = -Math.min(0.8, horisontalSpeed*3) //When go faster tilt wing back so its in direction of wind - wing[f.rotateAngleX] = 0.75 - Math.cos(this.animOffset) * 0.2+wing_tilt_offset-wingBackAmount/2; //rotateAngleX + let wing_tilt_offset = -Math.min(0.8, horisontalSpeed * 3) //When go faster tilt wing back so its in direction of wind + wing[f.rotateAngleX] = 0.75 - Math.cos(this.animOffset) * 0.2 + wing_tilt_offset - wingBackAmount / 2; //rotateAngleX wing[f.rotateAngleZ] = -wingBackAmount; //rotateAngleZ - - wingTip[f.rotateAngleZ] = -((Math.sin((this.animOffset))*0.5 + 0.3)) + + wingTip[f.rotateAngleZ] = -((Math.sin((this.animOffset)) * 0.5 + 0.3)) } - + GlStateManager[m.disableCull]() //disable culling - let wing_center_dist = ((0-Math.log(1000*this.settings.scale+0.01)-2)-100000*this.settings.scale*this.settings.scale)/1000 + let wing_center_dist = ((0 - Math.log(1000 * this.settings.scale + 0.01) - 2) - 100000 * this.settings.scale * this.settings.scale) / 1000 // GL11.glDepthMask(GL11.GL_FALSE); Tessellator.translate(-wing_center_dist, 0, 0) Tessellator.scale(this.settings.scale, this.settings.scale, this.settings.scale) wing[m.renderWithRotation](1) //render left wing - Tessellator.translate(2*wing_center_dist/this.settings.scale, 0, 0) + Tessellator.translate(2 * wing_center_dist / this.settings.scale, 0, 0) Tessellator.scale(-1, 1, 1) wing[m.renderWithRotation](1) //render right wing - - if(this.player.getPlayer()[f.hurtTime] > 0){ //damage tick + + if (this.player.getPlayer()[f.hurtTime] > 0) { //damage tick GlStateManager[m.pushMatrix](); // pushMatrix GlStateManager[m.depthFunc](514); GlStateManager[m.disableTexture2D](); GlStateManager[m.enableBlend](); GlStateManager[m.blendFunc](770, 771); GlStateManager.func_179131_c(1, 0, 0, 0.25); //m.color.glstatemanager.ffff - + Tessellator.scale(-1, 1, 1) - Tessellator.translate(-2*wing_center_dist/this.settings.scale, 0, 0) + Tessellator.translate(-2 * wing_center_dist / this.settings.scale, 0, 0) wing[m.renderWithRotation](1) //render left wing - Tessellator.translate(2*wing_center_dist/this.settings.scale, 0, 0) + Tessellator.translate(2 * wing_center_dist / this.settings.scale, 0, 0) Tessellator.scale(-1, 1, 1) wing[m.renderWithRotation](1) //render right wing @@ -307,48 +317,48 @@ class DragonWings extends Cosmetic { GlStateManager[m.popMatrix](); // popMatrix } - testPlaySound(){ - if(this.player.getPlayer()[m.isInvisibleToPlayer](Player.getPlayer())){ + testPlaySound() { + if (this.player.getPlayer()[m.isInvisibleToPlayer](Player.getPlayer())) { return } - if(!this.parent.ownCosmeticAudio.getValue()){ + if (!this.parent.ownCosmeticAudio.getValue()) { return } - if(this.player.getPlayer()[m.isPlayerSleeping]()) return + if (this.player.getPlayer()[m.isPlayerSleeping]()) return + + let horisontalSpeed = Math.hypot((this.player.getPlayer()[f.posX.Entity] - this.player.getPlayer()[f.lastTickPosX]), (this.player.getPlayer()[f.posZ.Entity] - this.player.getPlayer()[f.lastTickPosZ])) - let horisontalSpeed = Math.hypot((this.player.getPlayer()[f.posX.Entity]-this.player.getPlayer()[f.lastTickPosX]),(this.player.getPlayer()[f.posZ.Entity]-this.player.getPlayer()[f.lastTickPosZ])) - // if((this.player === Player &&this.player.getPlayer().field_71075_bZ.field_75100_b) || (this.player !== Player && Math.abs(verticleSpeed)<0.2 && !this.player.getPlayer().field_70122_E)){//playerCapabilities.isFlying - if(this.flying){ //flying - - if(this.animOffset-this.lastFlapSound > 2*Math.PI){ + if (this.flying) { //flying + + if (this.animOffset - this.lastFlapSound > 2 * Math.PI) { - let dist = Math.hypot((Player.getX()-this.player.getX()),(Player.getY()-this.player.getY()),(Player.getZ()-this.player.getZ()))+1 + let dist = Math.hypot((Player.getX() - this.player.getX()), (Player.getY() - this.player.getY()), (Player.getZ() - this.player.getZ())) + 1 - World.playSound("mob.enderdragon.wings", (this.settings.scale*15)*Math.min(1, 50/(dist*dist)), 1) - this.lastFlapSound = this.animOffset-this.animOffset%(Math.PI*2) + World.playSound("mob.enderdragon.wings", (this.settings.scale * 15) * Math.min(1, 50 / (dist * dist)), 1) + this.lastFlapSound = this.animOffset - this.animOffset % (Math.PI * 2) } } - if(horisontalSpeed < 0.01){ - if(!(this.flying)){ //not flying - let amt = (this.animOffset+Math.PI/2)%(20*Math.PI) - if(amt < 1*Math.PI){ - if(amt > 0.65*Math.PI && (2*Math.PI+this.animOffset)-this.lastFlapSound > 2*Math.PI){ - - let dist = Math.hypot((Player.getX()-this.player.getX()),(Player.getY()-this.player.getY()),(Player.getZ()-this.player.getZ()))+1 - - World.playSound("mob.enderdragon.wings", (Math.max(0.005,this.settings.scale-0.005)*25)*Math.min(1, 50/Math.min(1,dist*dist))/50, 1-(Math.max(0.005,this.settings.scale-0.005)*25)) - this.lastFlapSound = 2*Math.PI+(this.animOffset)-this.animOffset%(Math.PI*2) + if (horisontalSpeed < 0.01) { + if (!(this.flying)) { //not flying + let amt = (this.animOffset + Math.PI / 2) % (20 * Math.PI) + if (amt < 1 * Math.PI) { + if (amt > 0.65 * Math.PI && (2 * Math.PI + this.animOffset) - this.lastFlapSound > 2 * Math.PI) { + + let dist = Math.hypot((Player.getX() - this.player.getX()), (Player.getY() - this.player.getY()), (Player.getZ() - this.player.getZ())) + 1 + + World.playSound("mob.enderdragon.wings", (Math.max(0.005, this.settings.scale - 0.005) * 25) * Math.min(1, 50 / Math.min(1, dist * dist)) / 50, 1 - (Math.max(0.005, this.settings.scale - 0.005) * 25)) + this.lastFlapSound = 2 * Math.PI + (this.animOffset) - this.animOffset % (Math.PI * 2) } } } } } - onTick(){ + onTick() { this.updateIfNotRendering() @@ -356,25 +366,25 @@ class DragonWings extends Cosmetic { } - removeEssentialCosmetics(){ - if(!this.player.getPlayer() || !this.player.getPlayer().getEssentialCosmetics || !this.player.getPlayer().getEssentialCosmetics()) return + removeEssentialCosmetics() { + if (!this.player.getPlayer() || !this.player.getPlayer().getEssentialCosmetics || !this.player.getPlayer().getEssentialCosmetics()) return let wingCosmetic = this.player.getPlayer().getEssentialCosmetics().get(EssentialCosmeticSlot.WINGS) - if(wingCosmetic !== null){ - if(this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(wingCosmetic))){ - this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(wingCosmetic)).getModel().getModel().boneList.forEach(b=>{ + if (wingCosmetic !== null) { + if (this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(wingCosmetic))) { + this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(wingCosmetic)).getModel().getModel().boneList.forEach(b => { b.isHidden = true this.parent.hiddenEssentialCosmetics.push(b) }) } - }else{ + } else { let fullBodyCosmetic = this.player.getPlayer().getEssentialCosmetics().get(EssentialCosmeticSlot.FULL_BODY) - if(fullBodyCosmetic === "DRAGON_ONESIE_2"){ - if(this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(fullBodyCosmetic))){ - this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(fullBodyCosmetic)).getModel().getModel().boneList.forEach(b=>{ - if(b.boxName === "wing_left_1" || b.boxName === "wing_right_1"){ + if (fullBodyCosmetic === "DRAGON_ONESIE_2") { + if (this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(fullBodyCosmetic))) { + this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(fullBodyCosmetic)).getModel().getModel().boneList.forEach(b => { + if (b.boxName === "wing_left_1" || b.boxName === "wing_right_1") { b.isHidden = true - + this.parent.hiddenEssentialCosmetics.push(b) } }) @@ -383,48 +393,48 @@ class DragonWings extends Cosmetic { } } - updateIfNotRendering(){ - let verticleSpeed = this.player.getPlayer()[f.posY.Entity]-this.player.getPlayer()[f.lastTickPosY] + updateIfNotRendering() { + let verticleSpeed = this.player.getPlayer()[f.posY.Entity] - this.player.getPlayer()[f.lastTickPosY] - this.flying = (verticleSpeed>-0.2) && !this.player.getPlayer()[f.onGround.Entity] + this.flying = (verticleSpeed > -0.2) && !this.player.getPlayer()[f.onGround.Entity] - let timeSince = (Date.now()-this.lastRender)/1000 + let timeSince = (Date.now() - this.lastRender) / 1000 - if(timeSince < 0.020){ + if (timeSince < 0.020) { return } this.lastRender = Date.now() - let horisontalSpeed = Math.hypot((this.player.getPlayer()[f.posX.Entity]-this.player.getPlayer()[f.lastTickPosX]),(this.player.getPlayer()[f.posZ.Entity]-this.player.getPlayer()[f.lastTickPosZ])) + let horisontalSpeed = Math.hypot((this.player.getPlayer()[f.posX.Entity] - this.player.getPlayer()[f.lastTickPosX]), (this.player.getPlayer()[f.posZ.Entity] - this.player.getPlayer()[f.lastTickPosZ])) - - this.animOffset += Math.min(1, horisontalSpeed)*10*timeSince+1*timeSince - if(this.player.getPlayer()[f.hurtResistantTime] > 0){ //damage tick - this.animOffset += 5*timeSince + this.animOffset += Math.min(1, horisontalSpeed) * 10 * timeSince + 1 * timeSince + + if (this.player.getPlayer()[f.hurtResistantTime] > 0) { //damage tick + this.animOffset += 5 * timeSince } // if((this.player === Player &&this.player.getPlayer().field_71075_bZ.field_75100_b) || (this.player !== Player && Math.abs(verticleSpeed)<0.2 && !this.player.getPlayer().field_70122_E)){//playerCapabilities.isFlying - if(this.flying){ //flying - this.animOffset += 5*timeSince //flap in mid air + if (this.flying) { //flying + this.animOffset += 5 * timeSince //flap in mid air - if(verticleSpeed > 0){ - this.animOffset += verticleSpeed*25*timeSince //flap when flying upwards + if (verticleSpeed > 0) { + this.animOffset += verticleSpeed * 25 * timeSince //flap when flying upwards } } - if(verticleSpeed < -0.5){ - this.animOffset += (verticleSpeed+0.5)*-3*timeSince + if (verticleSpeed < -0.5) { + this.animOffset += (verticleSpeed + 0.5) * -3 * timeSince } - if(horisontalSpeed < 0.01){ - if(!(this.flying)){ //not flying - let amt = (this.animOffset+Math.PI/2)%(20*Math.PI) - if(amt < 1*Math.PI){ - this.animOffset += 2*timeSince*Math.min(1,(amt/(1*Math.PI))*2) - }else if(amt < 2*Math.PI){ - this.animOffset += 2*timeSince*Math.min(1,(1-(amt/(1*Math.PI)-1))*2) + if (horisontalSpeed < 0.01) { + if (!(this.flying)) { //not flying + let amt = (this.animOffset + Math.PI / 2) % (20 * Math.PI) + if (amt < 1 * Math.PI) { + this.animOffset += 2 * timeSince * Math.min(1, (amt / (1 * Math.PI)) * 2) + } else if (amt < 2 * Math.PI) { + this.animOffset += 2 * timeSince * Math.min(1, (1 - (amt / (1 * Math.PI) - 1)) * 2) } } } @@ -434,10 +444,10 @@ class DragonWings extends Cosmetic { export default DragonWings; -function getField(e, field){ - +function getField(e, field) { + let field2 = e.class.getDeclaredField(field); - + field2.setAccessible(true) return field2.get(e) @@ -445,7 +455,7 @@ function getField(e, field){ let a = 0 -register("command", (val)=>{ +register("command", (val) => { a = parseFloat(val) ChatLib.chat("Set a to " + a) }).setName("seta", true)
\ No newline at end of file diff --git a/features/cosmetics/textures/dragon/classic.png b/features/cosmetics/textures/dragon/classic.png Binary files differdeleted file mode 100644 index aad6401..0000000 --- a/features/cosmetics/textures/dragon/classic.png +++ /dev/null diff --git a/features/cosmetics/textures/dragon/purple.png b/features/cosmetics/textures/dragon/purple.png Binary files differdeleted file mode 100644 index 5f35a58..0000000 --- a/features/cosmetics/textures/dragon/purple.png +++ /dev/null diff --git a/features/dataLoader/index.js b/features/dataLoader/index.js index f0ede23..849e0fd 100644 --- a/features/dataLoader/index.js +++ b/features/dataLoader/index.js @@ -23,6 +23,8 @@ class DataLoader extends Feature { this.registerStep(true, 2, this.step) + this.registerStep(false, 170, this.loadApiStepThing) + this.registerEvent("worldLoad", this.worldLoad) this.api_loaded_event = this.createCustomEvent("apiLoad") @@ -42,13 +44,19 @@ class DataLoader extends Feature { this.worldLoaded = true this.loadApi() + + this.firstLoaded = false } worldLoad() { this.area = undefined this.areaFine = undefined + this.loadApiData("skyblock", false) } + loadApiStepThing() { + this.loadApiData("skyblock", false) + } loadApi() { fetch("http://soopymc.my.to/api/v2/player_skyblock/" + Player.getUUID().replace(/-/g, "")).json(data => { @@ -87,6 +95,12 @@ class DataLoader extends Feature { } step() { //2fps + if (!this.firstLoaded) { + if (!(this.FeatureManager.features["globalSettings"] === undefined || this.FeatureManager.features["globalSettings"].class.apiKeySetting === undefined)) { + this.loadApiData("skyblock", false) + this.firstLoaded = true + } + } this.isInSkyblock = Scoreboard.getTitle()?.removeFormatting().includes("SKYBLOCK") if (!this.isInSkyblock) { @@ -151,11 +165,11 @@ class DataLoader extends Feature { this.area = this.stats["Area"] - if (this.lastServer !== this.FeatureManager.features["dataLoader"].class.stats.Server || Date.now() - this.lastSentServer > 60000 * 5) { - this.lastServer = this.FeatureManager.features["dataLoader"].class.stats.Server; + if (this.lastServer !== this.stats.Server || Date.now() - this.lastSentServer > 60000 * 5) { + this.lastServer = this.stats.Server; this.lastSentServer = Date.now() - socketConnection.setServer(this.FeatureManager.features["dataLoader"].class.stats.Server); + socketConnection.setServer(this.stats.Server, this.area, this.areaFine); } } diff --git a/features/dungeonMap/index.js b/features/dungeonMap/index.js index bdaaf23..40bd292 100644 --- a/features/dungeonMap/index.js +++ b/features/dungeonMap/index.js @@ -95,6 +95,7 @@ class DungeonMap extends Feature { this.bloodOpened = false this.registerChat("&r&cThe &r&c&lBLOOD DOOR&r&c has been opened!&r", () => { this.bloodOpened = true + this.keys-- }) this.registerChat("&r${*}&r&f &r&ehas obtained &r&a&r&${*} Key&r&e!&r", () => { @@ -438,7 +439,7 @@ class DungeonMap extends Feature { mapData = item.getItem()[m.getMapData](item.getItemStack(), World.getWorld()); // ItemStack.getItem().getMapData() } catch (error) { } - if (mapData) { + if (mapData && !this.boringMap) { this.mapData = mapData @@ -511,7 +512,7 @@ class DungeonMap extends Feature { roomWidth1++ } let roomWidth = Math.floor(Math.max(roomWidth1, roomWidth2) * 5 / 4) - console.log(roomWidth) + // console.log(roomWidth) this.mapScale = 32 / roomWidth let mortLocationOnMap roomOffsets = [rx % roomWidth - 3, ry % roomWidth - 3] diff --git a/features/dungeonSolvers/index.js b/features/dungeonSolvers/index.js index d753b43..8cd5da0 100644 --- a/features/dungeonSolvers/index.js +++ b/features/dungeonSolvers/index.js @@ -70,7 +70,7 @@ class DungeonSolvers extends Feature { .setToggleSetting(this.runSpeedRates) .setLocationSetting(new LocationSetting("Run speed and exp rates location", "Allows you to edit the location of the information", "run_speed_rates_location", this, [10, 100, 1, 1]).requires(this.runSpeedRates).editTempText("&6Run speed&7> &f4:30\n&6Exp/hour&7> &f1,234,567\n&6Runs/hour&7> &f17")); - this.scoreCalculation = new ToggleSetting("Show score calculation", "NOTE: doesent include mimic or spirit pet yet", true, "run_score_calc", this); + this.scoreCalculation = new ToggleSetting("Show score calculation", "", true, "run_score_calc", this); this.scoreElement = new HudTextElement().setToggleSetting(this.scoreCalculation).setLocationSetting(new LocationSetting("Score calculation location", "Allows you to edit the location of the score calc", "score_calc_location", this, [10, 130, 1, 1]).requires(this.scoreCalculation).editTempText("&dScore: 120\n&aS+ ??\n&aS ??")); this.hudElements.push(this.runSpeedRatesElement); @@ -249,6 +249,68 @@ class DungeonSolvers extends Feature { this.renderEntityEvent = undefined; this.onWorldLoad(); + + + //TODO: finish this + // let saidLocations = new Set() + // let data = [] + // let area = 0 + // this.registerChat("", () => { + // area++ + // }) + // this.registerStep(false, 3, () => { + // World.getAllEntities().forEach(e => { + // if (ChatLib.removeFormatting(e.getName()).toLowerCase().includes("inactive device")) { + // addThing([Math.trunc(e.getX()), Math.trunc(e.getY()), Math.trunc(e.getZ())], "device") + // } + // if (ChatLib.removeFormatting(e.getName()).toLowerCase().includes("inactive terminal")) { + // addThing([Math.trunc(e.getX()), Math.trunc(e.getY()), Math.trunc(e.getZ())], "terminal") + // } + // if (ChatLib.removeFormatting(e.getName()).toLowerCase().includes("not activated")) { + // addThing([Math.trunc(e.getX()), Math.trunc(e.getY()), Math.trunc(e.getZ())], "lever") + // } + // }) + // }) + + // function addThing(location, type) { + // if (saidLocations.has(location.join(","))) return + + // saidLocations.add(location.join(",")) + + // if (type === "lever") { + // let finalLoc = undefined + // for (let i = 5; i > -5; i--) { + // if (World.getBlockAt(location[0], location[1] + i, location[2])?.getType()?.getID() === 69) { + // finalLoc = [location[0], location[1] + i, location[2]] + // } + // } + // data.push({ type: "lever", location: finalLoc, phase: area }) + // return + // } + // if (type === "terminal") { + // let finalLoc = undefined + // for (let x = 5; x > -5; x--) { + // for (let y = 5; y > -5; y--) { + // for (let z = 5; z > -5; z--) { + // if (World.getBlockAt(location[0] + x, location[1] + y, location[2] + x)?.getType()?.getID() === 137) { + // finalLoc = [location[0] + x, location[1] + y, location[2] + x] + // } + // } + // } + // } + // data.push({ type: "terminal", location: finalLoc, phase: area }) + // return + // } + // data.push({ type: type, location: location, phase: area }) + // } + + // this.registerCommand("getdata", () => { + // ChatLib.chat(JSON.stringify(data)) + // }) + + //§r§6Soopyboo32§r§a activated a lever! (§r§c8§r§a/8)§r + //§r§6Soopyboo32§r§a completed a device! (§r§c3§r§a/8)§r + //§r§bBossmanLeo§r§a activated a terminal! (§r§c2§r§a/8)§r } step_5min() { diff --git a/features/events/index.js b/features/events/index.js index e3decc5..d1a075d 100644 --- a/features/events/index.js +++ b/features/events/index.js @@ -382,7 +382,7 @@ class Events extends Feature { }) } - if (!this.potentialParticleLocs[locstr]) this.potentialParticleLocs[locstr] = { enchant: 0, crit: 0, step: 0, isMob: 0, timestamp: Date.now() } + if (!this.potentialParticleLocs[locstr] || Date.now() - this.potentialParticleLocs[locstr].timestamp > 30000) this.potentialParticleLocs[locstr] = { enchant: 0, crit: 0, step: 0, isMob: 0, timestamp: Date.now() } if (foundEnchant) this.potentialParticleLocs[locstr].enchant++ if (foundCrit) this.potentialParticleLocs[locstr].crit++ diff --git a/features/eventsGUI/index.js b/features/eventsGUI/index.js index c828f85..d13d792 100644 --- a/features/eventsGUI/index.js +++ b/features/eventsGUI/index.js @@ -1,7 +1,17 @@ /// <reference types="../../../CTAutocomplete" /> /// <reference lib="es2015" /> +import Enum from "../../../guimanager/Enum"; +import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent"; import BoxWithLoading from "../../../guimanager/GuiElement/BoxWithLoading"; +import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow"; +import SoopyGuiElement from "../../../guimanager/GuiElement/SoopyGuiElement"; +import SoopyMarkdownElement from "../../../guimanager/GuiElement/SoopyMarkdownElement"; +import SoopyTextElement from "../../../guimanager/GuiElement/SoopyTextElement"; +import TextBox from "../../../guimanager/GuiElement/TextBox"; import Feature from "../../featureClass/class"; +import socketConnection from "../../socketConnection"; +import { timeSince } from "../../utils/numberUtils"; +import { firstLetterCapital } from "../../utils/stringUtils"; import GuiPage from "../soopyGui/GuiPage"; class EventsGui extends Feature { @@ -12,10 +22,23 @@ class EventsGui extends Feature { onEnable() { this.initVariables() - // this.GuiPage = new EventsPage() //TODO: SOON(tm) + this.GuiPage = new EventsPage() // this.registerChat("&9&m-----------------------------------------------------&r&9${*}&r&9 ${*} &6Friends (Page ${pagenum} of ${maxpages})${friendslist}&r&9&m-----------------------------------------------------&r", (...args) => { this.GuiPage.friendListMessageEvent.call(this.GuiPage, ...args) }) - // this.registerStep(true, 5, () => { this.GuiPage.regenGuiElements.call(this.GuiPage) }) + this.registerStep(true, 5, () => { this.GuiPage.regenGuiElements.call(this.GuiPage) }) + this.registerStep(false, 60, () => { this.GuiPage.pollData.call(this.GuiPage) }) + } + + eventsDataUpdated(data) { + this.GuiPage.eventsDataUpdated(data) + } + + joinEventResult(data) { + this.GuiPage.joinEventResult(data) + } + + pollEventData(admin) { + this.GuiPage.pollEventData(admin) } initVariables() { @@ -32,17 +55,207 @@ class EventsPage extends GuiPage { constructor() { super(8) - this.name = "Guild Events" + this.name = "Events" this.pages = [this.newPage()] - this.pages[0].addChild(new BoxWithLoading().setLocation(0.3, 0.3, 0.4, 0.4)) + this.leaderboardElm = undefined + this.memberData = undefined + + this.lastScroll = 1 + + this.leaderboardChildren = [] + + this.code = undefined this.finaliseLoading() } + updateNotInEvent() { + this.pages[0].clearChildren() + + this.pages[0].addChild(new SoopyTextElement().setText("§0You are not currently in any events").setMaxTextScale(3).setLocation(0.2, 0.1, 0.6, 0.2)) + this.pages[0].addChild(new SoopyTextElement().setText("§0If you have a join code enter it here").setMaxTextScale(1).setLocation(0.3, 0.4, 0.4, 0.1)) + let joinBox = new TextBox().setPlaceholder("Code here").setLocation(0.3, 0.5, 0.4, 0.1) + this.pages[0].addChild(joinBox) + + this.pages[0].addChild(new ButtonWithArrow().setLocation(0.35, 0.6, 0.3, 0.1).setText("§0Join Event").addEvent(new SoopyMouseClickEvent().setHandler(() => { + + let code = joinBox.getText() + + this.pages[0].clearChildren() + this.pages[0].addChild(new BoxWithLoading().setLocation(0.3, 0.3, 0.4, 0.4)) + + socketConnection.pollEventCode(code) + + this.code = code + }))) + } + + updateInEvent(data) { + //MAIN PAGE + + this.pages[0].clearChildren() + + this.pages[0].addChild(new SoopyTextElement().setText("§0You are curently in an event managed by §6" + data.admin).setMaxTextScale(3).setLocation(0.1, 0.05, 0.8, 0.2)) + + if (!data.members[Player.getUUID().toString().replace(/-/g, "")]) { + this.pages[0].addChild(new ButtonWithArrow().setText("Join").setLocation(0.05, 0.2, 0.1, 0.05).addEvent(new SoopyMouseClickEvent().setHandler(() => { + this.pages[0].clearChildren() + this.pages[0].addChild(new BoxWithLoading().setLocation(0.3, 0.3, 0.4, 0.4)) + + socketConnection.pollEventCode(data.code) + + this.code = data.code + }))) + } + + let leaderboard = new SoopyGuiElement().setLocation(0.1, 0.3, 0.8, 0.7).setScrollable(true) + + this.pages[0].addChild(leaderboard) + + let playerPosition = -1 + + if (this.leaderboardElm) { + let scroll = this.leaderboardElm._scrollAmount + + leaderboard._scrollAmount = scroll + leaderboard.location.scroll.y.set(scroll, 0) + } + + this.leaderboardElm = leaderboard + + Object.values(data.members).sort((a, b) => b.progress - a.progress).forEach((m, i) => { + let isPlayer = m.uuid === Player.getUUID().toString().replace(/-/g, "") + + if (isPlayer) playerPosition = i + 1 + + let nameLine = new SoopyTextElement().setText(`${isPlayer ? "§d" : "§0"}#${i + 1} ${m.username}`).setLocation(0, i * 0.05, 0.5, 0.05).setLore(["Last updated " + timeSince(m.timestamp) + " ago"]) + nameLine.timestamp = m.timestamp + leaderboard.addChild(nameLine) + leaderboard.addChild(new SoopyTextElement().setText(`§0+${Math.floor(m.progress)}`).setLocation(0.5, i * 0.05, 0.5, 0.05)) + }) + + this.leaderboardChildren = [...leaderboard.children] + + this.lastScroll = 1 + + if (playerPosition >= 0) { + this.pages[0].addChild(new SoopyTextElement().setText("§0You are #" + playerPosition + " with +" + Math.floor(data.members[Player.getUUID().toString().replace(/-/g, "")].progress)).setMaxTextScale(2).setLocation(0.2, 0.2, 0.6, 0.1)) + } + + // SIDEBAR + + let sideBarElm = new SoopyGuiElement().setLocation(0, 0, 1, 1).setScrollable(true) + + sideBarElm.addChild(new SoopyTextElement().setText("§0Event Settings").setMaxTextScale(3).setLocation(0.1, 0, 0.8, 0.2)) + + sideBarElm.addChild(new SoopyMarkdownElement().setLocation(0.05, 0.2, 0.9, 1).setText("# Tracking: \n" + data.settings.tracking.map(a => firstLetterCapital(a.replace(/\w+?_/, "").replace(/_/g, " "))).join("\n"))) + + this.openSidebarPage(sideBarElm) + } + + regenGuiElements() { + if (!this.isOpen()) return + + if (this.leaderboardElm) { + let scroll = this.leaderboardElm.location.scroll.y.get() + if (this.lastScroll !== scroll) { + this.lastScroll = scroll + + this.leaderboardElm.children = [] + + let min = this.leaderboardElm.location.getYExact() - 100 + let max = min + 200 + this.leaderboardElm.location.getHeightExact() + let lastChildNotAdded = undefined + this.leaderboardChildren.forEach(c => { + c.setParent(this.leaderboardElm) + c.triggerEvent(Enum.EVENT.RESET_FRAME_CACHES) + + let y = c.location.getYExact() + + if (y > min && y < max) { + this.leaderboardElm.children.push(c) + } else { + lastChildNotAdded = c + } + }) + + if (lastChildNotAdded) { + this.leaderboardElm.children.push(lastChildNotAdded) + } + } + + + this.leaderboardChildren.forEach(c => { + if (c.timestamp) { + c.setLore(["Last updated " + timeSince(c.timestamp) + " ago"]) + } + }) + } + } + + eventsDataUpdated(data) { + if (!data.inEvent) { + this.updateNotInEvent() + return + } + + this.updateInEvent(data) + } + + pollEventData(admin) { + if (!admin) { + this.updateNotInEvent() + this.pages[0].addChild(new SoopyTextElement().setText("§cInvalid code").setMaxTextScale(3).setLocation(0.2, 0.7, 0.6, 0.2)) + return + } + this.pages[0].clearChildren() + this.pages[0].addChild(new SoopyTextElement().setText("§0Join §6" + admin + "§0's event?").setMaxTextScale(3).setLocation(0.2, 0.2, 0.6, 0.2)) + this.pages[0].addChild(new ButtonWithArrow().setText("§0Join").setLocation(0.4, 0.4, 0.4, 0.3).addEvent(new SoopyMouseClickEvent().setHandler(() => { + socketConnection.joinEvent(this.code) + this.pages[0].clearChildren() + this.pages[0].addChild(new BoxWithLoading().setLocation(0.3, 0.3, 0.4, 0.4)) + }))) + this.pages[0].addChild(new ButtonWithArrow().setText("§0Cancel").setLocation(0.2, 0.4, 0.2, 0.3).setDirectionRight(false).addEvent(new SoopyMouseClickEvent().setHandler(() => { + this.updateNotInEvent() + }))) + } + + joinEventResult(data) { + this.pages[0].clearChildren() + if (data.success) { + this.pages[0].addChild(new SoopyTextElement().setText("§0Joined event!").setMaxTextScale(3).setLocation(0.2, 0.2, 0.6, 0.2)) + this.pages[0].addChild(new ButtonWithArrow().setText("§0Ok").setLocation(0.3, 0.4, 0.4, 0.4).addEvent(new SoopyMouseClickEvent().setHandler(() => { + this.pages[0].clearChildren() + this.pages[0].addChild(new BoxWithLoading().setLocation(0.3, 0.3, 0.4, 0.4)) + + socketConnection.pollEventData() + }))) + } else { + this.pages[0].addChild(new SoopyTextElement().setText("§0Unable to join event!").setMaxTextScale(3).setLocation(0.2, 0.2, 0.6, 0.1)) + this.pages[0].addChild(new SoopyTextElement().setText("§0" + data.reason).setMaxTextScale(3).setLocation(0.2, 0.3, 0.6, 0.1)) + this.pages[0].addChild(new ButtonWithArrow().setText("§0Ok").setLocation(0.3, 0.4, 0.4, 0.4).addEvent(new SoopyMouseClickEvent().setHandler(() => { + this.pages[0].clearChildren() + this.pages[0].addChild(new BoxWithLoading().setLocation(0.3, 0.3, 0.4, 0.4)) + + socketConnection.pollEventData() + }))) + } + } + + pollData() { + if (!this.isOpen()) return + + socketConnection.pollEventData() + } + onOpen() { + this.pages[0].clearChildren() + this.pages[0].addChild(new BoxWithLoading().setLocation(0.3, 0.3, 0.4, 0.4)) + this.leaderboardElm = undefined + socketConnection.pollEventData() } } diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js index b77fd0e..ef566c9 100644 --- a/features/globalSettings/index.js +++ b/features/globalSettings/index.js @@ -73,6 +73,27 @@ class GlobalSettings extends Feature { this.registerEvent("tick", this.fixNEU) } + try { //This enables links from soopymc.my.to to be shown in patcher image preview + let hasHost = false + + for (let host of Java.type("gg.essential.util.TrustedHostsUtil").INSTANCE.getTrustedHosts()) { + if (host.getName() === "soopymc") { + hasHost = true + } + } + + if (!hasHost) { + let TrustedHost = Java.type("gg.essential.api.utils.TrustedHostsUtil").TrustedHost + let TreeSet = Java.type("java.util.TreeSet") + let hosts = new TreeSet() + hosts.add("soopymc.my.to") + + let host = new TrustedHost(124123, "soopymc", hosts) + + Java.type("gg.essential.util.TrustedHostsUtil").INSTANCE.addTrustedHost(host) + } + } catch (e) { } + this.registerCommand("soopyweight", (user = Player.getName()) => { this.soopyWeight(user) }) diff --git a/features/hud/index.js b/features/hud/index.js index 7d07085..8462963 100644 --- a/features/hud/index.js +++ b/features/hud/index.js @@ -253,10 +253,11 @@ class Hud extends Feature { this.lastSwappedPet = Date.now() }) this.registerChat("&r&aYour &r${pet} &r&alevelled up to level &r&9${level}&r&a!&r", (pet, level) => { - this.petElement.setText("&6Pet&7> &7[Lvl " + (level || "??") + "] " + pet) - this.petText = "&6Pet&7> &7[Lvl " + (level || "??") + "] " + pet - - this.lastSwappedPet = Date.now() + if (this.petText.split("] ")[1] === pet) { + this.petElement.setText("&6Pet&7> &7[Lvl " + (level || "??") + "] " + pet) + this.petText = "&6Pet&7> &7[Lvl " + (level || "??") + "] " + pet + this.lastSwappedPet = Date.now() + } }) this.registerSoopy("apiLoad", this.apiLoad) @@ -450,7 +451,7 @@ class Hud extends Feature { if (Date.now() - this.lastSwappedPet > 1000) { inv[i].getLore().forEach(line => { - if (line.includes("Click to despawn.")) { + if (line.includes("Click to despawn!")) { this.petElement.setText("&6Pet&7> &7" + inv[i].getName().split("(")[0]) this.petText = "&6Pet&7> &7" + inv[i].getName().split("(")[0] } @@ -484,13 +485,6 @@ class Hud extends Feature { this.petElement.setText(this.petText) } - if (Date.now() - this.lastUpdatedStatData > 5 * 60000) { - - this.FeatureManager.features["dataLoader"].class.loadApiData("skyblock", false) - - this.lastUpdatedStatData = Date.now() - } - let soulflowCount = 0 let hasSoulflowItem = false Player.getInventory().getItems().forEach(i => { @@ -642,13 +636,6 @@ class Hud extends Feature { updateHudThingos() { let insb = this.FeatureManager.features["dataLoader"].class.isInSkyblock - if (Date.now() - this.lastUpdatedStatData > 5 * 60000 && this.hudStat[0].enabled.getValue() && (!this.lastStatData || insb || this.hudStat.map(a => (!a.enabled.getValue() || a.onlySb.getValue())).includes(false))) { - - this.FeatureManager.features["dataLoader"].class.loadApiData("skyblock", false) - - this.lastUpdatedStatData = Date.now() - return - } this.hudStat.forEach(stat => { if (stat.enabled.getValue()) { diff --git a/features/mining/index.js b/features/mining/index.js index 8c6ce12..d028450 100644 --- a/features/mining/index.js +++ b/features/mining/index.js @@ -7,13 +7,20 @@ import * as utils from "../../utils/utils" import HudTextElement from "../hud/HudTextElement"; import LocationSetting from "../settings/settingThings/location"; import ToggleSetting from "../settings/settingThings/toggle"; -import { numberWithCommas } from "../../utils/numberUtils"; +import { numberWithCommas, timeSince2 } from "../../utils/numberUtils"; +import { fetch } from "../../utils/networkUtils"; +import socketConnection from "../../socketConnection"; class Mining extends Feature { constructor() { super() } + isInCH() { + if (!this.FeatureManager || !this.FeatureManager.features["dataLoader"]) return false + return this.FeatureManager.features["dataLoader"].class.area === "Crystal Hollows" + } + onEnable() { this.initVariables() @@ -42,6 +49,22 @@ class Mining extends Feature { this.hudElements.push(this.compactHudElement) this.compactProgressHudOnlyWhenMoreThan0 = new ToggleSetting("Only show compact progress when it is above 0", "So that you dont need to disable it when you start doing something else", true, "compact_progress_disable_0", this).requires(this.compactProgressHud) + this.gemstoneMoneyHud = new ToggleSetting("Show $/h made from gemstone mining", "This will add a HUD element with the gemstone $/h", true, "gemstone_money_hud", this) + this.gemstoneMoneyHudElement = new HudTextElement() + .setToggleSetting(this.gemstoneMoneyHud) + .setLocationSetting(new LocationSetting("HUD Location", "Allows you to edit the location of the gemstone $/h", "gemstone_money_location", this, [10, 60, 1, 1]) + .requires(this.gemstoneMoneyHud) + .editTempText("&6$/h&7> &f$12,345,678\n&6$ made&7> &f$123,456,789\n&6Time tracked&7> &f123m")) + this.hudElements.push(this.gemstoneMoneyHudElement) + + this.nextChEvent = new ToggleSetting("Show the current and next crystal hollows event", "(syncs the data between all users in ch)", true, "chevent_hud", this) + this.nextChEventElement = new HudTextElement() + .setToggleSetting(this.nextChEvent) + .setLocationSetting(new LocationSetting("HUD Location", "Allows you to edit the location of the hud element", "chevent_hud_location", this, [10, 70, 1, 1]) + .requires(this.nextChEvent) + .editTempText("&6Event&7> &fGONE WITH THE WIND &7->&f 2X POWDER")) + this.hudElements.push(this.nextChEventElement) + this.seenBalDamages = [] this.balHP = 250 this.lastBalAlive = 0 @@ -75,6 +98,73 @@ class Mining extends Feature { this.registerChat("&r&c&oThe boss looks weak and tired and retreats into the lava...&r", () => { this.balHP = 0 }) + + let startingTime = -1 + let money = 0 + let gemstoneCosts = {} + let lastMined = 0 + this.registerChat("&r&d&lPRISTINE! &r&fYou found &r${*} &r&aFlawed ${type} Gemstone &r&8x${num}&r&f!&r", (type, num, event) => { + + let id = "FLAWED_" + type.toUpperCase() + "_GEM" + let number = parseInt(num) + + lastMined = Date.now() + + if (!this.gemstoneMoneyHud.getValue()) return + + if (startingTime === 0) return + if (startingTime === -1) { + startingTime = 0 + fetch("https://api.hypixel.net/skyblock/bazaar").json(data => { + startingTime = Date.now() + + Object.keys(data.products).forEach(id => { + if (id.startsWith("FLAWED_")) { + gemstoneCosts[id] = Math.max(240, data.products[id].quick_status.sellPrice) + // console.log(id + ": " + gemstoneCosts[id]) + } + }) + }) + return + } + + money += gemstoneCosts[id] * number + + let moneyPerHour = Math.floor(money / ((Date.now() - startingTime) / (1000 * 60 * 60))) + let moneyMade = Math.floor(money) + let timeTracked = timeSince2(startingTime) + + this.gemstoneMoneyHudElement.setText("&6$/h&7> &f$" + numberWithCommas(moneyPerHour) + "\n&6$ made&7> &f$" + numberWithCommas(moneyMade) + "\n&6Time tracked&7> &f" + timeTracked) + }) + this.registerStep(false, 10, () => { + if (lastMined && Date.now() - lastMined > 2 * 60000) { + money = 0 + startingTime = -1 + lastMined = 0 + this.gemstoneMoneyHudElement.setText("") + } + + this.nextChEventElement.setText("&6Event&7> &f" + socketConnection.chEvent.join(" &7->&f ")) + }) + + let lastWorldChange = 0 + + this.registerEvent("worldLoad", () => { + lastWorldChange = Date.now() + }) + + this.registerChat("&r&r&r ${spaces}&r&${color}&l${event} ENDED!&r", (spaces, color, event) => { + if (Date.now() - lastWorldChange < 5000) return + if (!this.isInCH()) return + + socketConnection.sendCHEventData(event.trim(), false) + }) + this.registerChat("&r&r&r ${spaces}&r&${color}&l${event} STARTED!&r", (spaces, color, event) => { + if (Date.now() - lastWorldChange < 5000) return + if (!this.isInCH()) return + + socketConnection.sendCHEventData(event.trim(), true) + }) } itemTooltipEvent(lore, item, event) { diff --git a/features/nether/index.js b/features/nether/index.js index 67accbc..52d1041 100644 --- a/features/nether/index.js +++ b/features/nether/index.js @@ -89,8 +89,8 @@ class Nether extends Feature { }) } - vanqData(loc) { - this.spawnedVanqs.push([...loc, Date.now()]) + vanqData(loc, name) { + this.spawnedVanqs.push([loc, name, Date.now()]) } tick() { @@ -212,8 +212,8 @@ class Nether extends Feature { } if (this.vaniquisherWaypoints.getValue()) { - Object.keys(this.spawnedVanqs).forEach(key => { - drawCoolWaypoint(this.spawnedVanqs[key][0], this.spawnedVanqs[key][1], this.spawnedVanqs[key][2], 255, 0, 0, { name: key + "'s vanquisher (" + Math.floor((Date.now() - this.spawnedVanqs[key][2]) / 1000) + "s)" }) + this.spawnedVanqs.forEach(vanq => { + drawCoolWaypoint(vanq[0][0], vanq[0][1], vanq[0][2], 255, 0, 0, { name: vanq[1] + "'s vanquisher (" + Math.floor((Date.now() - vanq[2]) / 1000) + "s)" }) }) } @@ -232,7 +232,7 @@ class Nether extends Feature { step1S() { if (this.blocks) this.blocks = this.blocks.filter(state => Date.now() < state.time) if (this.dojoFireBalls) this.dojoFireBalls = this.dojoFireBalls.filter(e => !e[f.isDead]) - if (this.spawnedVanqs) this.spawnedVanqs = this.spawnedVanqs.filter(a => Date.now() - a[3] < 60000) + if (this.spawnedVanqs) this.spawnedVanqs = this.spawnedVanqs.filter(a => Date.now() - a[2] < 60000) } getBlockIdFromState(state) { diff --git a/features/soopyGui/GuiPage.js b/features/soopyGui/GuiPage.js index f5ac9a5..7a21d26 100644 --- a/features/soopyGui/GuiPage.js +++ b/features/soopyGui/GuiPage.js @@ -19,7 +19,13 @@ class GuiPage { } getSoopyGui() { - return global.soopyv2featuremanagerthing.features["soopyGui"].class + if (global.soopyv2featuremanagerthing.features["soopyGui"]) return global.soopyv2featuremanagerthing.features["soopyGui"].class; + } + + isOpen() { + if (!this.getSoopyGui()?.gui?.ctGui?.isOpen()) return false + + return this.getSoopyGui()?.currCategory === this } newPage() { diff --git a/features/soopyGui/index.js b/features/soopyGui/index.js index 4c8f571..32ac1a7 100644 --- a/features/soopyGui/index.js +++ b/features/soopyGui/index.js @@ -29,7 +29,7 @@ class SoopyGui extends Feature { this.activeCategory = undefined } - onEnable(){ + onEnable() { this.gui = new SoopyGui2() // this.gui.isDebugEnabled = true @@ -39,23 +39,23 @@ class SoopyGui extends Feature { this.mainWindowElement = new SoopyBoxElement().setLocation(0.25, 0.2, 0.5, 0.6) - this.mainWindowElement.addEvent(new SoopyOpenGuiEvent().setHandler(()=>{this.goToPageNum(0, false)})) + this.mainWindowElement.addEvent(new SoopyOpenGuiEvent().setHandler(() => { this.goToPageNum(0, false) })) //############################################################################################### // Category Page //############################################################################################### this.categoryPage = new SoopyGuiElement().setLocation(0, 0, 1, 1) - + let title = new SoopyTextElement().setText("§0SoopyV2!").setMaxTextScale(3).setLocation(0.1, 0.05, 0.5, 0.1) this.categoryPage.addChild(title) let discordButton = new ButtonWithArrow().setText("§0Discord").setLocation(0.7, 0.05, 0.25, 0.1) - discordButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + discordButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { java.awt.Desktop.getDesktop().browse( new java.net.URI("https://discord.gg/dfSMq96RSN") - ); - })) + ); + })) this.categoryPage.addChild(discordButton) this.buttonListElm = new SoopyGuiElement().setLocation(0.1, 0.2, 0.8, 0.8).setScrollable(true) @@ -64,11 +64,11 @@ class SoopyGui extends Feature { //############################################################################################### // Back button for all second pages //############################################################################################### - + this.backButton = new TextWithArrow().setText("§0Back").setLocation(0.01, -0.2, 0.1, 0.1).setDirectionRight(false) - let backButtonEvent = new SoopyMouseClickEvent().setHandler(()=>{this.clickedBackButton()}) + let backButtonEvent = new SoopyMouseClickEvent().setHandler(() => { this.clickedBackButton() }) this.backButton.addEvent(backButtonEvent) - + this.mainWindowElement.addChild(this.categoryPage) this.sidebarPage = new SoopyBoxElement().setLocation(0.3, 0.2, 0.3, 0.6) @@ -76,43 +76,43 @@ class SoopyGui extends Feature { this.gui.element.addChild(this.sidebarPage) this.gui.element.addChild(this.mainWindowElement) - + this.mainWindowElement.addChild(this.backButton) this.updateButtons() } - openCommand(page){ + openCommand(page) { this.gui.open() - if(page){ - this.getPages().forEach(p=>{ - if(p.name.replace(/ /g, "_").toLowerCase() === page.toLowerCase()){ + if (page) { + this.getPages().forEach(p => { + if (p.name.replace(/ /g, "_").toLowerCase() === page.toLowerCase()) { this.clickedOpen(p, false) } }) } } - getPages(){ + getPages() { return categoryManager.arr } - updateButtons(){ - if(!this.buttonListElm) return; + updateButtons() { + if (!this.buttonListElm) return; this.buttonListElm.children = [] - this.getPages().forEach((p, i)=>{ - let settingsButton = new ButtonWithArrow().setText("§0" + p.name).setLocation(0, 0.225*i, 1, 0.2) - settingsButton.addEvent(new SoopyMouseClickEvent().setHandler(()=>{this.clickedOpen(p)})) + this.getPages().forEach((p, i) => { + let settingsButton = new ButtonWithArrow().setText("§0" + p.name).setLocation(0, 0.225 * i, 1, 0.2) + settingsButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { this.clickedOpen(p) })) this.buttonListElm.addChild(settingsButton) }) } - clickedOpen(category, anim=true){ - if(!this.lastClickedOpen)this.lastClickedOpen = 0 - if(Date.now()-this.lastClickedOpen < 100) return //Stopping infinite loop where button getting reset causes click event to get fired again + clickedOpen(category, anim = true) { + if (!this.lastClickedOpen) this.lastClickedOpen = 0 + if (Date.now() - this.lastClickedOpen < 100) return //Stopping infinite loop where button getting reset causes click event to get fired again this.lastClickedOpen = Date.now() let theParent = this.mainWindowElement.innerObjectPaddingThing || this.mainWindowElement @@ -124,7 +124,7 @@ class SoopyGui extends Feature { this.activePages = category.pages this.currCategory = category - Object.values(this.activePages).forEach(p=>{ + Object.values(this.activePages).forEach(p => { this.mainWindowElement.addChild(p) }) @@ -133,7 +133,7 @@ class SoopyGui extends Feature { this.goToPageNum(1, anim) } - onDisable(){ + onDisable() { this.gui.delete() this.gui = undefined @@ -145,50 +145,50 @@ class SoopyGui extends Feature { this.lastClickedOpen = undefined } - clickedBackButton(){ - this.goToPageNum(this.currentPage-1) + clickedBackButton() { + this.goToPageNum(this.currentPage - 1) } - goToPage(page, animate=true){ + goToPage(page, animate = true) { let pageNum = page._soopyAddonsPageId - - if(pageNum == this.currentPage){ + + if (pageNum == this.currentPage) { return } this.currentPage = pageNum - this.getPages().forEach((p)=>{ - Object.values(p.pages).forEach((e, i)=>{ - e.location.location.x.set(i-pageNum+1, animate?500:0) + this.getPages().forEach((p) => { + Object.values(p.pages).forEach((e, i) => { + e.location.location.x.set(i - pageNum + 1, animate ? 500 : 0) }) }) - this.categoryPage.location.location.x.set(-pageNum, animate?500:0) + this.categoryPage.location.location.x.set(-pageNum, animate ? 500 : 0) - this.backButton.location.location.y.set((pageNum === 0 || !this.currCategory.showBackButton)?-0.2:0, animate?500:0) + this.backButton.location.location.y.set((pageNum === 0 || !this.currCategory.showBackButton) ? -0.2 : 0, animate ? 500 : 0) } - goToPageNum(pageNum, animate=true){ - if(pageNum<0) return; + goToPageNum(pageNum, animate = true) { + if (pageNum < 0) return; this.currentPage = pageNum - if(pageNum===0){ + if (pageNum === 0) { this.currCategory = undefined this.closeSidebarPage() this.updateButtons() } - this.getPages().forEach((p)=>{ - Object.values(p.pages).forEach((e, i)=>{ - e.location.location.x.set(i-pageNum+1, animate?500:0) + this.getPages().forEach((p) => { + Object.values(p.pages).forEach((e, i) => { + e.location.location.x.set(i - pageNum + 1, animate ? 500 : 0) }) }) - this.categoryPage.location.location.x.set(-pageNum, animate?500:0) + this.categoryPage.location.location.x.set(-pageNum, animate ? 500 : 0) - this.backButton.location.location.y.set((pageNum === 0 || !this.currCategory.showBackButton)?-0.2:0, animate?500:0) + this.backButton.location.location.y.set((pageNum === 0 || !this.currCategory.showBackButton) ? -0.2 : 0, animate ? 500 : 0) - if(this.currCategory) this.currCategory.onOpenPage(pageNum) + if (this.currCategory) this.currCategory.onOpenPage(pageNum) } - openSidebarPage(child){ + openSidebarPage(child) { this.sidebarPage.location.location.x.set(0.625, 500) this.mainWindowElement.location.location.x.set(0.075, 500) @@ -197,7 +197,7 @@ class SoopyGui extends Feature { this.sidebarPage.addChild(child) } - closeSidebarPage(){ + closeSidebarPage() { this.sidebarPage.location.location.x.set(0.3, 500) this.mainWindowElement.location.location.x.set(0.25, 500) diff --git a/metadata.json b/metadata.json index 669b79d..94aa816 100644 --- a/metadata.json +++ b/metadata.json @@ -5,8 +5,8 @@ "entry": "index.js", "description": "SoopyV2", "name": "SoopyV2", - "version": "2.1.81", - "versionId": 208, + "version": "2.1.91", + "versionId": 218, "requires": [ "soopyApis", "soopyAddonsData", diff --git a/socketConnection.js b/socketConnection.js index b032d39..70609ec 100644 --- a/socketConnection.js +++ b/socketConnection.js @@ -20,10 +20,14 @@ class SoopyV2Server extends WebsiteCommunicator { this.userCosmeticPermissions = undefined + this.eventData = undefined + this.cookieCount = 0 this.cookieData = undefined this.cookieDataUpdated = 0 + this.chEvent = ["???", "???"] + register("step", () => { if (this.cookieDataUpdated && Date.now() - this.cookieDataUpdated > 60000) { this.cookieData = 0 @@ -74,10 +78,17 @@ class SoopyV2Server extends WebsiteCommunicator { this.cookieDataUpdated = Date.now() } if (data.type === "joinEventResult") { - console.log(JSON.stringify(data, undefined, 2)) + if (global.soopyv2featuremanagerthing && global.soopyv2featuremanagerthing.features.eventsGUI) global.soopyv2featuremanagerthing.features.eventsGUI.class.joinEventResult(data.response) } if (data.type === "eventData") { - console.log(JSON.stringify(data, undefined, 2)) + this.eventData = data + if (global.soopyv2featuremanagerthing && global.soopyv2featuremanagerthing.features.eventsGUI) global.soopyv2featuremanagerthing.features.eventsGUI.class.eventsDataUpdated(data) + } + if (data.type === "pollEvent") { + if (global.soopyv2featuremanagerthing && global.soopyv2featuremanagerthing.features.eventsGUI) global.soopyv2featuremanagerthing.features.eventsGUI.class.pollEventData(data.admin) + } + if (data.type === "chEvent") { + this.chEvent = data.event } } @@ -159,14 +170,14 @@ class SoopyV2Server extends WebsiteCommunicator { this.sendData({ type: "slayerSpawnData", data: data, - name: Player.getDisplayName().text + name: ChatLib.removeFormatting(Player.getDisplayName().text) }) } sendInquisData(data) { this.sendData({ type: "inquisData", data: data, - name: Player.getDisplayName().text + name: ChatLib.removeFormatting(Player.getDisplayName().text) }) } @@ -174,14 +185,16 @@ class SoopyV2Server extends WebsiteCommunicator { this.sendData({ type: "vancData", data: data, - name: Player.getDisplayName().text + name: ChatLib.removeFormatting(Player.getDisplayName().text) }) } - setServer(server) { + setServer(server, area, areaFine) { this.sendData({ type: "server", - server: server + server, + area, + areaFine }) } @@ -206,6 +219,21 @@ class SoopyV2Server extends WebsiteCommunicator { type: "eventData" }) } + + pollEventCode(code) { + this.sendData({ + type: "pollEvent", + code + }) + } + + sendCHEventData(event, started) { + this.sendData({ + type: "chEvent2", + event, + started + }) + } } if (!global.soopyV2Server) { diff --git a/utils/numberUtils.js b/utils/numberUtils.js index 96a6b74..597a538 100644 --- a/utils/numberUtils.js +++ b/utils/numberUtils.js @@ -1,11 +1,11 @@ -module.exports = { - numberWithCommas: function(x){ +let utils = { + numberWithCommas: function (x) { if (x === undefined) { return "" } var parts = x.toString().split("."); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); return parts.join("."); }, - addNotation: function(type, value) { + addNotation: function (type, value) { let returnVal = value; let notList = []; if (type === "shortScale") { @@ -47,14 +47,14 @@ module.exports = { return returnVal; }, - timeSince:function (date) { + timeSince: function (date) { if (typeof date !== 'object') { date = new Date(date); } - - var seconds = Math.floor((new Date()-date) / 1000); + + var seconds = Math.floor((new Date() - date) / 1000); var intervalType; - + var interval = Math.floor(seconds / 31536000); interval = Math.floor(seconds / 86400); if (interval >= 1) { @@ -73,21 +73,30 @@ module.exports = { } } } - + return interval + '' + intervalType; }, - timeNumber: function(time){ - let mins = Math.floor(time/1000/60) - let secs = Math.floor(time/1000)%60 - - if(mins === 0) return secs + "s" + timeSince2: (date) => { + let time = Date.now() - date + + if (time > 30 * 60000) { + return utils.timeNumber2(time) + } + return utils.timeNumber(time) + }, + timeNumber: (time) => { + let mins = Math.floor(time / 1000 / 60) + let secs = Math.floor(time / 1000) % 60 + + if (mins === 0) return secs + "s" return `${mins}m ${secs}s` }, - timeNumber2: function(time){ - let hours = Math.floor(time/1000/60/60) - let mins = Math.floor(time/1000/60)%60 - - if(hours === 0) return mins + "m" + timeNumber2: (time) => { + let hours = Math.floor(time / 1000 / 60 / 60) + let mins = Math.floor(time / 1000 / 60) % 60 + + if (hours === 0) return mins + "m" return `${hours}h ${mins}m` } -}
\ No newline at end of file +} +module.exports = utils
\ No newline at end of file |