aboutsummaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-04-03 16:44:29 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-04-03 16:44:29 +0800
commitd7dd016c1f4e4732dae6f4eb718fefa24462704b (patch)
tree0327c15068261ec223e2a49f4575defad5980074 /features
parentbe90cd09f07e8cd2112812036b1f6eb4942eb0b4 (diff)
downloadSoopyV2-d7dd016c1f4e4732dae6f4eb718fefa24462704b.tar.gz
SoopyV2-d7dd016c1f4e4732dae6f4eb718fefa24462704b.tar.bz2
SoopyV2-d7dd016c1f4e4732dae6f4eb718fefa24462704b.zip
add waypoints
Diffstat (limited to 'features')
-rw-r--r--features/events/index.js30
-rw-r--r--features/settings/settingThings/dropdownSetting.js9
-rw-r--r--features/settings/settingThings/settingBase.js4
-rw-r--r--features/settings/settingThings/textSetting.js10
-rw-r--r--features/waypoints/index.js112
-rw-r--r--features/waypoints/metadata.json8
6 files changed, 153 insertions, 20 deletions
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