diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-06-05 22:56:59 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-06-05 22:56:59 +0800 |
commit | 80df8e23c4c4fea6e6c4f438151842070707116a (patch) | |
tree | 258db4ca4c9cf626a17ae81c817355f5bba9e7be /features/dungeonRoutes | |
parent | 9e37dc333023e88371b4109b91e264d69798f758 (diff) | |
download | SoopyV2-80df8e23c4c4fea6e6c4f438151842070707116a.tar.gz SoopyV2-80df8e23c4c4fea6e6c4f438151842070707116a.tar.bz2 SoopyV2-80df8e23c4c4fea6e6c4f438151842070707116a.zip |
+ Start of dungeonroutes feature (SUPER UNFINISHED)
Diffstat (limited to 'features/dungeonRoutes')
-rw-r--r-- | features/dungeonRoutes/index.js | 57 | ||||
-rw-r--r-- | features/dungeonRoutes/metadata.json | 2 |
2 files changed, 58 insertions, 1 deletions
diff --git a/features/dungeonRoutes/index.js b/features/dungeonRoutes/index.js index 9cfbd88..f2d6757 100644 --- a/features/dungeonRoutes/index.js +++ b/features/dungeonRoutes/index.js @@ -1,6 +1,7 @@ /// <reference types="../../../CTAutocomplete" /> /// <reference lib="es2015" /> import Feature from "../../featureClass/class"; +import { drawBoxAtBlock, drawFilledBox, drawLinePoints } from "../../utils/renderUtils"; import SettingBase from "../settings/settingThings/settingBase"; @@ -14,6 +15,62 @@ class DungeonRoutes extends Feature { new SettingBase("Coming soontm", "maby", undefined, "coming_soontm", this) return } + + this.actionId = 0 + + this.recentEtherwarps = [] + this.recentMines = [] + this.recentLocations = [] + this.lastLocationUpdatedTime = Date.now() + + this.registerEvent("soundPlay", this.playSound) + this.registerEvent("worldLoad", this.worldLoad) + + this.registerStep(true, 5, () => { + if (this.recentLocations.length === 0 + || Math.trunc(Player.getX()) !== this.recentLocations[this.recentLocations.length - 1].loc[0] + || Math.trunc(Player.getY()) !== this.recentLocations[this.recentLocations.length - 1].loc[1] + || Math.trunc(Player.getZ()) !== this.recentLocations[this.recentLocations.length - 1].loc[2]) { + + this.recentLocations.push({ loc: [Math.trunc(Player.getX()), Math.trunc(Player.getY()), Math.trunc(Player.getZ())], id: this.actionId++ }) + + if (this.recentLocations.length > 50) this.recentLocations.shift() + } + }) + + this.registerEvent("renderWorld", () => { + this.recentEtherwarps.forEach(({ loc }) => { + drawFilledBox(loc.x, loc.y - 1, loc.z, 1, 1, 1, 0, 0, 50 / 255, true) + drawBoxAtBlock(loc.x - 0.5, loc.y - 1, loc.z - 0.5, 1, 0, 0, 1, 1, 1) + }) + this.recentMines.forEach(({ loc }) => { + drawFilledBox(loc.x, loc.y - 0.5, loc.z, 1, 1, 0, 1, 0, 50 / 255, true) + }) + if (this.recentLocations.length >= 2) drawLinePoints(this.recentLocations.map(a => [a.loc[0] - 0.5, a.loc[1] + 0.1, a.loc[2] - 0.5]), 0, 0, 255, 2, true) + }) + } + + worldLoad() { + this.recentEtherwarps = [] + this.recentMines = [] + } + + playSound(pos, name, volume, pitch, categoryName, event) { + let nameSplitted = name.split(".") + if (name === "mob.enderdragon.hit") { //etherwarp + this.recentEtherwarps.push({ loc: pos, id: this.actionId++ }) + if (this.recentEtherwarps.length > 10) this.recentEtherwarps.shift() + } + if (nameSplitted[0] === "dig") { //mining block + if (!this.recentMines.some(a => + a.loc.x === pos.x + && a.loc.y === pos.y + && a.loc.z === pos.z + )) { + this.recentMines.push({ loc: pos, id: this.actionId++ }) + if (this.recentMines.length > 10) this.recentMines.shift() + } + } } onDisable() { diff --git a/features/dungeonRoutes/metadata.json b/features/dungeonRoutes/metadata.json index 783bdd8..c2f2a63 100644 --- a/features/dungeonRoutes/metadata.json +++ b/features/dungeonRoutes/metadata.json @@ -1,7 +1,7 @@ { "name": "Dungeon Routes", "description": "Routes for dungeons (Coming soontm maby)", - "isHidden": true, + "isHidden": false, "isTogglable": true, "defaultEnabled": true, "sortA": 0 |