aboutsummaryrefslogtreecommitdiff
path: root/features/cosmetics
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2021-12-24 01:23:11 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2021-12-24 01:23:11 +0800
commita9b64d621f31d7b3f92c27115c2bb50139788e15 (patch)
tree0e3fb96cf11d18b8f31c02a6af446b59e9dd6bc3 /features/cosmetics
parentaf90f8e220733b26098d3c4f4758bccf9f08908c (diff)
downloadSoopyV2-a9b64d621f31d7b3f92c27115c2bb50139788e15.tar.gz
SoopyV2-a9b64d621f31d7b3f92c27115c2bb50139788e15.tar.bz2
SoopyV2-a9b64d621f31d7b3f92c27115c2bb50139788e15.zip
make ingame toggle for cosmetics
Diffstat (limited to 'features/cosmetics')
-rw-r--r--features/cosmetics/cosmetic.js1
-rw-r--r--features/cosmetics/cosmetic/dragon/dragonWings.js3
-rw-r--r--features/cosmetics/index.js64
3 files changed, 53 insertions, 15 deletions
diff --git a/features/cosmetics/cosmetic.js b/features/cosmetics/cosmetic.js
index 997b219..878e425 100644
--- a/features/cosmetics/cosmetic.js
+++ b/features/cosmetics/cosmetic.js
@@ -1,3 +1,4 @@
+
class Cosmetic{
constructor(player, parent, id){
diff --git a/features/cosmetics/cosmetic/dragon/dragonWings.js b/features/cosmetics/cosmetic/dragon/dragonWings.js
index 08a45cc..ee6b055 100644
--- a/features/cosmetics/cosmetic/dragon/dragonWings.js
+++ b/features/cosmetics/cosmetic/dragon/dragonWings.js
@@ -1,10 +1,11 @@
import { f, m, m } from "../../../../../mappings/mappings.js";
+import ToggleSetting from "../../../settings/settingThings/toggle.js";
import Cosmetic from "../../cosmetic.js";
const ModelDragon = Java.type("net.minecraft.client.model.ModelDragon")
if(!GlStateManager){
- var GL11 = Java.type("org.lwjgl.opengl.GL11"); //using var so it goes to global scope
+ // var GL11 = Java.type("org.lwjgl.opengl.GL11"); //using var so it goes to global scope
var GlStateManager = Java.type("net.minecraft.client.renderer.GlStateManager");
}
const Essential = Java.type("gg.essential.Essential")
diff --git a/features/cosmetics/index.js b/features/cosmetics/index.js
index 1eb73d7..f442c45 100644
--- a/features/cosmetics/index.js
+++ b/features/cosmetics/index.js
@@ -4,6 +4,7 @@ import Feature from "../../featureClass/class";
import DragonWings from "./cosmetic/dragon/dragonWings"
import Toggle from "../settings/settingThings/toggle"
import { f } from "../../../mappings/mappings";
+import FakeRequireToggle from "../settings/settingThings/FakeRequireToggle";
class Cosmetics extends Feature {
constructor() {
@@ -29,6 +30,13 @@ class Cosmetics extends Feature {
this.firstPersonVisable = new Toggle("Cosmetics visable in first person", "", false, "cosmetics_first_person_visable", this)
this.lessFirstPersonVisable = new Toggle("Make cosmetics less visable in first person mode", "", true, "cosmetics_first_person_less_visable", this).requires(this.firstPersonVisable)
+ this.dragon_wings_enabled = new Toggle("Dragon Wings Toggle", "", true, "cosmetic_dragon_wings_toggle", this).requires(new FakeRequireToggle(false)).onchange(this, ()=>{
+ global.soopyV2Server.updateCosmeticsData({
+ cosmetic: "dragon_wings",
+ type: this.dragon_wings_enabled.getValue() ? "enable" : "disable"
+ })
+ })
+
this.loadCosmeticsData()
this.worldLoad()
@@ -44,6 +52,20 @@ class Cosmetics extends Feature {
})
this.registerEvent("renderEntity", this.renderEntity)
this.loadedRenderEntity = false
+
+ if(global.soopyV2Server.userCosmeticPermissions){
+ this.updateUserCosmeticPermissionSettings()
+ }
+ }
+
+ updateUserCosmeticPermissionSettings(){
+ if(!this.enabled) return
+
+ if(global.soopyV2Server.userCosmeticPermissions === "*" || global.soopyV2Server.userCosmeticPermissions.dragon_wings){
+ this.dragon_wings_enabled.requiresO.set(true)
+ }else{
+ this.dragon_wings_enabled.requiresO.set(false)
+ }
}
renderWorld(ticks){
@@ -54,8 +76,8 @@ class Cosmetics extends Feature {
renderEntity(entity, pos, ticks, event){
if(ticks !== 1) return
- if(this.uuidToCosmeticDirect[entity.getUUID().toString()]){
- Object.values(this.uuidToCosmeticDirect[entity.getUUID().toString()]).forEach(cosmetic => {
+ if(this.uuidToCosmeticDirect[entity.getUUID().toString().replace(/-/g,"")]){
+ Object.values(this.uuidToCosmeticDirect[entity.getUUID().toString().replace(/-/g,"")]).forEach(cosmetic => {
cosmetic.onRenderEntity(ticks, true)
})
}
@@ -76,14 +98,26 @@ class Cosmetics extends Feature {
setUserCosmeticsInformation(uuid, cosmetics){
if(!this.enabled) return
-
- this.filterUnloadedCosmetics()
+ uuid = uuid.replace(/-/g,"")
if(!cosmetics){
delete this.cosmeticsData[uuid]
return
}
this.cosmeticsData[uuid] = cosmetics
+
+ this.loadedCosmetics = this.loadedCosmetics.filter(cosmetic=>{
+ if(cosmetic.player.getUUID().toString().replace(/-/g,"") === uuid){
+ return false
+ }
+ return true
+ })
+ Object.keys(this.uuidToCosmetic).forEach(cosmeticName=>{
+ delete this.uuidToCosmetic[cosmeticName][uuid]
+ })
+
+ delete this.uuidToCosmeticDirect[uuid]
+
this.scanForNewCosmetics()
}
@@ -93,7 +127,7 @@ class Cosmetics extends Feature {
scanForNewCosmetics(){
this.loadCosmeticsForPlayer(Player)
World.getAllPlayers().forEach(p=>{
- if(p.getUUID().toString() === Player.getUUID().toString()) return
+ if(p.getUUID().toString().replace(/-/g,"") === Player.getUUID().toString().replace(/-/g,"")) return
this.loadCosmeticsForPlayer(p)
})
}
@@ -109,8 +143,8 @@ class Cosmetics extends Feature {
this.loadedCosmetics.push(cosmetic)
this.uuidToCosmetic[cosmeticName][player.getUUID().toString().replace(/-/g,"")] = cosmetic
- if(!this.uuidToCosmeticDirect[player.getUUID.toString()]) this.uuidToCosmeticDirect[player.getUUID().toString()] = {}
- this.uuidToCosmeticDirect[player.getUUID().toString()][cosmeticName] = cosmetic
+ if(!this.uuidToCosmeticDirect[player.getUUID.toString()]) this.uuidToCosmeticDirect[player.getUUID().toString().replace(/-/g,"")] = {}
+ this.uuidToCosmeticDirect[player.getUUID().toString().replace(/-/g,"")][cosmeticName] = cosmetic
}
})
}
@@ -125,18 +159,18 @@ class Cosmetics extends Feature {
}
playerJoined(player){
- if(player.getUUID().toString() === Player.getUUID().toString()) return
+ if(player.getUUID().toString().replace(/-/g,"") === Player.getUUID().toString().replace(/-/g,"")) return
this.loadCosmeticsForPlayer(player)
}
playerLeft(playerName){
- this.loadedCosmetics.filter(cosmetic=>{
- if(cosmetic.player.getUUID().toString() === Player.getUUID().toString()) return true
+ this.loadedCosmetics= this.loadedCosmetics.filter(cosmetic=>{
+ if(cosmetic.player.getUUID().toString().replace(/-/g,"") === Player.getUUID().toString().replace(/-/g,"")) return true
if(cosmetic.player.getName() === playerName){
this.uuidToCosmetic[cosmetic.id][cosmetic.player.getUUID().toString().replace(/-/g,"")] = undefined
- this.uuidToCosmeticDirect[cosmetic.player.getUUID().toString()] = undefined
+ this.uuidToCosmeticDirect[cosmetic.player.getUUID().toString().replace(/-/g,"")] = undefined
return false
}
return true
@@ -157,11 +191,11 @@ class Cosmetics extends Feature {
filterUnloadedCosmetics(tick=false){
this.loadedCosmetics = this.loadedCosmetics.filter(cosmetic => {
if(tick) cosmetic.onTick()
- if(cosmetic.player.getUUID().toString() === Player.getUUID().toString()) return true
+ if(cosmetic.player.getUUID().toString().replace(/-/g,"") === Player.getUUID().toString().replace(/-/g,"")) return true
if(cosmetic.player.getPlayer()[f.isDead]){ //filter out players that are no longer loaded
this.uuidToCosmetic[cosmetic.id][cosmetic.player.getUUID().toString().replace(/-/g,"")] = undefined
- this.uuidToCosmeticDirect[cosmetic.player.getUUID().toString()] = undefined
+ this.uuidToCosmeticDirect[cosmetic.player.getUUID().toString().replace(/-/g,"")] = undefined
return false
}
return true
@@ -199,6 +233,8 @@ class Cosmetics extends Feature {
}
}
+let instance = new Cosmetics()
+
module.exports = {
- class: new Cosmetics()
+ class: instance
} \ No newline at end of file