diff options
Diffstat (limited to 'features/mining/index.js')
-rw-r--r-- | features/mining/index.js | 144 |
1 files changed, 72 insertions, 72 deletions
diff --git a/features/mining/index.js b/features/mining/index.js index a2cfccf..a05552d 100644 --- a/features/mining/index.js +++ b/features/mining/index.js @@ -14,7 +14,7 @@ class Mining extends Feature { super() } - onEnable(){ + onEnable() { this.initVariables() this.hudElements = [] @@ -35,10 +35,10 @@ class Mining extends Feature { this.compactProgressHud = new ToggleSetting("Show compact blocks in the current session", "This will add a HUD element with the compact progress", true, "compact_progress_hud", this) this.compactHudElement = new HudTextElement() - .setToggleSetting(this.compactProgressHud) - .setLocationSetting(new LocationSetting("HUD Location", "Allows you to edit the location of the compact progress", "compact_progress_location", this, [10, 50, 1, 1]) - .requires(this.compactProgressHud) - .editTempText("&6Compact Session&7> &f12,345")) + .setToggleSetting(this.compactProgressHud) + .setLocationSetting(new LocationSetting("HUD Location", "Allows you to edit the location of the compact progress", "compact_progress_location", this, [10, 50, 1, 1]) + .requires(this.compactProgressHud) + .editTempText("&6Compact Session&7> &f12,345")) 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) @@ -53,178 +53,178 @@ class Mining extends Feature { this.armourstandClass = Java.type("net.minecraft.entity.item.EntityArmorStand").class - this.registerEvent("renderOverlay", this.renderOverlay) + this.registerEvent("renderOverlay", this.renderOverlay).registeredWhen(() => this.balRespawnHud.getValue() || this.compactProgressHud.getValue()) this.registerEvent("tick", this.tick) - this.registerEvent("itemTooltip", this.itemTooltipEvent) - this.registerEvent("renderWorld", this.renderWorld) + this.registerEvent("itemTooltip", this.itemTooltipEvent).registeredWhen(() => this.showContainedGemstoneSlots.getValue() || this.showUnlockedGemstoneSlots.getValue()) + this.registerEvent("renderWorld", this.renderWorld).registeredWhen(() => this.guessBalHp.getValue()) - this.registerChat("&r&c&o&r&6&lRARE DROP! &r&eA Bal Pet dropped!&r", ()=>{ - if(this.balPetAlert.getValue()){ + this.registerChat("&r&c&o&r&6&lRARE DROP! &r&eA Bal Pet dropped!&r", () => { + if (this.balPetAlert.getValue()) { World.playSound("random.orb", 1, 1) Client.showTitle("§r§c§o§r§6§lRARE DROP! §r§eA Bal Pet dropped!§r", "", 20, 50, 20) } }) - this.registerChat("&r&c&oThe bosses outer shell looks to be weakening!&r", ()=>{ + this.registerChat("&r&c&oThe bosses outer shell looks to be weakening!&r", () => { this.balHP = 200 }) - this.registerChat("&r&c&oHalf way there! The boss is starting to become weaker!&r", ()=>{ + this.registerChat("&r&c&oHalf way there! The boss is starting to become weaker!&r", () => { this.balHP = 125 }) - this.registerChat("&r&c&oNearly there! The boss is shaking it can't last much longer!&r", ()=>{ + this.registerChat("&r&c&oNearly there! The boss is shaking it can't last much longer!&r", () => { this.balHP = 75 }) - this.registerChat("&r&c&oThe boss looks weak and tired and retreats into the lava...&r", ()=>{ + this.registerChat("&r&c&oThe boss looks weak and tired and retreats into the lava...&r", () => { this.balHP = 0 }) } - itemTooltipEvent(lore, item, event){ + itemTooltipEvent(lore, item, event) { this.addLore(item) } /** * @param {Item} item */ - addLore(item){ - if(!item) return - if(this.showUnlockedGemstoneSlots.getValue()){ + addLore(item) { + if (!item) return + if (this.showUnlockedGemstoneSlots.getValue()) { let gems = item.getNBT().getCompoundTag("tag").getCompoundTag("ExtraAttributes").getCompoundTag("gems") - if(gems){ + if (gems) { let unlockedGems = gems.getTagMap().get("unlocked_slots") - if(unlockedGems){ + if (unlockedGems) { - if(unlockedGems[m.tagCount]() === 0){ + if (unlockedGems[m.tagCount]() === 0) { utils.addLore(item, ChatLib.addColor("&d&lGemstones Unlocked: &f"), ChatLib.addColor("&cNone!")) - }else{ + } else { let gemstoneString = "" - for(let i = 0; i < unlockedGems[m.tagCount](); i++){ + for (let i = 0; i < unlockedGems[m.tagCount](); i++) { let gem = String(unlockedGems[m.getStringTagAt](i)).split("_") let name = stringUtils.firstLetterCapital(gem[0].toLowerCase()) - gemstoneString += (gemstoneString===""?"":"&7, &a")+name + gemstoneString += (gemstoneString === "" ? "" : "&7, &a") + name } - utils.addLore(item, ChatLib.addColor("&d&lGemstones Unlocked: &f"), ChatLib.addColor("&a"+gemstoneString)) + utils.addLore(item, ChatLib.addColor("&d&lGemstones Unlocked: &f"), ChatLib.addColor("&a" + gemstoneString)) } } } - } - if(this.showContainedGemstoneSlots.getValue()){ + } + if (this.showContainedGemstoneSlots.getValue()) { let gems = item.getNBT().getCompoundTag("tag").getCompoundTag("ExtraAttributes").getCompoundTag("gems") - if(gems){ + if (gems) { let unlockedGems = gems.getTagMap() let gemStr = "" unlockedGems.keySet().forEach(gem => { - if(gem !== "unlocked_slots" && !gem.endsWith("_gem")){ + if (gem !== "unlocked_slots" && !gem.endsWith("_gem")) { gem = gem.split("_") - let gemName = stringUtils.firstLetterCapital(gems.getString(gem.join("_") + "_gem").toLowerCase()) ||stringUtils.firstLetterCapital(gem[0].toLowerCase()) + let gemName = stringUtils.firstLetterCapital(gems.getString(gem.join("_") + "_gem").toLowerCase()) || stringUtils.firstLetterCapital(gem[0].toLowerCase()) let name = stringUtils.firstLetterCapital(gems.getString(gem.join("_")).toLowerCase()) + " " + gemName - - gemStr += (gemStr===""?"":"&7, &a")+name + + gemStr += (gemStr === "" ? "" : "&7, &a") + name } }); - if(gemStr !== ""){ - utils.addLore(item, ChatLib.addColor("&d&lGemstones: &f"), ChatLib.addColor("&a"+gemStr)) + if (gemStr !== "") { + utils.addLore(item, ChatLib.addColor("&d&lGemstones: &f"), ChatLib.addColor("&a" + gemStr)) } } - } + } } - renderWorld(){ - if(this.guessBalHp.getValue()){ - if(this.balEntity) Tessellator.drawString(this.balHP + "/250" , this.balEntity.getX(), this.balEntity.getY()+12, this.balEntity.getZ()) + renderWorld() { + if (this.guessBalHp.getValue()) { + if (this.balEntity) Tessellator.drawString(this.balHP + "/250", this.balEntity.getX(), this.balEntity.getY() + 12, this.balEntity.getZ()) } } - tick(){ + tick() { let oldCompactItems = this.compactItems let oldTotalCompact = this.totalCompact this.totalCompact = 0 this.compactItems = 0 let slots = [0, 1, 2, 3, 4, 5, 6, 7, 8] - - slots.forEach(a=>{ + + slots.forEach(a => { item = Player.getInventory().getStackInSlot(a) - if(!item) return - if(item.getNBT()?.getCompoundTag("tag")?.getCompoundTag("ExtraAttributes")?.getInteger("compact_blocks")){ + if (!item) return + if (item.getNBT()?.getCompoundTag("tag")?.getCompoundTag("ExtraAttributes")?.getInteger("compact_blocks")) { this.compactItems++ this.totalCompact += item.getNBT().getCompoundTag("tag").getCompoundTag("ExtraAttributes").getInteger("compact_blocks") } }) - if(oldCompactItems === this.compactItems){ - this.compactProgress += this.totalCompact-oldTotalCompact + if (oldCompactItems === this.compactItems) { + this.compactProgress += this.totalCompact - oldTotalCompact } - if(this.compactItems === 0){ + if (this.compactItems === 0) { this.compactProgress = 0 } - if(this.compactProgress === 0 && this.compactProgressHudOnlyWhenMoreThan0.getValue()){ + if (this.compactProgress === 0 && this.compactProgressHudOnlyWhenMoreThan0.getValue()) { this.compactHudElement.setText("") - }else{ + } else { this.compactHudElement.setText("&6Compact Session&7> &f" + numberWithCommas(this.compactProgress)) } - if(!this.FeatureManager.features["dataLoader"]) return - if(this.guessBalHp.getValue() || this.balRespawnHud.getValue()){ - if(this.FeatureManager.features["dataLoader"].class.area === "Crystal Hollows" && this.FeatureManager.features["dataLoader"].class.areaFine === "Khazad-dm"){ - + if (!this.FeatureManager.features["dataLoader"]) return + if (this.guessBalHp.getValue() || this.balRespawnHud.getValue()) { + if (this.FeatureManager.features["dataLoader"].class.area === "Crystal Hollows" && this.FeatureManager.features["dataLoader"].class.areaFine === "Khazad-dm") { + this.balEntity = undefined - World.getAllEntities().filter(a=>a.getName()==="Magma Cube").filter(a=>a.getEntity()[m.getSlimeSize]() > 10).forEach((bal)=>{ + World.getAllEntities().filter(a => a.getName() === "Magma Cube").filter(a => a.getEntity()[m.getSlimeSize]() > 10).forEach((bal) => { //Bal found this.balEntity = bal }) - if(this.balEntity){ - this.balDespawnDebounce=0 - if(this.lastBalAlive !== 0){ + if (this.balEntity) { + this.balDespawnDebounce = 0 + if (this.lastBalAlive !== 0) { this.lastBalAlive = 0 } - World.getAllEntitiesOfType(this.armourstandClass).forEach(e=>{ - if(Math.abs(e.getX()-this.balEntity.getX())<=5 && Math.abs(e.getZ()-this.balEntity.getZ())<=5 && Math.abs(e.getY()-(this.balEntity.getY()+12))<=5){ - if(!this.seenBalDamages.includes(e.getUUID())){ + World.getAllEntitiesOfType(this.armourstandClass).forEach(e => { + if (Math.abs(e.getX() - this.balEntity.getX()) <= 5 && Math.abs(e.getZ() - this.balEntity.getZ()) <= 5 && Math.abs(e.getY() - (this.balEntity.getY() + 12)) <= 5) { + if (!this.seenBalDamages.includes(e.getUUID())) { this.balHP-- this.seenBalDamages.push(e.getUUID()) } } }) - }else{ + } else { this.balDespawnDebounce++ - if(this.balDespawnDebounce > 10){ + if (this.balDespawnDebounce > 10) { this.seenBalDamages = [] this.balHP = 250 - if(this.lastBalAlive === 0) this.lastBalAlive = Date.now() + if (this.lastBalAlive === 0) this.lastBalAlive = Date.now() } } } } - if(this.balRespawnHud.getValue() && this.FeatureManager.features["dataLoader"].class.area === "Crystal Hollows" && this.FeatureManager.features["dataLoader"].class.areaFine === "Khazad-dm"){ - if(this.balEntity){ + if (this.balRespawnHud.getValue() && this.FeatureManager.features["dataLoader"].class.area === "Crystal Hollows" && this.FeatureManager.features["dataLoader"].class.areaFine === "Khazad-dm") { + if (this.balEntity) { this.balHudElement.setText("&6Bal&7> &f" + this.balHP + "/250") - }else{ - this.balHudElement.setText("&6Bal&7> &f" + Math.max(0, Math.floor((290000-(Date.now()-this.lastBalAlive))/1000)) + "s") + } else { + this.balHudElement.setText("&6Bal&7> &f" + Math.max(0, Math.floor((290000 - (Date.now() - this.lastBalAlive)) / 1000)) + "s") } - }else{ + } else { this.balHudElement.setText("") } } - renderOverlay(){ - for(let element of this.hudElements){ + renderOverlay() { + for (let element of this.hudElements) { element.render() } } - - initVariables(){ + + initVariables() { this.hudElements = undefined this.guessBalHp = undefined this.balRespawnHud = undefined @@ -238,7 +238,7 @@ class Mining extends Feature { this.balPetAlert = undefined } - onDisable(){ + onDisable() { this.initVariables() } } |