aboutsummaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-03-08 21:20:21 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-03-08 21:20:21 +0800
commit133f781e0838445bca104490c8ffe0b6398a876e (patch)
tree4fd5d2fc125ec3b812aec1e780720704746796bb /features
parent7ba09eb9ee619197849f3ed8de971e6bfab7d721 (diff)
downloadSoopyV2-133f781e0838445bca104490c8ffe0b6398a876e.tar.gz
SoopyV2-133f781e0838445bca104490c8ffe0b6398a876e.tar.bz2
SoopyV2-133f781e0838445bca104490c8ffe0b6398a876e.zip
update meta + make dungeon map sync player locations thru socket
Diffstat (limited to 'features')
-rw-r--r--features/cosmetics/index.js10
-rw-r--r--features/dungeonMap/index.js103
2 files changed, 89 insertions, 24 deletions
diff --git a/features/cosmetics/index.js b/features/cosmetics/index.js
index d4b9fcb..e1879d0 100644
--- a/features/cosmetics/index.js
+++ b/features/cosmetics/index.js
@@ -50,7 +50,7 @@ class Cosmetics extends Feature {
this.registerEvent("playerLeft", this.playerLeft)
this.registerEvent("worldLoad", this.worldLoad)
this.registerStep(false, 2, this.step)
- this.registerEvent('worldUnload', ()=>{
+ this.registerEvent('gameUnload', ()=>{
if(this.postRenderEntityTrigger){
this.postRenderEntityTrigger.unregister()
this.postRenderEntityTrigger = undefined
@@ -60,7 +60,6 @@ class Cosmetics extends Feature {
// new Thread(()=>{this.loadCosmeticsData.call(this)}).start()
// })
// this.registerEvent("renderEntity", this.renderEntity)
- this.loadedRenderEntity = false
if(global.soopyV2Server.userCosmeticPermissions){
this.updateUserCosmeticPermissionSettings()
@@ -78,8 +77,8 @@ class Cosmetics extends Feature {
}
renderWorld(ticks){
- for(let cosmetic of this.loadedCosmetics){
- cosmetic.onRenderEntity(ticks, false)
+ for(let i = 0;i<this.loadedCosmetics.length;i++){
+ this.loadedCosmetics[i].onRenderEntity(ticks, false)
}
}
@@ -88,7 +87,7 @@ class Cosmetics extends Feature {
this.cosmeticsData = data
this.playerHasACosmeticA = !!data[Player.getUUID().toString().replace(/-/g,"")]
- if(this.playerHasACosmeticA && !this.loadedRenderEntity){
+ if(this.playerHasACosmeticA && !this.postRenderEntityTrigger){
// this.registerEvent("postRenderEntity", this.renderEntity)
this.postRenderEntityTrigger = register("postRenderEntity", (entity, pos, ticks, event)=>{
if(ticks !== 1) return
@@ -99,7 +98,6 @@ class Cosmetics extends Feature {
}
}
})
- this.loadedRenderEntity = true
}
this.scanForNewCosmetics()
diff --git a/features/dungeonMap/index.js b/features/dungeonMap/index.js
index 05bd25a..7261c60 100644
--- a/features/dungeonMap/index.js
+++ b/features/dungeonMap/index.js
@@ -13,6 +13,7 @@ import SoopyGuiElement from "../../../guimanager/GuiElement/SoopyGuiElement";
import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent";
import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow";
import ImageLocationSetting from "../settings/settingThings/imageLocation";
+import socketConnection from "../../socketConnection";
const BufferedImage = Java.type("java.awt.image.BufferedImage")
const AlphaComposite = Java.type("java.awt.AlphaComposite")
@@ -86,6 +87,7 @@ class DungeonMap extends Feature {
// this.registerEvent("tick", this.tick)
this.registerStep(true, 3, this.step)
+ this.registerStep(false, 5, this.step5s)
this.registerEvent("renderOverlay", this.renderOverlay)
this.registerEvent("renderWorld", this.renderWorld)
this.registerEvent("worldLoad", this.worldLoad)
@@ -94,6 +96,17 @@ class DungeonMap extends Feature {
if(this.spiritLeapOverlay.getValue()) this.spiritLeapOverlayGui.guiOpened.call(this.spiritLeapOverlayGui, event)
})
+ this.boringMap = false
+ this.registerChat("&r&r&r ${*}&r&cThe Catacombs &r&8- &r&eFloor ${*}&r", ()=>{
+ this.boringMap = true
+ })
+ this.registerChat("&r&r&r ${*}&r&cMaster Mode Catacombs &r&8- &r&eFloor ${*}&r", ()=>{
+ this.boringMap = true
+ })
+ this.registerChat("&r&aDungeon starts in 1 second.&r", ()=>{
+ this.boringMap = false
+ })
+
this.running = true
this.registerEvent("gameUnload", ()=>{
this.running = false
@@ -148,11 +161,53 @@ class DungeonMap extends Feature {
drawMap(x, y, size, scale){
if(this.mapImage){
- this.mapImage.draw(x, y, size, size)
+ if(this.boringMap){
+ this.mapImage.draw(x, y, size, size)
+ return
+ }
+ renderLibs.scizzor(x, y, size, size)
+
+ World.getAllPlayers().forEach(player=>{
+ if(player.getPing()===-1)return
+ if(!this.people.includes(player.getName())) return
+ this.mapDataPlayers[player.getUUID().toString()] = {
+ x: player.getX(),
+ y: player.getZ(),
+ rot: player.getYaw()+180,
+ username: player.getName(),
+ uuid: player.getUUID().toString()
+ }
+ })
+
+ let uuid = Player.getUUID().toString()
+ let renderX
+ let renderY
+ let xOff = 0
+ let yOff = 0
+ if(this.mapDataPlayers[uuid]){
+
+ if(this.currDungeonBossImage){
+ renderX = (this.mapDataPlayers[uuid].x-this.currDungeonBossImage.topLeftLocation[0])/this.currDungeonBossImage.widthInWorld*size
+ renderY = (this.mapDataPlayers[uuid].y-this.currDungeonBossImage.topLeftLocation[1])/this.currDungeonBossImage.heightInWorld*size
+ }else{
+ renderX = this.mapDataPlayers[uuid].x/this.mapScale/128*size+this.offset[0]/128*size//*16/this.roomWidth
+ renderY = this.mapDataPlayers[uuid].y/this.mapScale/128*size+this.offset[1]/128*size//*16/this.roomWidth
+ }
+
+ if(renderX < 0 || renderX>size
+ || renderY < 0 || renderY > size){
+ xOff = size/2-renderX
+ yOff = size/2-renderY
+ }
+ }
+
+ this.mapImage.draw(x+xOff, y+yOff, size, size)
- this.drawOtherMisc(x, y, size, scale)
+ this.drawOtherMisc(x+xOff, y+yOff, size, scale)
- this.drawPlayersLocations(x, y, size, scale)
+ this.drawPlayersLocations(x+xOff, y+yOff, size, scale)
+
+ renderLibs.stopScizzor()
}
}
@@ -181,13 +236,6 @@ class DungeonMap extends Feature {
if(player.getPing()===-1)return
if(!this.people.includes(player.getName())) return
uuidToPlayer[player.getUUID().toString()] = player
- this.mapDataPlayers[player.getUUID().toString()] = {
- x: player.getX(),
- y: player.getZ(),
- rot: player.getYaw()+180,
- username: player.getName(),
- uuid: player.getUUID().toString()
- }
})
Object.keys(this.mapDataPlayers).forEach((uuid)=>{
@@ -198,10 +246,6 @@ class DungeonMap extends Feature {
if(this.currDungeonBossImage){
renderX = (this.mapDataPlayers[uuid].x-this.currDungeonBossImage.topLeftLocation[0])/this.currDungeonBossImage.widthInWorld*size
renderY = (this.mapDataPlayers[uuid].y-this.currDungeonBossImage.topLeftLocation[1])/this.currDungeonBossImage.heightInWorld*size
- console.log(
- (this.mapDataPlayers[uuid].x-this.currDungeonBossImage.topLeftLocation[0])/this.currDungeonBossImage.widthInWorld,
- (this.mapDataPlayers[uuid].y-this.currDungeonBossImage.topLeftLocation[1])/this.currDungeonBossImage.heightInWorld
- )
}else{
renderX = this.mapDataPlayers[uuid].x/this.mapScale/128*size+this.offset[0]/128*size//*16/this.roomWidth
renderY = this.mapDataPlayers[uuid].y/this.mapScale/128*size+this.offset[1]/128*size//*16/this.roomWidth
@@ -222,10 +266,6 @@ class DungeonMap extends Feature {
if(this.currDungeonBossImage){
renderX = (this.mapDataPlayers[uuid].x-this.currDungeonBossImage.topLeftLocation[0])/this.currDungeonBossImage.widthInWorld*size
renderY = (this.mapDataPlayers[uuid].y-this.currDungeonBossImage.topLeftLocation[1])/this.currDungeonBossImage.heightInWorld*size
- console.log(
- (this.mapDataPlayers[uuid].x-this.currDungeonBossImage.topLeftLocation[0])/this.currDungeonBossImage.widthInWorld,
- (this.mapDataPlayers[uuid].y-this.currDungeonBossImage.topLeftLocation[1])/this.currDungeonBossImage.heightInWorld
- )
}else{
renderX = this.mapDataPlayers[uuid].x/this.mapScale/128*size+this.offset[0]/128*size//*16/this.roomWidth
renderY = this.mapDataPlayers[uuid].y/this.mapScale/128*size+this.offset[1]/128*size//*16/this.roomWidth
@@ -562,6 +602,33 @@ class DungeonMap extends Feature {
// this.mapImage.setImage(this.renderImage)
}
+
+ step5s(){
+ if(!this.FeatureManager.features["dataLoader"].class.isInDungeon) return
+ if(this.people.length < 1) return
+
+ let data = []
+
+ World.getAllPlayers().forEach(player=>{
+ if(player.getPing()===-1)return
+ if(!this.people.includes(player.getName())) return
+ data.push({
+ x: player.getX(),
+ y: player.getZ(),
+ rot: player.getYaw()+180,
+ username: player.getName(),
+ uuid: player.getUUID().toString()
+ })
+ })
+ // console.log("Sending: " + JSON.stringify(this.people, undefined, 2)+JSON.stringify(data, undefined, 2))
+ socketConnection.sendDungeonData(this.people, data)
+ }
+ updateDungeonMapData(data){
+ // console.log("Recieved: " + JSON.stringify(data, undefined, 2))
+ data.forEach(p=>{
+ this.mapDataPlayers[p.uuid] = p
+ })
+ }
getImageForPlayer(uuid){
if(!this.playerImages) return this.defaultPlayerImage