diff options
-rw-r--r-- | features/bestiary/index.js | 13 | ||||
-rw-r--r-- | features/dungeonMap/index.js | 24 | ||||
-rw-r--r-- | features/dungeonSolvers/index.js | 17 | ||||
-rw-r--r-- | features/events/index.js | 1 | ||||
-rw-r--r-- | features/globalSettings/index.js | 9 | ||||
-rw-r--r-- | features/hud/HudTextElement.js | 9 | ||||
-rw-r--r-- | features/hud/index.js | 9 | ||||
-rw-r--r-- | features/lockedFeatures/index.js | 1 | ||||
-rw-r--r-- | features/mining/index.js | 1 | ||||
-rw-r--r-- | features/slayers/index.js | 1 | ||||
-rw-r--r-- | features/spamHider/index.js | 2 | ||||
-rw-r--r-- | features/waypoints/index.js | 83 | ||||
-rw-r--r-- | index.js | 31 | ||||
-rw-r--r-- | logger.js | 2 | ||||
-rw-r--r-- | utils/renderJavaUtils.js | 138 |
15 files changed, 235 insertions, 106 deletions
diff --git a/features/bestiary/index.js b/features/bestiary/index.js index 00d5752..d21fc2a 100644 --- a/features/bestiary/index.js +++ b/features/bestiary/index.js @@ -59,10 +59,6 @@ class Bestiary extends Feature { } this.registerStep(false, 5, this.updateHudElements) - this.registerEvent("renderOverlay", this.renderHUD) - // TODO - // dragon - // headless_horseman let lastThing = undefined let lastThingTime = 0 this.registerChat("${chat}", (chat) => { @@ -120,12 +116,6 @@ class Bestiary extends Feature { } } - renderHUD() { - for (let stat of this.hudStat) { - stat.textElement.render() - } - } - getBestiaryCount(id) { if (!this.bestiaryData[id]) return "???" let count = this.bestiaryData[id].count @@ -156,6 +146,8 @@ class Bestiary extends Feature { let type = stat.type.getValue() stat.textElement.setText(`&6${this.bestiaryData[type]?.guiName}&7> &f${numberWithCommas(this.getBestiaryCount(type))}`) + } else { + stat.textElement.setText("") } }) } @@ -248,6 +240,7 @@ class Bestiary extends Feature { } onDisable() { + this.hudStat.forEach(h => h.textElement.delete()) this.saveData() } diff --git a/features/dungeonMap/index.js b/features/dungeonMap/index.js index 40bd292..d349fa6 100644 --- a/features/dungeonMap/index.js +++ b/features/dungeonMap/index.js @@ -16,6 +16,7 @@ import ImageLocationSetting from "../settings/settingThings/imageLocation"; import socketConnection from "../../socketConnection"; import SoopyKeyPressEvent from "../../../guimanager/EventListener/SoopyKeyPressEvent"; import SettingBase from "../settings/settingThings/settingBase"; +import { Box } from "../../utils/renderJavaUtils"; const BufferedImage = Java.type("java.awt.image.BufferedImage") const AlphaComposite = Java.type("java.awt.AlphaComposite") @@ -39,7 +40,6 @@ class DungeonMap extends Feature { this.showMapInBoss = new ToggleSetting("Keep showing the map in the dungeon boss room", "This will center the map when in boss to still be usefull", true, "dmap_enable_boss", this) this.borderedHeads = new ToggleSetting("Add a black border around heads on map", "", false, "dmap_border_head", this) this.brBox = new ToggleSetting("Box around doors in br", "In map category because it uses map to find location (no esp)", true, "dmap_door", this) - this.brBoxDisableWhenBloodOpened = new ToggleSetting("Disable blood rush box when blood open", "", true, "dmap_door_disable", this).requires(this.brBox) this.spiritLeapOverlay = new ToggleSetting("Spirit leap overlay", "Cool overlay for the spirit leap menu", true, "spirit_leap_overlay", this) // this.spiritLeapOverlay = new ToggleSetting("Spirit leap overlay", "Cool overlay for the spirit leap menu", true, "spirit_leap_overlay", this).requires(this.spiritLeapOverlay) @@ -91,24 +91,30 @@ class DungeonMap extends Feature { } this.currDungeonBossImage = undefined + this.dungeonBrBoxElm = new Box([0, 0, 0], [3, 4, 3], 1, 0, 0, 1, 3, false) this.bloodOpened = false this.registerChat("&r&cThe &r&c&lBLOOD DOOR&r&c has been opened!&r", () => { this.bloodOpened = true this.keys-- + this.dungeonBrBoxElm.setRGBA(1, 0, 0, 1) + this.dungeonBrBoxElm.stopRender() }) this.registerChat("&r${*}&r&f &r&ehas obtained &r&a&r&${*} Key&r&e!&r", () => { this.keys++ + this.dungeonBrBoxElm.setRGBA(0, 1, 0, 1) }) this.registerChat("&r&eA &r&a&r&${*} Key&r&e was picked up!&r", () => { this.keys++ + this.dungeonBrBoxElm.setRGBA(0, 1, 0, 1) }) this.lastDoorOpener = undefined this.registerChat("&r&a${player}&r&a opened a &r&8&lWITHER &r&adoor!&r", (player) => { this.lastDoorOpener = ChatLib.removeFormatting(player) this.keys-- + this.dungeonBrBoxElm.setRGBA(1, 0, 0, 1) }) this.spiritLeapOverlayGui = new SpiritLeapOverlay(this) @@ -120,7 +126,6 @@ class DungeonMap extends Feature { }).registeredWhen(() => this.isInDungeon()) this.registerStep(false, 5, this.step5s).registeredWhen(() => this.isInDungeon()) this.registerEvent("renderOverlay", this.renderOverlay).registeredWhen(() => this.isInDungeon()) - this.registerEvent("renderWorld", this.renderWorld).registeredWhen(() => this.isInDungeon()) this.registerEvent("worldLoad", this.worldLoad) this.renderingPlayerList = false this.registerEvent("renderPlayerList", () => { @@ -162,6 +167,7 @@ class DungeonMap extends Feature { } worldLoad() { + this.dungeonBrBoxElm.stopRender() this.mortLocation = undefined this.mapDataPlayers = {} this.offset = [] @@ -174,14 +180,6 @@ class DungeonMap extends Feature { this.keys = 0 } - renderWorld() { - if (this.isInDungeon() && this.brBox.getValue()) { - if (this.brBoxLoc && (!this.bloodOpened || !this.brBoxDisableWhenBloodOpened.getValue())) { - drawBoxAtBlock(this.brBoxLoc[0] - 1.5, 69, this.brBoxLoc[1] - 1.5, this.keys === 0 ? 255 : 0, this.keys === 0 ? 0 : 255, 0, 3, 4) - } - } - } - renderOverlay() { if (!this.renderingPlayerList && this.isInDungeon() && this.renderMap.getValue() && !this.spiritLeapOverlayGui.soopyGui.ctGui.isOpen()) { this.drawMap(this.mapLocation.getValue()[0], this.mapLocation.getValue()[1], 100 * this.mapLocation.getValue()[2], 0.5 * this.mapLocation.getValue()[2]) @@ -592,6 +590,11 @@ class DungeonMap extends Feature { this.brBoxLoc = brBoxTemp + + 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 (roomOffsets) { // for(let x = 0;x<128;x++){ // for(let y = 0;y<128;y++){ @@ -731,6 +734,7 @@ class DungeonMap extends Feature { } onDisable() { + this.dungeonBrBoxElm.stopRender() this.initVariables() this.running = false } diff --git a/features/dungeonSolvers/index.js b/features/dungeonSolvers/index.js index 8cd5da0..34c236f 100644 --- a/features/dungeonSolvers/index.js +++ b/features/dungeonSolvers/index.js @@ -169,11 +169,11 @@ class DungeonSolvers extends Feature { }; this.registerStep(true, 2, this.step).registeredWhen(() => this.isInDungeon()); + this.registerStep(false, 60, this.step) this.registerStep(true, 10, this.step2).registeredWhen(() => this.isInDungeon()); this.registerStep(false, 60 * 5, this.step_5min) this.registerEvent("worldLoad", this.onWorldLoad); - this.registerEvent("renderOverlay", this.renderHud).registeredWhen(() => this.isInDungeon()); this.registerEvent("renderWorld", this.renderWorld).registeredWhen(() => this.isInDungeon()); this.bloodOpenedBonus = false; @@ -543,14 +543,6 @@ class DungeonSolvers extends Feature { } } - renderHud() { - 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(""); - } - } - onWorldLoad() { this.goneInBonus = false; this.bloodOpenedBonus = false; @@ -589,6 +581,11 @@ class DungeonSolvers extends Feature { } step2() { + 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 (this.scoreCalculation.getValue()) this.calculateDungeonScore(); if (this.bloodCampAssist.getValue()) { this.skulls.forEach((skull) => { @@ -891,6 +888,8 @@ class DungeonSolvers extends Feature { } onDisable() { + this.hudElements.forEach(h => h.delete()) + this.initVariables(); } } diff --git a/features/events/index.js b/features/events/index.js index d1a075d..9ff7078 100644 --- a/features/events/index.js +++ b/features/events/index.js @@ -450,7 +450,6 @@ class Events extends Feature { this.showingWaypoints = undefined this.lastPath = undefined this.updatingPath = undefined - this.hudElements = undefined this.lastPathCords = undefined } diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js index ef566c9..856791e 100644 --- a/features/globalSettings/index.js +++ b/features/globalSettings/index.js @@ -44,6 +44,8 @@ class GlobalSettings extends Feature { this.reportErrorsSetting = new ToggleSetting("Send module errors to soopy server", "This will allow me to more effectivly fix them", false, "privacy_send_errors", this) + this.hideFallingBlocks = new ToggleSetting("Hide falling blocks", "NOTE: this may cause more/less lag because of render entity event", false, "hide_falling_sand", this) + this.privacySettings = [this.reportErrorsSetting] this.firstLoadPageData = JSON.parse(FileLib.read("soopyAddonsData", "soopyv2firstloaddata.json") || "{}") || {} @@ -53,6 +55,13 @@ class GlobalSettings extends Feature { soopyV2Server.reportErrorsSetting = this.reportErrorsSetting this.registerChat("&aYour new API key is &r&b${key}&r", this.newKey) + const EntityFallingBlock = Java.type("net.minecraft.entity.item.EntityFallingBlock"); + + this.registerEvent('renderEntity', (entity, posVec, partialTicks, event) => { + if (entity.getEntity() instanceof EntityFallingBlock) { + cancel(event); + } + }).registeredWhen(() => this.hideFallingBlocks.getValue()) this.ranFirstLoadThing = false diff --git a/features/hud/HudTextElement.js b/features/hud/HudTextElement.js index de031a2..834ef28 100644 --- a/features/hud/HudTextElement.js +++ b/features/hud/HudTextElement.js @@ -21,6 +21,10 @@ class HudTextElement { this.renderElm = new HudText([""], 0, 0, true).startRender() } + delete() { + this.renderElm.stopRender() + } + setBaseEditWidth(width) { this.editBaseWidth = width return this @@ -49,6 +53,11 @@ class HudTextElement { this.renderElm.stopRender() } } + if (this.toggleSetting.getValue()) { + this.renderElm.startRender() + } else { + this.renderElm.stopRender() + } return this } setLocationSetting(setting) { diff --git a/features/hud/index.js b/features/hud/index.js index b7ea05a..7c679ff 100644 --- a/features/hud/index.js +++ b/features/hud/index.js @@ -130,6 +130,7 @@ class Hud extends Feature { .setLocationSetting(new LocationSetting("Spotify Location", "Allows you to edit the location of the spotify text", "spotify_now_playing_location", this, [10, 80, 1, 1]) .requires(this.showSpotifyPlaying) .editTempText("&6Spotify&7> &cNot open")) + this.hudElements.push(this.spotifyElement) this.spotifyElement2 = new HudTextElement().setToggleSetting(this.showSpotifyPlaying).setLocationSetting({ setParent: () => { }, x: this.spotifyElement.locationSetting.x + this.spotifyElement.getWidth(), @@ -197,6 +198,7 @@ class Hud extends Feature { // .editTempText("Test Line 1\nTest line 2\nTest line 3\nTest line 4 (longer KEKW)")) // this.hudElements.push(this.dragonDamageElement) + this.step_5second() this.lastTickTime = 0 @@ -225,7 +227,7 @@ class Hud extends Feature { this.fps = new SoopyNumber(0) this.lowFps = new SoopyNumber(0) - this.registerEvent("renderOverlay", this.renderHud) + this.registerEvent("renderOverlay", this.renderHud).registeredWhen(() => this.showSpotifyPlaying.getValue() || this.witherImpactCooldownSetting.getValue()) this.registerStep(true, 5, this.step) this.registerStep(false, 5, this.step_5second) this.registerEvent("renderWorld", this.renderWorld).registeredWhen(() => this.fpsEnabledSetting.getValue() && this.fpsFastSetting.getValue()) @@ -333,6 +335,9 @@ class Hud extends Feature { this.fpsFastSetting.delete() this.cpsEnabledSetting.delete() + this.hudStat.forEach(h => h.textElement.delete()) + this.hudElements.forEach(h => h.delete()) + this.initVariables() if (this.packetReceived) this.packetReceived.unregister() @@ -640,6 +645,8 @@ class Hud extends Feature { this.hudStat.forEach(stat => { if (stat.enabled.getValue()) { this.updateHudThing(stat, insb) + } else { + stat.textElement.setText("") } }) } diff --git a/features/lockedFeatures/index.js b/features/lockedFeatures/index.js index 2826626..9314105 100644 --- a/features/lockedFeatures/index.js +++ b/features/lockedFeatures/index.js @@ -111,6 +111,7 @@ class LockedFeatures extends Feature { } onDisable() { + this.hudElements.forEach(h => h.delete()) this.initVariables() } } diff --git a/features/mining/index.js b/features/mining/index.js index d028450..31fa716 100644 --- a/features/mining/index.js +++ b/features/mining/index.js @@ -322,6 +322,7 @@ class Mining extends Feature { } onDisable() { + this.hudElements.forEach(h => h.delete()) this.initVariables() } } diff --git a/features/slayers/index.js b/features/slayers/index.js index 16ac357..5546cad 100644 --- a/features/slayers/index.js +++ b/features/slayers/index.js @@ -565,6 +565,7 @@ class Slayers extends Feature { } onDisable() { + this.hudElements.forEach(h => h.delete()) this.initVariables(); } } diff --git a/features/spamHider/index.js b/features/spamHider/index.js index f5f2259..e1c79f3 100644 --- a/features/spamHider/index.js +++ b/features/spamHider/index.js @@ -127,7 +127,7 @@ class SpamHider extends Feature { }) } } - renderOverlay() { + renderOverlay() { //TODO: move this to java this.SpamHiderMessagesRenderer.render(100, 100, 1, 1) } diff --git a/features/waypoints/index.js b/features/waypoints/index.js index e378898..2dfe46f 100644 --- a/features/waypoints/index.js +++ b/features/waypoints/index.js @@ -2,6 +2,7 @@ /// <reference lib="es2015" /> import { m } from "../../../mappings/mappings"; import Feature from "../../featureClass/class"; +import { Waypoint } from "../../utils/renderJavaUtils"; import { drawCoolWaypoint } from "../../utils/renderUtils"; import SettingBase from "../settings/settingThings/settingBase"; import ToggleSetting from "../settings/settingThings/toggle"; @@ -27,14 +28,13 @@ class Waypoints extends Feature { this.userWaypoints = JSON.parse(FileLib.read("soopyAddonsData", "soopyv2userwaypoints.json") || "{}") this.userWaypointsHash = {} this.userWaypointsAll = [] + this.lastArea = undefined this.userWaypointsArr = Object.values(this.userWaypoints) this.updateWaypointsHashes() this.waypointsChanged = false this.patcherWaypoints = [] - this.registerEvent("renderWorld", this.renderWorld) - this.registerCommand("addwaypoint", (name, x = Math.floor(Player.getX()).toString(), y = Math.floor(Player.getY()).toString(), z = Math.floor(Player.getZ()).toString(), r = "0", g = "255", b = "0", area = "") => { let lx = 0 let ly = 0 @@ -96,55 +96,90 @@ class Waypoints extends Feature { if (this.showInfoInChat.getValue()) ChatLib.chat(this.FeatureManager.messagePrefix + "Loaded waypoints from clipboard!") } catch (e) { if (this.showInfoInChat.getValue()) ChatLib.chat(this.FeatureManager.messagePrefix + "Error loading from clipboard!") + console.log(JSON.stringify(e, undefined, 2)) + console.log(e.stack) } }) this.registerChat("&r${*} &8> ${player}&f: &rx: ${x}, y: ${y}, z: ${z}", (player, x, y, z, e) => { if (this.loadWaypointsFromSendCoords.getValue()) { - this.patcherWaypoints.push([Date.now(), parseInt(x), parseInt(y), parseInt(ChatLib.removeFormatting(z)), ChatLib.addColor(player)]) + this.patcherWaypoints.push([Date.now(), new Waypoint(parseInt(x), parseInt(y), parseInt(ChatLib.removeFormatting(z)), 0, 0, 1, { name: ChatLib.addColor(player), showDist: true }).startRender()]) if (this.patcherWaypoints.length > 10) this.patcherWaypoints.shift() } }) this.registerChat("${player}&r&f: x: ${x}, y: ${y}, z: ${z}", (player, x, y, z, e) => { if (player.includes(">")) return - if (this.loadWaypointsFromSendCoords.getValue()) { - this.patcherWaypoints.push([Date.now(), parseInt(x), parseInt(y), parseInt(ChatLib.removeFormatting(z)), ChatLib.addColor(player)]) + if (this.loadWaypointsFromSendCoords.getValue()) {//parseInt(x), parseInt(y), parseInt(ChatLib.removeFormatting(z)), ChatLib.addColor(player) + this.patcherWaypoints.push([Date.now(), new Waypoint(parseInt(x), parseInt(y), parseInt(ChatLib.removeFormatting(z)), 0, 0, 1, { name: ChatLib.addColor(player), showDist: true }).startRender()]) if (this.patcherWaypoints.length > 10) this.patcherWaypoints.shift() } }) this.registerStep(false, 5, () => { while (this.patcherWaypoints[0]?.[0] < Date.now() - 60000) { - this.patcherWaypoints.shift() + this.patcherWaypoints.shift()[1].stopRender() } }) + + let lastX = 0 + let lastY = 0 + let lastZ = 0 + let lastTick = 0 + this.registerEvent("renderWorld", () => { + if (Math.round(Player.getX()) !== lastX + || Math.round(Player.getY()) !== lastY + || Math.round(Player.getZ()) !== lastZ + || Date.now() - lastTick > 500) { + lastX = Math.round(Player.getX()) + lastY = Math.round(Player.getY()) + lastZ = Math.round(Player.getZ()) + lastTick = Date.now() + + this.tickWaypoints() + } + }) + } + + tickWaypoints() { + for (let waypoint of this.userWaypointsAll) { + waypoint.update() + } + for (let waypoint of this.patcherWaypoints) { + waypoint[1].update() + } + let area = this.FeatureManager.features["dataLoader"] ? this.FeatureManager.features["dataLoader"].class.area : "NONE" + if (this.lastArea && this.lastArea !== area) { + if (this.userWaypointsHash[lastArea]) { + for (let waypoint of this.userWaypointsHash[lastArea]) { + waypoint.stopRender() + } + + } + } + this.lastArea = area + + if (this.userWaypointsHash[area]) { + for (let waypoint of this.userWaypointsHash[area]) { + waypoint.update() + waypoint.startRender() + } + } } updateWaypointsHashes() { + this.userWaypointsAll.forEach(w => w.stopRender()) + Object.values(this.userWaypointsHash).forEach(a => a.forEach(w => w.stopRender())) + this.userWaypointsAll = [] this.userWaypointsHash = {} for (let waypoint of this.userWaypointsArr) { if (!waypoint.area) { - this.userWaypointsAll.push(waypoint) + this.userWaypointsAll.push(new Waypoint(waypoint.x, waypoint.y, waypoint.z, waypoint.r, waypoint.g, waypoint.b, waypoint.options).startRender()) } else { if (!this.userWaypointsHash[waypoint.area]) this.userWaypointsHash[waypoint.area] = [] - this.userWaypointsHash[waypoint.area].push(waypoint) - } - } - } - - renderWorld() { - for (let waypoint of this.userWaypointsAll) { - drawCoolWaypoint(waypoint.x, waypoint.y, waypoint.z, waypoint.r, waypoint.g, waypoint.b, waypoint.options) - } - if (this.userWaypointsHash[this.FeatureManager.features["dataLoader"].class.area]) { - for (let waypoint of this.userWaypointsHash[this.FeatureManager.features["dataLoader"].class.area]) { - drawCoolWaypoint(waypoint.x, waypoint.y, waypoint.z, waypoint.r, waypoint.g, waypoint.b, waypoint.options) + this.userWaypointsHash[waypoint.area].push(new Waypoint(waypoint.x, waypoint.y, waypoint.z, waypoint.r, waypoint.g, waypoint.b, waypoint.options)) } } - for (let waypoint of this.patcherWaypoints) { - drawCoolWaypoint(waypoint[1], waypoint[2], waypoint[3], 0, 255, 0, { name: waypoint[4] }) - } } initVariables() { @@ -152,6 +187,10 @@ class Waypoints extends Feature { } onDisable() { + this.userWaypointsAll.forEach(w => w.stopRender()) + Object.values(this.userWaypointsHash).forEach(a => a.forEach(w => w.stopRender())) + this.patcherWaypoints.forEach(p => p[1].stopRender()) + if (this.waypointsChanged) { FileLib.write("soopyAddonsData", "soopyv2userwaypoints.json", JSON.stringify(this.userWaypoints)) } @@ -23,21 +23,24 @@ if (FileLib.read("soopyAddonsData", "deletesoopyv1please.txt") === "true") { ChatLib.command("ct reload", true) }).start() } else { - if (FileLib.read("soopyAddonsData", "firstload.txt") !== "true") { - new Thread(() => { - ChatLib.chat("&7Loading SoopyV2 required modules...") //idk what to say to chat, but it requires an extra ct load after starting to load stuff like mappings (maby this should be part of mappings module, but i put it here so it doesent try to load the first load page thingo) - FileLib.write("soopyAddonsData", "firstload.txt", "true") - Thread.sleep(2000) - - ChatLib.command("ct reload", true) - }).start() - } else { - let a = register("worldLoad", () => { + let a = register("worldLoad", () => { + if (FileLib.read("soopyAddonsData", "firstload.txt") !== "true") { + b = register("tick", () => { + new Thread(() => { + ChatLib.chat("&7Loading SoopyV2 required modules...") //idk what to say to chat, but it requires an extra ct load after starting to load stuff like mappings (maby this should be part of mappings module, but i put it here so it doesent try to load the first load page thingo) + FileLib.write("soopyAddonsData", "firstload.txt", "true") + Thread.sleep(2000) + + ChatLib.command("ct reload", true) + }).start() + + b.unregister() + }) + } else { new SoopyAddons() - - a.unregister() - }) - } + } + a.unregister() + }) } if (new File("./config/ChatTriggers/modules/SoopyV2UpdateButtonPatcher").exists()) { @@ -39,7 +39,7 @@ if (!global.soopyv2loggerthing) { devs.push(Player.getUUID().toString().replace(/-/g, "")) global.soopyv2loggerthing.isDev = isDev() global.soopyv2featuremanagerthing.isDev = isDev() - }).setName("pleasegivemeaccesstosoopyv2devconsolelogs") //yep + }).setName("pleasegivemeaccesstosoopyv2devconsolelogs", true) //yep register("gameUnload", () => { global.soopyv2loggerthing = undefined diff --git a/utils/renderJavaUtils.js b/utils/renderJavaUtils.js index d3af176..0903986 100644 --- a/utils/renderJavaUtils.js +++ b/utils/renderJavaUtils.js @@ -1,6 +1,10 @@ +import { m } from "../../mappings/mappings" +import { numberWithCommas } from "./numberUtils" + let SoopyV2Forge = Java.type("me.soopyboo32.soopyv2forge.SoopyV2Forge").INSTANCE let LASTEST_SOOPYFORGE_VER = "1.0" +let canUseForgeRendering = net.minecraftforge.fml.common.Loader.isModLoaded("soopyv2forge") && SoopyV2Forge.getVersion() === LASTEST_SOOPYFORGE_VER let ArrayList = Java.type("java.util.ArrayList") @@ -15,25 +19,40 @@ let HudTextC = Java.type("me.soopyboo32.soopyv2forge.RenderTypes.HudText") let RenderWorldThings = new Set() let RenderHudThings = new Set() +register("gameUnload", () => { + RenderWorldThings.clear() + SoopyV2Forge.setRenderWorldList(new ArrayList([])) + RenderHudThings.clear() + SoopyV2Forge.setRenderHudList(new ArrayList([])) +}) + class RenderWorldAble { - startRender() { + startRender(isBatched) { + if (!canUseForgeRendering) return + if (RenderWorldThings.has(this.javaObj)) return this RenderWorldThings.add(this.javaObj) - SoopyV2Forge.setRenderWorldList(new ArrayList([...RenderWorldThings])) + if (!isBatched) SoopyV2Forge.setRenderWorldList(new ArrayList([...RenderWorldThings])) return this } - stopRender() { + stopRender(isBatched) { + if (!canUseForgeRendering) return + if (!RenderWorldThings.has(this.javaObj)) return this RenderWorldThings.delete(this.javaObj) - SoopyV2Forge.setRenderWorldList(new ArrayList([...RenderWorldThings])) + if (!isBatched) SoopyV2Forge.setRenderWorldList(new ArrayList([...RenderWorldThings])) return this } } class RenderHudAble { startRender() { + if (!canUseForgeRendering) return + if (RenderHudThings.has(this.javaObj)) return this RenderHudThings.add(this.javaObj) SoopyV2Forge.setRenderHudList(new ArrayList([...RenderHudThings])) return this } stopRender() { + if (!canUseForgeRendering) return + if (!RenderHudThings.has(this.javaObj)) return this RenderHudThings.delete(this.javaObj) SoopyV2Forge.setRenderHudList(new ArrayList([...RenderHudThings])) return this @@ -169,7 +188,7 @@ export class WorldText extends RenderWorldAble { } setLocation(location) { - this.javaObj.location = location + this.javaObj.location = new Vec3(...location) return this } setText(text) { @@ -196,7 +215,7 @@ export class Beacon extends RenderWorldAble { } setLocation(location) { - this.javaObj.location = location + this.javaObj.location = new Vec3(...location) return this } setRGBA(r, g, b, a) { @@ -264,53 +283,98 @@ export class HudText extends RenderHudAble { } } -// let data = [] +export class Waypoint extends FilledBox { + constructor(x, y, z, r, g, b, { name = "", showDist = !!name, phase = false }) { + this.rendering = false + + let distToPlayerSq = (x - Player.getRenderX()) ** 2 + (y - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) ** 2 + (z - Player.getRenderZ()) ** 2 + + let alpha = Math.min(1, Math.max(0, 1 - (distToPlayerSq - 10000) / 12500)) + + super([x - 0.001, y - 0.001, z - 0.001], [1.002, 1.002, 1.002], r, g, b, 0.25 * alpha, 1, !phase) + + this.params = { x, y, z, r, g, b, name, showDist, phase } + + this.outLine = new Box([x - 0.002, y - 0.002, z - 0.002], [1.004, 1.004, 1.004], r, g, b, alpha, 3, !phase) + this.beam = new Beacon([x, y + 1, z], r, g, b, Math.min(1, Math.max(0, (distToPlayerSq - 25) / 100)) * alpha, true) + + let distToPlayer = Math.sqrt(distToPlayerSq) + + let distRender = Math.min(distToPlayer, 50) + + let loc5 = [Player.getRenderX() + (x + 0.5 - Player.getRenderX()) / (distToPlayer / distRender), (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]()) + (y + 2 + 20 * distToPlayer / 300 - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) / (distToPlayer / distRender), Player.getRenderZ() + (z + 0.5 - Player.getRenderZ()) / (distToPlayer / distRender)] + let loc6 = [Player.getRenderX() + (x + 0.5 - Player.getRenderX()) / (distToPlayer / distRender), (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]()) + (y + 2 + 20 * distToPlayer / 300 - 10 * distToPlayer / 300 - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) / (distToPlayer / distRender), Player.getRenderZ() + (z + 0.5 - Player.getRenderZ()) / (distToPlayer / distRender)] + + this.textLine1 = new WorldText([loc5[0], loc5[1], loc5[2]], "§a" + name, false, distRender / 12) + this.textLine2 = new WorldText([(name ? loc6[0] : loc5[0]), (name ? loc6[1] : loc5[1]), (name ? loc6[2] : loc5[2])], "§b(" + numberWithCommas(Math.round(distToPlayer)) + "m)", false, distRender / 12) + } + + update() { + let { x, y, z, r, g, b, name, showDist } = this.params + + let distToPlayerSq = (x - Player.getRenderX()) ** 2 + (y - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) ** 2 + (z - Player.getRenderZ()) ** 2 + + let alpha = Math.min(1, Math.max(0, 1 - (distToPlayerSq - 10000) / 12500)) -// data.push(createPoints([[108, 70, 63], [108, 71, 63], [108, 70, 67], [108, 70, 63]], 1, 0, 0, 1, 2, true)) -// data.push(createWorldText([115, 73, 63], "Text §dWOW §6YEP", true, 1)) -// data.push(createBeacon([115, 75, 63], 0, 1, 0, 1, true)) + this.setRGBA(r, g, b, 0.25 * alpha) + this.outLine.setRGBA(r, g, b, alpha) + this.beam.setRGBA(r, g, b, Math.min(1, Math.max(0, (distToPlayerSq - 25) / 100)) * alpha) -// SoopyV2Forge.setRenderWorldList(new ArrayList(data)) + if (name || showDist) { + let distToPlayer = Math.sqrt(distToPlayerSq) -// let data2 = [] + let distRender = Math.min(distToPlayer, 100) -// data2.push(createHudPoints([[10, 10], [50, 10], [50, 20], [10, 10]], 0, 0, 1, 1, 5)) -// data2[data2.length - 1].glmode = 5 -// data2.push(createHudText("Text §dWOW §6YEP", 10, 30, true)) + let loc5 = [Player.getRenderX() + (x + 0.5 - Player.getRenderX()) / (distToPlayer / distRender), (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]()) + (y + 2 + 20 * distToPlayer / 300 - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) / (distToPlayer / distRender), Player.getRenderZ() + (z + 0.5 - Player.getRenderZ()) / (distToPlayer / distRender)] + let loc6 = [Player.getRenderX() + (x + 0.5 - Player.getRenderX()) / (distToPlayer / distRender), (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]()) + (y + 2 + 20 * distToPlayer / 300 - 10 * distToPlayer / 300 - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) / (distToPlayer / distRender), Player.getRenderZ() + (z + 0.5 - Player.getRenderZ()) / (distToPlayer / distRender)] -// SoopyV2Forge.setRenderHudList(new ArrayList(data2)) + this.textLine1.setLocation([loc5[0], loc5[1], loc5[2]]).setScale(distRender / 12) + this.textLine2.setLocation([(name ? loc6[0] : loc5[0]), (name ? loc6[1] : loc5[1]), (name ? loc6[2] : loc5[2])]).setScale(distRender / 12).setText("§b(" + numberWithCommas(Math.round(distToPlayer)) + "m)") + } + } + + startRender(isBatched) { + if (this.rendering) return this + this.rendering = true + + super.startRender(true) + this.outLine.startRender(true) + this.beam.startRender(true) + if (this.params.name) this.textLine1.startRender(true) + if (this.params.showDist) this.textLine2.startRender(true) + + if (!isBatched) SoopyV2Forge.setRenderWorldList(new ArrayList([...RenderWorldThings])) + return this + } + + stopRender(isBatched) { + if (!this.rendering) return this + this.rendering = false + + super.stopRender(true) + this.outLine.stopRender(true) + this.beam.stopRender(true) + this.textLine1.stopRender(true) + this.textLine2.stopRender(true) + + if (!isBatched) SoopyV2Forge.setRenderWorldList(new ArrayList([...RenderWorldThings])) + return this + } +} register("worldLoad", () => { if (!net.minecraftforge.fml.common.Loader.isModLoaded("soopyv2forge")) { ChatLib.chat("&1" + ChatLib.getChatBreak("-").trim()) ChatLib.chat("§cWARNING: You dont have the forge mod for soopyv2 installed") - ChatLib.chat("§cWARNING: If you have the mod installed it will take over rendering") - ChatLib.chat("§cWARNING: And improve performance quite a bit") + ChatLib.chat("§cWARNING: -> almost nothing can be rendered") new TextComponent(" &e[CLICK] &7- Download").setHover("show_text", "&2Download").setClick("open_url", "https://github.com/Soopyboo32/SoopyV2Forge/releases").chat() ChatLib.chat("&1" + ChatLib.getChatBreak("-").trim()) } if (SoopyV2Forge.getVersion() !== LASTEST_SOOPYFORGE_VER) { ChatLib.chat("&1" + ChatLib.getChatBreak("-").trim()) ChatLib.chat("§cWARNING: Your forge version of soopyv2 is outdated") - ChatLib.chat("§cWARNING: Chattriggers will take over rendering") - ChatLib.chat("§cWARNING: This will hurt performance quite a bit") + ChatLib.chat("§cWARNING: -> almost nothing can be rendered") new TextComponent(" &e[CLICK] &7- Download").setHover("show_text", "&2Download update").setClick("open_url", "https://github.com/Soopyboo32/SoopyV2Forge/releases").chat() ChatLib.chat("&1" + ChatLib.getChatBreak("-").trim()) } -}) - -let renderWorldList -let renderHudList - -let shouldUseForgeRendering = net.minecraftforge.fml.common.Loader.isModLoaded("soopyv2forge") && SoopyV2Forge.getVersion() === LASTEST_SOOPYFORGE_VER - -if (!shouldUseForgeRendering) { - renderWorldList = [] - renderHudList = [] - register("renderOverlay", (ticks) => { - - }) - register("renderWorld", (ticks) => { - - }) -}
\ No newline at end of file +})
\ No newline at end of file |