aboutsummaryrefslogtreecommitdiff
path: root/features/events/index.js
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2021-11-30 23:28:02 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2021-11-30 23:28:02 +0800
commit71ae701c364f586c34ae2d1e5f82e4df89e1d851 (patch)
tree8ed41d1b9fbdf72bbf256cb60d83a82adf8446b6 /features/events/index.js
parent5f481b984dfeb8ec6d6eb1762928726d728e775d (diff)
downloadSoopyV2-71ae701c364f586c34ae2d1e5f82e4df89e1d851.tar.gz
SoopyV2-71ae701c364f586c34ae2d1e5f82e4df89e1d851.tar.bz2
SoopyV2-71ae701c364f586c34ae2d1e5f82e4df89e1d851.zip
Allow for dynamic updating of module code in the fly
Diffstat (limited to 'features/events/index.js')
-rw-r--r--features/events/index.js27
1 files changed, 17 insertions, 10 deletions
diff --git a/features/events/index.js b/features/events/index.js
index 80ba200..5586503 100644
--- a/features/events/index.js
+++ b/features/events/index.js
@@ -41,7 +41,8 @@ class Events extends Feature {
.requires(this.burrialWaypointsEnabled)
.editTempText("&6Update&7> &f100s"))
this.hudElements.push(this.updateTimer)
-
+
+
this.registerEvent("worldLoad", this.worldLoad)
this.registerEvent("spawnParticle", this.spawnParticle)
this.registerEvent("renderWorld", this.renderWorld)
@@ -75,14 +76,7 @@ class Events extends Feature {
})
}
if(this.showingWaypoints){
- let sorted = [...this.burrialData.locations]
- sorted.sort((a,b)=>{
- let aDist = calculateDistanceQuick([Player.getX(),Player.getY(),Player.getZ()],[a.x+0.5,a.y+2.5,a.z+0.5])
- let bDist = calculateDistanceQuick([Player.getX(),Player.getY(),Player.getZ()],[b.x+0.5,b.y+2.5,b.z+0.5])
-
- return bDist-aDist
- })
- sorted.forEach((loc,i)=>{
+ this.burrialData.locations.forEach((loc,i)=>{
let typeReplace = [
"Start",
@@ -119,6 +113,17 @@ class Events extends Feature {
}
}
+ sortBurrialLocations(){
+ let sorted = [...this.burrialData.locations]
+ sorted.sort((a,b)=>{
+ let aDist = calculateDistanceQuick([Player.getX(),Player.getY(),Player.getZ()],[a.x+0.5,a.y+2.5,a.z+0.5])
+ let bDist = calculateDistanceQuick([Player.getX(),Player.getY(),Player.getZ()],[b.x+0.5,b.y+2.5,b.z+0.5])
+
+ return bDist-aDist
+ })
+ this.burrialData.locations = sorted
+ }
+
step(){
hasDianaShovle = false
@@ -160,6 +165,7 @@ class Events extends Feature {
}).start()
}
}
+ this.sortBurrialLocations()
}
worldLoad(){
@@ -234,6 +240,7 @@ class Events extends Feature {
})
this.burrialData.locations = newLocs
+ this.sortBurrialLocations()
this.updateBurrialPath()
}
@@ -376,7 +383,7 @@ class Events extends Feature {
return false
})
if(this.burrialData.historicalLocations.length > 10) this.burrialData.historicalLocations.pop()
- this.lastPathCords.shift()
+ if(this.lastPathCords) this.lastPathCords.shift()
new Thread(()=>{
this.updateBurrialPath()
}).start()