aboutsummaryrefslogtreecommitdiff
path: root/features/dungeonRoutes/index.js
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-06-06 13:27:49 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-06-06 13:27:49 +0800
commit091590d76e30797ec27a143129146904c14dd2b3 (patch)
treec3a10caedb0934f07ac41d5e00d96f6817be43c6 /features/dungeonRoutes/index.js
parent80df8e23c4c4fea6e6c4f438151842070707116a (diff)
downloadSoopyV2-091590d76e30797ec27a143129146904c14dd2b3.tar.gz
SoopyV2-091590d76e30797ec27a143129146904c14dd2b3.tar.bz2
SoopyV2-091590d76e30797ec27a143129146904c14dd2b3.zip
+ dungeon routes stuff
+ wing changes
Diffstat (limited to 'features/dungeonRoutes/index.js')
-rw-r--r--features/dungeonRoutes/index.js41
1 files changed, 34 insertions, 7 deletions
diff --git a/features/dungeonRoutes/index.js b/features/dungeonRoutes/index.js
index f2d6757..84c5409 100644
--- a/features/dungeonRoutes/index.js
+++ b/features/dungeonRoutes/index.js
@@ -21,6 +21,7 @@ class DungeonRoutes extends Feature {
this.recentEtherwarps = []
this.recentMines = []
this.recentLocations = []
+ this.recentTnts = []
this.lastLocationUpdatedTime = Date.now()
this.registerEvent("soundPlay", this.playSound)
@@ -28,13 +29,13 @@ class DungeonRoutes extends Feature {
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]) {
+ || Math.ceil(Player.getX()) !== this.recentLocations[this.recentLocations.length - 1].loc[0]
+ || Math.ceil(Player.getY()) !== this.recentLocations[this.recentLocations.length - 1].loc[1]
+ || Math.ceil(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++ })
+ this.recentLocations.push({ loc: [Math.ceil(Player.getX()), Math.ceil(Player.getY()), Math.ceil(Player.getZ())], id: this.actionId++ })
- if (this.recentLocations.length > 50) this.recentLocations.shift()
+ this.checkForRemove()
}
})
@@ -53,13 +54,39 @@ class DungeonRoutes extends Feature {
worldLoad() {
this.recentEtherwarps = []
this.recentMines = []
+ this.recentLocations = []
+ this.recentTnts = []
+ }
+
+ checkForRemove() {
+ if (this.recentLocations.length + this.recentMines.length + this.recentEtherwarps.length + this.recentTnts.length > 50) {
+ let arrs = [this.recentLocations, this.recentMines, this.recentEtherwarps, this.recentTnts]
+ let smallestArr = undefined
+
+ if (this.recentLocations[0].id < this.recentMines[0].id && this.recentLocations[0].id < this.recentEtherwarps[0].id) {
+ this.recentLocations.shift()
+ return
+ }
+ if (this.recentMines[0].id < this.recentLocations[0].id && this.recentMines[0].id < this.recentEtherwarps[0].id) {
+ this.recentMines.shift()
+ return
+ }
+ if (this.recentEtherwarps[0].id < this.recentMines[0].id && this.recentEtherwarps[0].id < this.recentLocations[0].id) {
+ this.recentEtherwarps.shift()
+ return
+ }
+ }
}
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()
+ this.checkForRemove()
+ }
+ if (name === "random.explode") { //etherwarp
+ this.recentTnts.push({ loc: pos, id: this.actionId++ })
+ this.checkForRemove()
}
if (nameSplitted[0] === "dig") { //mining block
if (!this.recentMines.some(a =>
@@ -68,7 +95,7 @@ class DungeonRoutes extends Feature {
&& a.loc.z === pos.z
)) {
this.recentMines.push({ loc: pos, id: this.actionId++ })
- if (this.recentMines.length > 10) this.recentMines.shift()
+ this.checkForRemove()
}
}
}