diff options
-rw-r--r-- | featureClass/featureManager.js | 2 | ||||
-rw-r--r-- | features/events/index.js | 30 | ||||
-rw-r--r-- | features/settings/settingThings/dropdownSetting.js | 9 | ||||
-rw-r--r-- | features/settings/settingThings/settingBase.js | 4 | ||||
-rw-r--r-- | features/settings/settingThings/textSetting.js | 10 | ||||
-rw-r--r-- | features/waypoints/index.js | 112 | ||||
-rw-r--r-- | features/waypoints/metadata.json | 8 | ||||
-rw-r--r-- | metadata.json | 6 | ||||
-rw-r--r-- | utils/renderLib2d.js | 2 | ||||
-rw-r--r-- | utils/renderUtils.js | 48 |
10 files changed, 200 insertions, 31 deletions
diff --git a/featureClass/featureManager.js b/featureClass/featureManager.js index 8b5a023..809e608 100644 --- a/featureClass/featureManager.js +++ b/featureClass/featureManager.js @@ -442,7 +442,7 @@ class FeatureManager { func.call(context, ...(args || [])) let time = Date.now()-start if(time > this.longEventTime){ - console.log(this.messagePrefix + "Long (forge) event triggered (" + context.constructor.name + "/" + event.class.toString() + ")") + logger.logMessage("Long (forge) event triggered (" + context.constructor.name + "/" + event.class.toString() + ")", 3) } this.stopRecordingPerformance(context.constructor.name, event.class.name) } diff --git a/features/events/index.js b/features/events/index.js index 664b675..cc2c3e5 100644 --- a/features/events/index.js +++ b/features/events/index.js @@ -2,7 +2,7 @@ /// <reference lib="es2015" /> import Feature from "../../featureClass/class"; import { f } from "../../../mappings/mappings"; -import { drawBoxAtBlock, drawBoxAtBlockNotVisThruWalls, drawLine } from "../../utils/renderUtils"; +import { drawBoxAtBlock, drawBoxAtBlockNotVisThruWalls, drawCoolWaypoint, drawLine } from "../../utils/renderUtils"; import { calculateDistance, calculateDistanceQuick, fastestPathThrough } from "../../utils/utils"; import HudTextElement from "../hud/HudTextElement"; import LocationSetting from "../settings/settingThings/location"; @@ -101,24 +101,16 @@ class Events extends Feature { if(loc.lastPing && Date.now()-loc.lastPing < 500){ blue = true } - drawBoxAtBlock(loc.x, loc.y,loc.z,0,blue?100:255,blue?255:0) - } - if(loc.fromApi){ - Tessellator.drawString( - "(" + (loc.chain+1) + "/4) " + typeReplace[loc.type] + " BURRIAL (" + Math.round(calculateDistance([Player.getX(),Player.getY(),Player.getZ()],[loc.x+0.5,loc.y+2.5,loc.z+0.5])) + "m)", - loc.x+0.5, - loc.y+1.5, - loc.z+0.5, - loc.clicked? 65280:(loc.nearest?16711680:6579300), true, loc.clicked? 0.04:(loc.nearest?1:0.5), !loc.clicked - ); - }else{ - Tessellator.drawString( - typeReplace[loc.type] + " BURRIAL (" + Math.round(calculateDistance([Player.getX(),Player.getY(),Player.getZ()],[loc.x+0.5,loc.y+2.5,loc.z+0.5])) + "m)", - loc.x+0.5, - loc.y+1.5, - loc.z+0.5, - loc.clicked? 65280:(loc.nearest?16711680:6579300), true, loc.clicked? 0.04:(loc.nearest?1:0.5), !loc.clicked - ); + + let name = "" + + if(loc.fromApi){ + name = (loc.nearest?"§c":"§a")+"(" + (loc.chain+1) + "/4) " + typeReplace[loc.type] + " burrial" + }else{ + name = (loc.nearest?"§c":"§a")+typeReplace[loc.type] + " burrial" + } + + drawCoolWaypoint(loc.x, loc.y,loc.z,0,blue?100:255,blue?255:0, {name: name}) } }) } diff --git a/features/settings/settingThings/dropdownSetting.js b/features/settings/settingThings/dropdownSetting.js index 6681d68..0cf7b27 100644 --- a/features/settings/settingThings/dropdownSetting.js +++ b/features/settings/settingThings/dropdownSetting.js @@ -19,6 +19,15 @@ class DropdownSetting extends SettingBase { })) } + update(){ + if(this.hasHelp()){ + this.guiObject.addChild(this.helpButton) + + this.guiObject.text.setLocation(0.075, 0, 0.6-0.075, 0.6) + }else{ + this.guiObject.text.setLocation(0, 0, 0.6, 0.6) + } + } setValue(newVal){ super.setValue(newVal) diff --git a/features/settings/settingThings/settingBase.js b/features/settings/settingThings/settingBase.js index 8093179..36bfcc1 100644 --- a/features/settings/settingThings/settingBase.js +++ b/features/settings/settingThings/settingBase.js @@ -64,6 +64,10 @@ class SettingBase { update(){ if(this.hasHelp()){ this.guiObject.addChild(this.helpButton) + + this.guiObject.text.setLocation(0.075, 0, 0.8-0.075, 0.6) + }else{ + this.guiObject.text.setLocation(0, 0, 0.8, 0.6) } } diff --git a/features/settings/settingThings/textSetting.js b/features/settings/settingThings/textSetting.js index 4666fbf..1ce53ab 100644 --- a/features/settings/settingThings/textSetting.js +++ b/features/settings/settingThings/textSetting.js @@ -20,7 +20,15 @@ class TextSetting extends SettingBase { })) } - + update(){ + if(this.hasHelp()){ + this.guiObject.addChild(this.helpButton) + + this.guiObject.text.setLocation(0.075, 0, 0.6-0.075, 0.6) + }else{ + this.guiObject.text.setLocation(0, 0, 0.6, 0.6) + } + } setValue(newVal){ super.setValue(newVal) diff --git a/features/waypoints/index.js b/features/waypoints/index.js new file mode 100644 index 0000000..755780d --- /dev/null +++ b/features/waypoints/index.js @@ -0,0 +1,112 @@ +/// <reference types="../../../CTAutocomplete" /> +/// <reference lib="es2015" /> +import { m } from "../../../mappings/mappings"; +import Feature from "../../featureClass/class"; +import { drawCoolWaypoint } from "../../utils/renderUtils"; +import SettingBase from "../settings/settingThings/settingBase"; + +const RenderWorldLastEvent = Java.type("net.minecraftforge.client.event.RenderWorldLastEvent") + +class Waypoints extends Feature { + constructor() { + super() + } + + onEnable(){ + this.initVariables() + + new SettingBase("/addwaypoint [name] [x] [y] [z] [r?] [g?] [b?]", "Allows you to create a waypoint", undefined, "create_waypoint", this) + new SettingBase("/delwaypoint [name]", "Allows you to delete a waypoint", undefined, "delete_waypoint", this) + new SettingBase("/clearwaypoints", "Allows you to clear all the waypoints", undefined, "clear_waypoints", this) + new SettingBase("/savewaypoints", "Copys the waypoints to your clipboard", undefined, "save_waypoints", this) + new SettingBase("/loadwaypoints", "Loads waypoints from your clipboard", undefined, "load_waypoints", this) + + this.waypoints = [] + this.userWaypoints = {} + + this.registerForge(RenderWorldLastEvent, this.renderWorldLast) + + 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")=>{ + let lx = 0 + let ly = 0 + let lz = 0 + + if(Player.lookingAt().getX){ + lx = Player.lookingAt().getX() + ly = Player.lookingAt().getY() + lz = Player.lookingAt().getZ() + + if(Player.lookingAt().getWidth){ + lx += -0.5 + lz += -0.5 + } + } + + this.userWaypoints[name] = { + x: parseFloat(x.replace("l", lx)), + y: parseFloat(y.replace("l", ly)), + z: parseFloat(z.replace("l", lz)), + r: parseInt(r), + g: parseInt(g), + b: parseInt(b), + options: {name: ChatLib.addColor(name.replace(/_/g," "))} + } + ChatLib.chat(this.FeatureManager.messagePrefix + "Added waypoint "+ name + "!") + }) + + this.registerCommand("delwaypoint", (name)=>{ + delete this.userWaypoints[name] + ChatLib.chat(this.FeatureManager.messagePrefix + "Deleted waypoint "+ name + "!") + }) + this.registerCommand("clearwaypoints", ()=>{ + this.userWaypoints = {} + ChatLib.chat(this.FeatureManager.messagePrefix + "Cleared waypoints!") + }) + this.registerCommand("savewaypoints", ()=>{ + Java.type("net.minecraft.client.gui.GuiScreen")[m.setClipboardString](JSON.stringify(this.userWaypoints)) + ChatLib.chat(this.FeatureManager.messagePrefix + "Saved waypoints to clipboard!") + }) + this.registerCommand("loadwaypoints", ()=>{ + try{ + this.userWaypoints = JSON.parse(Java.type("net.minecraft.client.gui.GuiScreen")[m.getClipboardString]()) + ChatLib.chat(this.FeatureManager.messagePrefix + "Loaded waypoints from clipboard!") + }catch(e){ + ChatLib.chat(this.FeatureManager.messagePrefix + "Error loading from clipboard!") + } + }) + } + + addWaypoint(x, y, z, r, g, b, options){ + this.waypoints.push({ + x: x, + y: y, + z: z, + r: r, + g: g, + b: b, + options: options + }) + } + + renderWorldLast(){ + for(let waypoint of this.waypoints){ + drawCoolWaypoint(waypoint.x, waypoint.y, waypoint.z, waypoint.r, waypoint.g, waypoint.b, waypoint.options) + } + let waypoints2 = Object.values(this.userWaypoints) + for(let waypoint of waypoints2){ + drawCoolWaypoint(waypoint.x, waypoint.y, waypoint.z, waypoint.r, waypoint.g, waypoint.b, {...waypoint.options}) + } + } + + initVariables(){ + this.waypoints = undefined + } + + onDisable(){ + this.initVariables() + } +} + +module.exports = { + class: new Waypoints() +}
\ No newline at end of file diff --git a/features/waypoints/metadata.json b/features/waypoints/metadata.json new file mode 100644 index 0000000..c162b72 --- /dev/null +++ b/features/waypoints/metadata.json @@ -0,0 +1,8 @@ +{ + "name": "Waypoints", + "description": "Allows rendering + creation of custom waypoints", + "isHidden": false, + "isTogglable": true, + "defaultEnabled": true, + "sortA": 0 +}
\ No newline at end of file diff --git a/metadata.json b/metadata.json index db767eb..3cc9e8d 100644 --- a/metadata.json +++ b/metadata.json @@ -5,7 +5,7 @@ "entry": "index.js", "description": "SoopyV2", "name": "SoopyV2", - "version": "2.1.46", - "versionId": 173, - "requires": ["soopyApis", "soopyAddonsData", "CustomTabCompletions", "guimanager", "mappings"] + "version": "2.1.47", + "versionId": 174, + "requires": ["soopyApis", "soopyAddonsData", "CustomTabCompletions", "guimanager", "mappings","BeaconBeam"] } diff --git a/utils/renderLib2d.js b/utils/renderLib2d.js index 6721760..30ac28f 100644 --- a/utils/renderLib2d.js +++ b/utils/renderLib2d.js @@ -7,7 +7,7 @@ // Edit: iv added some features to this so might keep as is //-------------------------------------------------------------------------- -import { f, m } from "../mappings/mappings"; +import { f, m } from "../../mappings/mappings"; const BufferUtils = org.lwjgl.BufferUtils; diff --git a/utils/renderUtils.js b/utils/renderUtils.js index 81bd2ea..c437254 100644 --- a/utils/renderUtils.js +++ b/utils/renderUtils.js @@ -1,10 +1,14 @@ const { f, m } = require("../../mappings/mappings"); +const {default:renderBeaconBeam2} = require("../../BeaconBeam/index"); +const numberUtils = require("./numberUtils"); +const { default: RenderLib2D } = require("./renderLib2d"); + if(!GlStateManager){ 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"); } -module.exports = { +let ret = { /* accepts parameters * h Object = {h:x, s:y, v:z} @@ -126,7 +130,7 @@ module.exports = { GL11.glDepthMask(true); GL11.glDisable(GL11.GL_BLEND); }, - drawBoxAtBlockNotVisThruWalls:function (x, y, z, colorR, colorG, colorB, w=1, h=1){ + drawBoxAtBlockNotVisThruWalls:function (x, y, z, colorR, colorG, colorB, w=1, h=1, a=1){ GL11.glBlendFunc(770, 771); GL11.glEnable(GL11.GL_BLEND); GL11.glLineWidth(3); @@ -139,7 +143,7 @@ module.exports = { w += 0.01 h += 0.01 - Tessellator.begin(3).colorize(colorR, colorG, colorB); + Tessellator.begin(3).colorize(colorR, colorG, colorB, a); Tessellator.pos(x+w,y+h,z+w); Tessellator.pos(x+w,y+h,z); @@ -167,7 +171,7 @@ module.exports = { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); }, - drawBoxAtBlock:function (x, y, z, colorR, colorG, colorB, w=1, h=1){ + drawBoxAtBlock:function (x, y, z, colorR, colorG, colorB, w=1, h=1, a=1){ GL11.glBlendFunc(770, 771); GL11.glEnable(GL11.GL_BLEND); @@ -178,7 +182,7 @@ module.exports = { GlStateManager[m.pushMatrix]() - Tessellator.begin(3).colorize(colorR, colorG, colorB); + Tessellator.begin(3).colorize(colorR, colorG, colorB, a); Tessellator.pos(x+w,y+h,z+w); Tessellator.pos(x+w,y+h,z); @@ -327,5 +331,37 @@ module.exports = { GL11.glDepthMask(true); GL11.glDisable(GL11.GL_BLEND); } + }, + renderBeaconBeam(x, y, z, r, g, b, alpha, phase){ + renderBeaconBeam2(x, y, z, r, g, b, alpha, !phase) + }, + drawCoolWaypoint(x, y, z, r, g, b, {name="", showDist=!!name ,phase=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)) + + ret[phase?"drawBoxAtBlock":"drawBoxAtBlockNotVisThruWalls"](x-0.005, y-0.005, z-0.005, r, g, b, 1.01, 1.01, alpha) + ret.drawFilledBox(x+0.5, y, z+0.5, 1.02, 1.02, r, g, b, 0.25*alpha, phase) + ret.renderBeaconBeam(x, y+1, z, r, g, b, Math.min(1,Math.max(0,(distToPlayerSq-25)/100))*alpha, false) + + if(name || showDist){ + let distToPlayer = Math.sqrt(distToPlayerSq) + + let distRender = Math.min(distToPlayer,50) + + let loc1 = [x+0.5, y+2+20*distToPlayer/300, z+0.5] + let loc2 = [x+0.5, y+2+20*distToPlayer/300-10*distToPlayer/300, z+0.5] + + let loc3 = [loc1[0]-Player.getRenderX(), loc1[1]-(Player.getRenderY()+Player.getPlayer()[m.getEyeHeight]()), loc1[2]-Player.getRenderZ()] + let loc4 = [loc2[0]-Player.getRenderX(), loc2[1]-(Player.getRenderY()+Player.getPlayer()[m.getEyeHeight]()), loc2[2]-Player.getRenderZ()] + + let loc5 = [Player.getRenderX()+loc3[0]/(distToPlayer/distRender), (Player.getRenderY()+Player.getPlayer()[m.getEyeHeight]())+loc3[1]/(distToPlayer/distRender), Player.getRenderZ()+loc3[2]/(distToPlayer/distRender)] + let loc6 = [Player.getRenderX()+loc4[0]/(distToPlayer/distRender), (Player.getRenderY()+Player.getPlayer()[m.getEyeHeight]())+loc4[1]/(distToPlayer/distRender), Player.getRenderZ()+loc4[2]/(distToPlayer/distRender)] + + if(name) Tessellator.drawString("§a" + name, loc5[0], loc5[1], loc5[2], 0, true, distRender/300, false) + if(showDist) Tessellator.drawString("§b(" + numberUtils.numberWithCommas(Math.round(distToPlayer)) + "m)", (name?loc6[0]:loc5[0]), (name?loc6[1]:loc5[1]), (name?loc6[2]:loc5[2]), 0, false, distRender/300, false) + } } -}
\ No newline at end of file +} + +module.exports = ret
\ No newline at end of file |