From 8d8101f8e60d964a3bf13fbb8427786aa78804f9 Mon Sep 17 00:00:00 2001 From: Allen Zheng Date: Wed, 17 Jan 2024 16:59:43 -0500 Subject: [PATCH] Added mana drain range --- changelog.json | 4 +++- features/combat/EntityDetect.js | 2 +- features/combat/ManaDrain.js | 37 +++++++++++++++++++++++++++++++++ features/party/PartyCommands.js | 10 +++++---- index.js | 1 + utils/settings.js | 8 +++++++ 6 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 features/combat/ManaDrain.js diff --git a/changelog.json b/changelog.json index b7c90f6b..e536a6bb 100644 --- a/changelog.json +++ b/changelog.json @@ -2,9 +2,11 @@ "- Added calculator to search bar", "- Added direction to status display", "- Added `/va attributelist`", + "- Added mana drain range", "- Added support for ${name} in join messages", + "- TODO: Added legion to stats display", "- Changed item value to include dye", - "- Recoded skill tracker", + "- TODO: Recoded skill tracker", "- Fixed valuelist only affecting base value", "- Fixed color syntax" ] \ No newline at end of file diff --git a/features/combat/EntityDetect.js b/features/combat/EntityDetect.js index b9dfa277..b2fb626a 100644 --- a/features/combat/EntityDetect.js +++ b/features/combat/EntityDetect.js @@ -1,5 +1,5 @@ import settings from "../../utils/settings"; -import { AMOGUS, BOLD, GRAY, DARK_RED, GREEN, RED, WHITE, LOGO } from "../../utils/constants"; +import { AMOGUS, BOLD, GRAY, DARK_RED, GREEN, RED, WHITE } from "../../utils/constants"; import { convertToPascalCase, getTime, playSound, unformatNumber } from "../../utils/functions"; import { Overlay } from "../../utils/overlay"; import { data, registerWhen } from "../../utils/variables"; diff --git a/features/combat/ManaDrain.js b/features/combat/ManaDrain.js new file mode 100644 index 00000000..1160ef5b --- /dev/null +++ b/features/combat/ManaDrain.js @@ -0,0 +1,37 @@ +import { AQUA } from "../../utils/constants"; +import settings from "../../utils/settings"; +import { registerWhen } from "../../utils/variables"; +import { Hitbox, renderEntities } from "../../utils/waypoints"; + + +/** + * Register hitbox rendering + */ +let nearby = []; +let render = false; +new Hitbox(() => settings.manaDrain, (pt) => { + // Mana Blue Hitboxes + renderEntities(nearby, 0.408, 0.76, 0.96, pt); +}); + +registerWhen(register("renderOverlay", () => { + if (!render) return; + + Client.showTitle(`${nearby.length + AQUA} nearby ${nearby.length === 1 ? "player" : "players"}!`, "", 0, 5, 1); +}), () => settings.manaDrain); + +/** + * Updates nearby players + */ +const PLAYER_CLASS = Java.type("net.minecraft.client.entity.EntityOtherPlayerMP").class; +registerWhen(register("step", () => { + const heldName = Player.getHeldItem()?.getName(); + render = heldName !== undefined && (heldName.includes("flux Power Orb") || heldName.endsWith("End Stone Sword")) + if (!render) { + nearby = []; + return; + } + + const player = Player.asPlayerMP(); + nearby = World.getAllEntitiesOfType(PLAYER_CLASS).filter(other => other.getEntity().func_110143_aJ() !== 20 && player.distanceTo(other) < 5); +}).setFps(2), () => settings.manaDrain); diff --git a/features/party/PartyCommands.js b/features/party/PartyCommands.js index 7514f5a5..4068ead2 100644 --- a/features/party/PartyCommands.js +++ b/features/party/PartyCommands.js @@ -67,10 +67,12 @@ function setWaifu(announce) { new TextComponent(`${DARK_GRAY}[click to regenerate]`).setClick("run_command", "/va w").setHoverValue("Click me!")).chat(); }).catch((err) => { const error = err.data.error; - if (announce) ChatLib.chat(`${LOGO + RED}Imgur Upload Failed: ${error?.message ?? error}`); - - // Attempt to use base Imgur API - ChatLib.chat(`${LOGO + DARK_GRAY}Attempting to fetch using Imgur API...`); + if (announce) { + // Attempt to use base Imgur API + ChatLib.chat(`${LOGO + RED}Imgur Upload Failed: ${error?.message ?? error}`); + ChatLib.chat(`${LOGO + DARK_GRAY}Attempting to fetch using Imgur API...`); + } + const clientID = IMGUR_KEYS[parseInt(Math.random() * (IMGUR_KEYS.length - 1))]; request({ url: "https://api.imgur.com/3/gallery/t/waifu/viral/1?showViral=true", diff --git a/index.js b/index.js index 9fadc8bb..fe7572b6 100644 --- a/index.js +++ b/index.js @@ -60,6 +60,7 @@ import "./features/combat/EntityDetect"; import "./features/combat/GyroTimer"; import "./features/combat/HealthAlert"; import "./features/combat/KillCounter"; +import "./features/combat/ManaDrain"; import "./features/combat/RagDetect"; import "./features/combat/SlayerDetect"; // Mining Features diff --git a/utils/settings.js b/utils/settings.js index 5d1b7f23..69489f84 100644 --- a/utils/settings.js +++ b/utils/settings.js @@ -597,6 +597,14 @@ Move GUI with ${AQUA}/moveKills ${GRAY}or reset tracker with ${AQUA}/resetKills$ subcategory: "Combat" }) healthAlert = 0.0; + + @SwitchProperty({ + name: "Mana Drain Range", + description: `${DARK_RED}NEW! ${GRAY}Highlights and displays number of players in mana drain range. Works only when holding End Stone Sword or fluxes.`, + category: "Combat", + subcategory: "Combat" + }) + manaDrain = false; @SwitchProperty({ name: "Ragnarok Detection",