diff options
author | EmeraldMerchant <96396730+EmeraldMerchant@users.noreply.github.com> | 2022-08-27 16:55:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-27 16:55:29 +0800 |
commit | 500beeb5851e32451dc0a4453ba4f829070948d4 (patch) | |
tree | 16573b10ed83a3d164874d67a26d61c25975468e | |
parent | 0d5c5d91f14a578eb9956ed8e43e249f4740db0b (diff) | |
download | SoopyV2-500beeb5851e32451dc0a4453ba4f829070948d4.tar.gz SoopyV2-500beeb5851e32451dc0a4453ba4f829070948d4.tar.bz2 SoopyV2-500beeb5851e32451dc0a4453ba4f829070948d4.zip |
things
+ compact powder gain message
+ 2x powder chat suffix
-rw-r--r-- | features/specialMining/index.js | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/features/specialMining/index.js b/features/specialMining/index.js index 2694427..72ee843 100644 --- a/features/specialMining/index.js +++ b/features/specialMining/index.js @@ -5,6 +5,7 @@ import HudTextElement from "../hud/HudTextElement"; import LocationSetting from "../settings/settingThings/location"; import ToggleSetting from "../settings/settingThings/toggle"; import { delay } from "../../utils/delayUtils"; +import TextSetting from "../settings/settingThings/textSetting"; import { drawBoxAtBlock, drawFilledBox } from "../../utils/renderUtils"; import RenderLib2D from "../../utils/renderLib2d"; @@ -16,6 +17,9 @@ class PowderAndScatha extends Feature { onEnable() { this.initVariables(); new SettingBase("Chest Miner", "Powder mining feature here are made mainly for powder chest grinding", undefined, "chest_mining_info", this); + this.compactedChat = new ToggleSetting("Compact Powder Messages", "same as the one in skytils but support following setting", false, "compact_powder_chat", this) + this.fixChatForDoublePowder = new ToggleSetting("Fix Chat Messages During Double Powder", "so it's the correct amount of powder you received during the event", false, "fix_chat_dpowder", this) + this.fixChatForDoublePowderSuffix = new TextSetting("Suffix of previous message", "(so you can tell )change it yourself!", "&a(&b2X Powder&a)", "chat_dpowder_suffix", this, "(none)", false).requires(this.fixChatForDoublePowder); this.PowderElement = new ToggleSetting("Powder Mining Info Hud (MAIN TOGGLE)", "This will show your current powder mining section (only in CH)", true, "powder_mining_hud", this).contributor("EmeraldMerchant"); this.PowderOverlayElement = new HudTextElement() .setText("") @@ -120,13 +124,42 @@ class PowderAndScatha extends Feature { this.gemstoneRate = (this.miningData.powder.gemstone - gemstone) / (Date.now() - time) }) }) + + this.lastPowderReceived = { mithril: 0, gemstone: 0 } + this.lastPowderReceivedExecuted = false; this.registerChat("&r&aYou received &r&b+${amount} &r&aMithril Powder&r", (amount, e) => { - this.miningData.powder.mithril += (this.dPowder ? 2 : 1) * parseInt(amount) + let p = (this.dPowder ? 2 : 1) * parseInt(amount) + this.miningData.powder.mithril += p + if (this.compactedChat.getValue()) { + cancel(e) + this.lastPowderReceived.mithril += p + return + } + if (this.fixChatForDoublePowder.getValue() && this.dPowder) { + cancel(e) + let suffix = ""; + if (this.fixChatForDoublePowderSuffix.getValue() !== "") suffix = this.fixChatForDoublePowderSuffix.getValue() + ChatLib.chat(`&r&aYou received &r&b+${2 * amount} &r&aMithril Powder&r ${suffix}`) + } }) this.registerChat("&r&aYou received &r&b+${amount} &r&aGemstone Powder&r", (amount, e) => { - this.miningData.powder.gemstone += (this.dPowder ? 2 : 1) * parseInt(amount) + let p = (this.dPowder ? 2 : 1) * parseInt(amount) + this.miningData.powder.gemstone += p + if (this.compactedChat.getValue()) { + cancel(e) + this.lastPowderReceived.gemstone += p + return + } + if (this.fixChatForDoublePowder.getValue() && this.dPowder) { + cancel(e) + let suffix = ""; + if (this.fixChatForDoublePowderSuffix.getValue() !== "") suffix = this.fixChatForDoublePowderSuffix.getValue() + ChatLib.chat(`&r&aYou received &r&b+${2 * amount} &r&aGemstone Powder&r ${suffix}`) + } }) + this.registerStep(true, 5, this.compactPowderChat) + this.chests = new Map() @@ -202,7 +235,7 @@ class PowderAndScatha extends Feature { step2fps() { if (!this.foundWither) { World.getAllEntitiesOfType(net.minecraft.entity.boss.EntityWither)?.forEach(e => { - if (e.getName().includes("§e§lPASSIVE EVENT §b§l2X POWDER §e§lRUNNING FOR §a§l")) { + if (e.getName().startsWith("§e§lPASSIVE EVENT §b§l2X POWDER §e§lRUNNING FOR §a§l")) { this.dPowder = Date.now(); let time = ChatLib.removeFormatting(e.getName()).split("RUNNING FOR ").pop() @@ -250,6 +283,30 @@ class PowderAndScatha extends Feature { } } + compactPowderChat() { + if (this.lastPowderReceived.mithril > 0 && this.lastPowderReceived.gemstone > 0 && !this.lastPowderReceivedExecuted) { + this.lastPowderReceivedExecuted = true + delay(300, () => { + let m = this.lastPowderReceived.mithril + let g = this.lastPowderReceived.gemstone + let msg = "" + if (g > 0) msg += `&r&aYou received &r&b+${g} &r&aGemstone ` + if (m > 0) { + if (!msg) msg += `&r&aYou received &r&b+${m} &r&aMithril ` + else msg += `and &r&b+${m} &r&aMithril ` + } + msg += `Powder&r` + if (this.dPowder) { + let suffix = ""; + if (this.fixChatForDoublePowderSuffix.getValue() !== "") suffix = this.fixChatForDoublePowderSuffix.getValue() + ChatLib.chat(`${msg} ${suffix}`) + } else ChatLib.chat(msg) + this.lastPowderReceived = { mithril: 0, gemstone: 0 } + this.lastPowderReceivedExecuted = false + }) + } + } + initVariables() { this.hudElements = []; this.inCrystalHollows = false; |