diff options
-rw-r--r-- | features/dungeonMap/index.js | 40 | ||||
-rw-r--r-- | features/dungeonSolvers/index.js | 112 | ||||
-rw-r--r-- | features/events/index.js | 2 |
3 files changed, 98 insertions, 56 deletions
diff --git a/features/dungeonMap/index.js b/features/dungeonMap/index.js index 207d480..bc54aa5 100644 --- a/features/dungeonMap/index.js +++ b/features/dungeonMap/index.js @@ -55,6 +55,7 @@ class DungeonMap extends Feature { this.puzzlesTab = [] this.roomWidth = 1 this.nameToUUID = {} + this.deadPlayers = new Set() this.newPuzzlesTab = [] this.mortLocationOnMap = undefined this.brBoxLoc = undefined @@ -62,6 +63,7 @@ class DungeonMap extends Feature { // this.invMapImage = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB) // this.renderImage = new BufferedImage(this.IMAGE_SIZE, this.IMAGE_SIZE, BufferedImage.TYPE_INT_ARGB) this.mapData = undefined + this.idToPlayer = {} this.barrier_block_item = new Item("minecraft:barrier") this.puzzleItems = { @@ -120,7 +122,7 @@ class DungeonMap extends Feature { this.spiritLeapOverlayGui = new SpiritLeapOverlay(this) // this.registerEvent("tick", this.tick) - this.registerStep(true, 3, this.step).registeredWhen(() => this.isInDungeon()) + this.registerStep(true, 3, this.step) this.registerStep(true, 10, () => { this.spiritLeapOverlayGui.tick() }).registeredWhen(() => this.isInDungeon()) @@ -154,6 +156,16 @@ class DungeonMap extends Feature { this.registerEvent("gameUnload", () => { this.running = false }) + this.registerChat("&r&c ☠ ${info} and became a ghost&r&7.&r", (info, e) => { + let player = ChatLib.removeFormatting(info.split(" ")[0]) + + this.deadPlayers.add(this.nameToUUID[player]) + }); + this.registerChat("&r&a ❣ &r${info} was revived${*}!&r", (info, e) => { + let player = ChatLib.removeFormatting(info.split(" ")[0]) + + this.deadPlayers.delete(this.nameToUUID[player]) + }); this.registerStep(true, 3, () => { if (!this.isInDungeon()) return @@ -178,6 +190,7 @@ class DungeonMap extends Feature { this.mortLocationOnMap = undefined this.bloodOpened = false this.keys = 0 + this.idToPlayer = {} } renderOverlay() { @@ -314,6 +327,7 @@ class DungeonMap extends Feature { }) Object.keys(this.mapDataPlayers).forEach((uuid) => { + if (this.deadPlayers.has(uuid)) return if (uuid === Player.getUUID().toString()) return let renderX let renderY @@ -366,6 +380,22 @@ class DungeonMap extends Feature { step() { if (!World.getWorld()) return + if (!this.isInDungeon()) return + if (Player.getContainer().getName().startsWith("Catacombs - Floor ")) { + this.nameToUUID = {} + World.getAllPlayers().forEach(p => { + this.nameToUUID[p.getName()] = p.getUUID().toString() + }) + let playerI = 0 + for (let i = 0; i < 5; i++) { + let name = ChatLib.removeFormatting(Player.getContainer().getStackInSlot(3 + i)?.getName()?.split(" ")?.pop() || "") + if (this.nameToUUID[name]) { + this.idToPlayer[playerI] = this.nameToUUID[name] + } + if (name) playerI++ + } + if (playerI !== World.getAllPlayers().filter(p => p.getPing() === 1).length) this.idToPlayer = {} + } // console.log("asjbfoasbgp") this.people = [] this.puzzlesTab = [] @@ -389,7 +419,6 @@ class DungeonMap extends Feature { // console.log(name) }) let puzzlesTab2 = this.puzzlesTab.map(a => a) - // console.log(this.puzzlesTab.length) // Object.keys(this.puzzles).forEach(key=>{ // let y = (key%128) @@ -593,7 +622,7 @@ class DungeonMap extends Feature { if (this.brBox.getValue() && !this.bloodOpened) this.dungeonBrBoxElm.startRender() - this.dungeonBrBoxElm.setLocationSize([this.brBoxLoc[0] - 1.5, 69, this.brBoxLoc[1] - 1.5], [3, 4, 3]) + if (this.brBoxLoc) this.dungeonBrBoxElm.setLocationSize([this.brBoxLoc[0] - 1.5, 69, this.brBoxLoc[1] - 1.5], [3, 4, 3]) if (roomOffsets) { // for(let x = 0;x<128;x++){ @@ -634,6 +663,7 @@ class DungeonMap extends Feature { let deco = mapData[f.mapDecorations] this.extraDeco = [] try { + let i = 0 deco.forEach((icon, vec4b) => { let x = vec4b.func_176112_b() let y = vec4b.func_176113_c() @@ -660,12 +690,15 @@ class DungeonMap extends Feature { closestP = uuid } }) + while (this.idToPlayer[i] && this.deadPlayers.has(this.idToPlayer[i])) i++ + if (this.idToPlayer[i]) closestP = this.idToPlayer[i] if (closestP) { // console.log(closestP, x, y) this.mapDataPlayers[closestP].x = x this.mapDataPlayers[closestP].y = y this.mapDataPlayers[closestP].rot = rot } + i++ }); } catch (e) { } } @@ -703,6 +736,7 @@ class DungeonMap extends Feature { username: player.getName(), uuid: player.getUUID().toString() }) + this.nameToUUID[player.getName()] = player.getUUID().toString() }) // console.log("Sending: " + JSON.stringify(this.people, undefined, 2)+JSON.stringify(data, undefined, 2)) socketConnection.sendDungeonData(this.people, data) diff --git a/features/dungeonSolvers/index.js b/features/dungeonSolvers/index.js index 34c236f..8b0e998 100644 --- a/features/dungeonSolvers/index.js +++ b/features/dungeonSolvers/index.js @@ -183,7 +183,7 @@ class DungeonSolvers extends Feature { this.bloodOpenedBonus = true; this.goneInBonus = true; }); - this.registerChat("&r&c[BOSS] The Watcher&r&f: You have proven yourself. You may pass.&r", () => { + this.registerChat("[BOSS] The Watcher: You have proven yourself. You may pass.", () => { this.bloodOpenedBonus = false; //TODO: add 5second delay this.goneInBonus = true; }); @@ -252,61 +252,64 @@ class DungeonSolvers extends Feature { //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") - // } - // }) - // }) + 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 + function addThing(location, type) { + if (saidLocations.has(location.join(","))) return - // saidLocations.add(location.join(",")) + 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 }) - // } + 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]] + } + } + ChatLib.chat("Loaded " + type) + 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] + } + } + } + } + ChatLib.chat("Loaded " + type) + data.push({ type: "terminal", location: finalLoc, phase: area }) + return + } + ChatLib.chat("Loaded " + type) + data.push({ type: type, location: location, phase: area }) + } - // this.registerCommand("getdata", () => { - // ChatLib.chat(JSON.stringify(data)) - // }) + 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 @@ -778,6 +781,11 @@ class DungeonSolvers extends Feature { } step() { + if (this.bearSpawning && this.bearSpawning > 0) { + this.spiritBearSpawnElement.setText("&dBear spawned in: &c" + (Math.max(0, this.bearSpawning - Date.now()) / 1000).toFixed(2) + "s"); + } else { + this.spiritBearSpawnElement.setText(""); + } if (!Player.getX()) return World.getAllPlayers().forEach((p) => { this.nameToUuid[p.getName().toLowerCase()] = p.getUUID().toString() diff --git a/features/events/index.js b/features/events/index.js index 9ff7078..9e08d94 100644 --- a/features/events/index.js +++ b/features/events/index.js @@ -57,7 +57,7 @@ class Events extends Feature { this.shinyBlockOverlayEnabled = new ToggleSetting("Shiny blocks highlight", "Will highlight shiny blocks in the end", false, "shiny_blocks_overlay", this) this.registerEvent("worldLoad", this.worldLoad) - this.registerEvent("spawnParticle", this.spawnParticle).registeredWhen(() => this.showingWaypoints) + this.registerEvent("spawnParticle", this.spawnParticle).registeredWhen(() => this.showingWaypoints || this.shinyBlockOverlayEnabled.getValue()) this.registerEvent("renderWorld", this.renderWorld).registeredWhen(() => this.showingWaypoints || this.shinyBlockOverlayEnabled.getValue()) this.registerStep(true, 2, this.step) this.registerStep(false, 5, this.step_5s) |