aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/roomdata.json (renamed from features/dungeonRoutes/temproomdata.json)0
-rw-r--r--features/dungeonMap/index.js32
-rw-r--r--features/dungeonMap2/DungeonMapData.js80
-rw-r--r--features/dungeonMap2/DungeonMapRoom.js134
-rw-r--r--features/dungeonMap2/DungeonRoomStaticData.js19
-rw-r--r--features/dungeonMap2/index.js199
-rw-r--r--features/dungeonMap2/metadata.json8
-rw-r--r--features/dungeonRoutes/index.js2
-rw-r--r--features/waypoints/index.js15
9 files changed, 471 insertions, 18 deletions
diff --git a/features/dungeonRoutes/temproomdata.json b/data/roomdata.json
index 4f9661d..4f9661d 100644
--- a/features/dungeonRoutes/temproomdata.json
+++ b/data/roomdata.json
diff --git a/features/dungeonMap/index.js b/features/dungeonMap/index.js
index ced41d2..4befbbf 100644
--- a/features/dungeonMap/index.js
+++ b/features/dungeonMap/index.js
@@ -194,18 +194,24 @@ class DungeonMap extends Feature {
return
}
// if (curr === max) curr = "&a" + curr
- if (this.roomDataStuff.get(loc.join(",")) !== curr + " " + max) {
- this.roomDataStuff.set(loc.join(","), curr + " " + max)
+ if (!this.roomDataStuff.get(loc.join(",")) || this.roomDataStuff.get(loc.join(","))[0] !== curr + " " + max) {
+ this.roomDataStuff.set(loc.join(","), [curr + " " + max, this.getCurrentRoomId()])
- socketConnection.sendDungeonData2(this.people, [loc.join(","), curr + " " + max])
+ socketConnection.sendDungeonData2(this.people, [loc.join(","), curr + " " + max, this.getCurrentRoomId()])
}
})
registerActionBar.trigger.setCriteria('&7${curr}/${max} Secrets').setParameter('contains');
}
+ getCurrentRoomId() {
+ let id = Scoreboard.getLineByIndex(Scoreboard.getLines().length - 1).getName().trim().split(" ").pop()
+
+ return id
+ }
+
updateDungeonMapData2(data) {
// console.log("Recieved: " + JSON.stringify(data, undefined, 2))
- this.roomDataStuff.set(data[0], data[1])
+ this.roomDataStuff.set(data[0], [data[1], data[2]])
}
worldLoad() {
this.dungeonBrBoxElm.stopRender()
@@ -358,10 +364,12 @@ class DungeonMap extends Feature {
if (this.currDungeonBossImage) return
if (this.roomsecrets.getValue()) {
for (let ent of this.roomDataStuffRender.entries()) {
- let [loc, val] = ent
+ let [loc, [secrets, roomid, color]] = ent
let [x, y] = loc.split(",")
- let val2 = ChatLib.removeFormatting(val)
+ let renderText = color + secrets
+
+ let val2 = ChatLib.removeFormatting(renderText)
let renderX = (parseInt(x) + 16) / this.mapScale / 128 * size + this.offset[0] / 128 * size
let renderY = (parseInt(y) + 16) / this.mapScale / 128 * size + this.offset[1] / 128 * size
@@ -375,7 +383,7 @@ class DungeonMap extends Feature {
Renderer.translate(0, 0, 1000)
renderLibs.drawStringCentered("§0" + val2, x2 + renderX, y2 + renderY - scale * 1.25 - 2 * scale * 1.25, scale * 1.25)
Renderer.translate(0, 0, 1000)
- renderLibs.drawStringCentered("§f" + val, x2 + renderX, y2 + renderY - 2 * scale * 1.25, scale * 1.25)
+ renderLibs.drawStringCentered("§f" + renderText, x2 + renderX, y2 + renderY - 2 * scale * 1.25, scale * 1.25)
}
}
}
@@ -881,11 +889,15 @@ class DungeonMap extends Feature {
}
}
if (isGreen) {
- let total = ent[1].split(" ")[1]
- this.roomDataStuff.set(loc, total + " " + total)
+ let total = ent[1][0].split(" ")[1]
+ let data = this.roomDataStuff.get(loc)
+ data[0] = total + " " + total
+ this.roomDataStuff.set(loc, data)
}
- this.roomDataStuffRender.set(loc, color + this.roomDataStuff.get(loc))
+ let setData = [...this.roomDataStuff.get(loc)]
+ setData.push(color)
+ this.roomDataStuffRender.set(loc, setData)
}
}
// if (!this.renderImage) return
diff --git a/features/dungeonMap2/DungeonMapData.js b/features/dungeonMap2/DungeonMapData.js
new file mode 100644
index 0000000..15ffcca
--- /dev/null
+++ b/features/dungeonMap2/DungeonMapData.js
@@ -0,0 +1,80 @@
+import { m } from "../../../mappings/mappings"
+import DungeonMapRoom from "./DungeonMapRoom"
+
+const BufferedImage = Java.type("java.awt.image.BufferedImage")
+
+class DungeonMapData {
+ constructor(floor) {
+ this.floor = floor
+
+ this.greenRoom = undefined
+ /**
+ * @type {Map<String,DungeonMapRoom>}
+ */
+ this.rooms = new Map()
+
+ this.image = undefined
+ }
+
+ setRoom(x, y, rotation, id) {
+ let locstr = x + "," + y
+
+ if (this.rooms.get(locstr) && this.rooms.get(locstr).roomId !== id) {
+ this.rooms.get(locstr).setId(id)
+ this.mapChanged()
+ return
+ }
+
+ let room = DungeonMapRoom.fromId(id, x, y, rotation)
+
+ if (room.type === DungeonMapRoom.TYPE_SPAWN) {
+ this.greenRoom = locstr
+ }
+ console.log(room.type)
+
+ this.rooms.set(locstr, room)
+
+ this.mapChanged()
+ }
+
+ mapChanged() {
+ if (this.image) {
+ this.image.getTexture()[m.deleteGlTexture]()
+ this.image = undefined
+ }
+ }
+
+ /**
+ * @returns {Image}
+ */
+ getImage() {
+ if (!this.image) {
+ this.image = new Image(this.render())
+ }
+ return this.image
+ }
+
+ /**
+ * @returns {BufferedImage}
+ */
+ render() {
+ //create 256x256 image
+ let image = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB)
+
+ //if green room data not found yet then map should be empty
+ if (!this.greenRoom) return image
+
+ //create graphics rendering context
+ let graphics = image.createGraphics()
+
+ //render rooms
+ for (let data of this.rooms.entries()) {
+ let room = data[1]
+ room.draw(graphics, 256, 256)
+ }
+
+ return image
+ }
+}
+
+export default DungeonMapData \ No newline at end of file
diff --git a/features/dungeonMap2/DungeonMapRoom.js b/features/dungeonMap2/DungeonMapRoom.js
new file mode 100644
index 0000000..10f26e2
--- /dev/null
+++ b/features/dungeonMap2/DungeonMapRoom.js
@@ -0,0 +1,134 @@
+import DungeonRoomStaticData from "./DungeonRoomStaticData"
+
+const Color = Java.type("java.awt.Color")
+
+class DungeonMapRoom {
+
+ static TYPE_SPAWN = 0
+ static TYPE_NORMAL = 1
+ static TYPE_PUZZLE = 2
+ static TYPE_MINIBOSS = 3
+ static TYPE_FAIRY = 4
+ static TYPE_BLOOD = 5
+ static TYPE_UNKNOWN = 6
+
+ static SHAPE_1X1 = 0
+ static SHAPE_1X2 = 1
+ static SHAPE_1X3 = 2
+ static SHAPE_1X4 = 3
+ static SHAPE_2X2 = 4
+ static SHAPE_L = 5
+
+ static fromId(roomId, x, y, rotation) {
+ let data = DungeonRoomStaticData.getDataFromId(roomId)
+ let type = DungeonMapRoom.TYPE_NORMAL
+ switch (data.type) {
+ case "mobs":
+ type = DungeonMapRoom.TYPE_NORMAL
+ break
+ case "miniboss":
+ type = DungeonMapRoom.TYPE_NORMAL
+ break
+ case "spawn":
+ type = DungeonMapRoom.TYPE_SPAWN
+ break
+ case "puzzle":
+ type = DungeonMapRoom.TYPE_PUZZLE
+ break
+ case "gold":
+ type = DungeonMapRoom.TYPE_MINIBOSS
+ break
+ case "fairy":
+ type = DungeonMapRoom.TYPE_FAIRY
+ break
+ case "blood":
+ type = DungeonMapRoom.TYPE_BLOOD
+ break
+ }
+
+ let shape = DungeonMapRoom.SHAPE_1X1
+ switch (data.shape) {
+ case "1x1":
+ shape = DungeonMapRoom.SHAPE_1X1
+ break
+ case "1x2":
+ shape = DungeonMapRoom.SHAPE_1X2
+ break
+ case "1x3":
+ shape = DungeonMapRoom.SHAPE_1X3
+ break
+ case "1x4":
+ shape = DungeonMapRoom.SHAPE_1X4
+ break
+ case "2x2":
+ shape = DungeonMapRoom.SHAPE_2X2
+ break
+ case "L":
+ shape = DungeonMapRoom.SHAPE_L
+ break
+ }
+ return new DungeonMapRoom(type, shape, rotation, x, y, roomId)
+ }
+
+ /**
+ *
+ * @param {Number} type
+ * @param {Number} shape
+ * @param {Number} rotation 0-3
+ * @param {Number} x
+ * @param {Number} y
+ * @param {String} roomId
+ */
+ constructor(type, shape, rotation, x, y, roomId) {
+ this.type = type
+ this.shape = shape
+ this.rotation = rotation
+ this.roomId = roomId
+
+ this.location = [x, y]
+ }
+
+ setId(id) {
+ this.roomId = id
+ }
+
+ /**
+ * Renders this room onto the given Graphics2D
+ * @param {Graphics2D} graphics
+ */
+ draw(graphics, xOff, yOff) {
+
+ graphics.setColor(this.getRoomRenderColor())
+
+ switch (this.shape) {
+ case DungeonMapRoom.SHAPE_1X1:
+ graphics.fillRect(this.location[0] + xOff + 3, this.location[1] + yOff + 3, 26, 26)
+ break;
+ case DungeonMapRoom.SHAPE_1X2:
+ graphics.fillRect(this.location[0] + xOff + 3, this.location[1] + yOff + 3, 26 + 32, 26)
+ break;
+ case DungeonMapRoom.SHAPE_1X3:
+ graphics.fillRect(this.location[0] + xOff + 3, this.location[1] + yOff + 3, 26 + 64, 26)
+ break;
+ case DungeonMapRoom.SHAPE_1X4:
+ graphics.fillRect(this.location[0] + xOff + 3, this.location[1] + yOff + 3, 26 + 96, 26)
+ break;
+ }
+
+ }
+
+ getRoomRenderColor() {
+ return roomColorMap.get(this.type)
+ }
+}
+
+let roomColorMap = new Map()
+roomColorMap.set(DungeonMapRoom.TYPE_SPAWN, new Color(Renderer.color(0, 124, 0, 255)))
+roomColorMap.set(DungeonMapRoom.TYPE_NORMAL, new Color(Renderer.color(114, 67, 27, 255)))
+roomColorMap.set(DungeonMapRoom.TYPE_PUZZLE, new Color(Renderer.color(178, 76, 216, 255)))
+roomColorMap.set(DungeonMapRoom.TYPE_MINIBOSS, new Color(Renderer.color(229, 229, 51, 255)))
+roomColorMap.set(DungeonMapRoom.TYPE_FAIRY, new Color(Renderer.color(242, 127, 165, 255)))
+roomColorMap.set(DungeonMapRoom.TYPE_BLOOD, new Color(Renderer.color(255, 0, 0, 255)))
+roomColorMap.set(DungeonMapRoom.TYPE_UNKNOWN, new Color(Renderer.color(65, 65, 65, 255)))
+
+export default DungeonMapRoom \ No newline at end of file
diff --git a/features/dungeonMap2/DungeonRoomStaticData.js b/features/dungeonMap2/DungeonRoomStaticData.js
new file mode 100644
index 0000000..75d5b1e
--- /dev/null
+++ b/features/dungeonMap2/DungeonRoomStaticData.js
@@ -0,0 +1,19 @@
+class DungeonRoomStaticData {
+ constructor() {
+ this.fullRoomData = JSON.parse(FileLib.read("SoopyV2", "data/roomdata.json"))
+
+ this.idMap = new Map()
+ this.fullRoomData.forEach((d, i) => {
+ d.id.forEach(id => {
+ this.idMap.set(id, i)
+ })
+ this.idMap.set(d.index, i)
+ })
+ }
+
+ getDataFromId(id) {
+ return this.fullRoomData[this.idMap.get(id)]
+ }
+}
+
+export default new DungeonRoomStaticData() \ No newline at end of file
diff --git a/features/dungeonMap2/index.js b/features/dungeonMap2/index.js
new file mode 100644
index 0000000..c807e85
--- /dev/null
+++ b/features/dungeonMap2/index.js
@@ -0,0 +1,199 @@
+/// <reference types="../../../CTAutocomplete" />
+/// <reference lib="es2015" />
+
+import Feature from "../../featureClass/class";
+import renderLibs from "../../../guimanager/renderLibs";
+import DungeonMapData from "./DungeonMapData";
+import DungeonRoomStaticData from "./DungeonRoomStaticData";
+
+const AlphaComposite = Java.type("java.awt.AlphaComposite")
+
+class DungeonMap extends Feature {
+ constructor() {
+ super()
+ }
+
+ onEnable() {
+ if (Player.getUUID().toString() !== "dc8c3964-7b29-4e03-ae9e-d13ebd65dd29") {
+ new SettingBase("Coming soontm", "maby", undefined, "coming_soontm", this)
+ return
+ }
+
+ this.lastRoomId = undefined
+
+ /**@type {DungeonMapData} */
+ this.currentDungeon = undefined
+
+ this.registerStep(true, 5, this.update)
+
+ this.registerEvent("renderOverlay", this.renderOverlay)
+ }
+
+ update() {
+ if (!this.isInDungeon()) {
+ this.lastRoomId = undefined
+ this.currentDungeon = undefined
+ return
+ }
+
+ if (!this.currentDungeon) {
+ this.currentDungeon = new DungeonMapData(this.FeatureManager.features["dataLoader"].class.dungeonFloor)
+ }
+
+ let roomid = this.getCurrentRoomId()
+ if (!roomid.includes(",")) return
+
+ if (roomid !== this.lastRoomId) {
+ this.lastRoomId = roomid
+
+ let roomWorldData = this.getRoomWorldData()
+ this.currentDungeon.setRoom(roomWorldData.x, roomWorldData.y, roomWorldData.rotation, roomid)
+ }
+ }
+
+ renderOverlay() {
+ if (this.currentDungeon) {
+ let x = 10
+ let y = 10
+ let size = 100
+ this.currentDungeon.getImage().draw(x, y, size, size)
+
+ Renderer.drawRect(Renderer.color(0, 0, 0), x, y, size, 2)
+ Renderer.drawRect(Renderer.color(0, 0, 0), x, y, 2, size)
+ Renderer.drawRect(Renderer.color(0, 0, 0), x + size - 2, y, 2, size)
+ Renderer.drawRect(Renderer.color(0, 0, 0), x, y + size - 2, size, 2)
+ }
+ }
+
+ getCurrentRoomId() {
+ if (Scoreboard.getLines().length === 0) return undefined
+ let id = Scoreboard.getLineByIndex(Scoreboard.getLines().length - 1).getName().trim().split(" ").pop()
+
+ return id
+ }
+
+ isInDungeon() {
+ if (!this.FeatureManager || !this.FeatureManager.features["dataLoader"]) return false
+ return this.FeatureManager.features["dataLoader"].class.isInDungeon
+ }
+
+ getRoomXYWorld() {
+ let roomData = this.getRoomWorldData()
+ if (roomData.rotation === 4) {
+ return [roomData.x, roomData.y + 32]
+ }
+
+ return [roomData.x, roomData.y]
+ }
+
+ getCurrentRoomData() {
+ return DungeonRoomStaticData.getDataFromId(this.getCurrentRoomId())
+ }
+
+ getRotation(x, y, width, height, roofY) {
+ let currRoomData = this.getCurrentRoomData()
+ if (!currRoomData) return -1
+
+ if (currRoomData.shape !== "L") {
+ if (this.getTopBlockAt(x, y, roofY) === 11) return 0
+ if (this.getTopBlockAt(x + width, y, roofY) === 11) return 1
+ if (this.getTopBlockAt(x + width, y + height, roofY) === 11) return 2
+ if (this.getTopBlockAt(x, y + height, roofY) === 11) return 3
+ } else {
+ let one = this.getTopBlockAt2(x + width / 2 + 1, y + height / 2, roofY)
+ let two = this.getTopBlockAt2(x + width / 2 - 1, y + height / 2, roofY)
+ let three = this.getTopBlockAt2(x + width / 2, y + height / 2 + 1, roofY)
+ let four = this.getTopBlockAt2(x + width / 2, y + height / 2 - 1, roofY)
+
+ if (one === 0 && three === 0) return 0
+ if (two === 0 && three === 0) return 1
+ if (one === 0 && four === 0) return 2
+ if (two === 0 && four === 0) return 3//3 IS SO TOXIK HGOLY HEL I HATE L SHAPE ROOMS WHY DO THIS TO ME
+ }
+
+ return -1
+ }
+
+ getRoomWorldData() {
+ let x = Math.floor((Player.getX() + 8) / 32) * 32 - 8
+ let y = Math.floor((Player.getZ() + 8) / 32) * 32 - 8
+ let width = 30
+ let height = 30
+
+ let roofY = this.getRoofAt(x, y)
+
+ while (World.getBlockStateAt(new BlockPos(x - 1, roofY, y)).getBlockId() !== 0) {
+ x -= 32
+ width += 32
+ }
+ while (World.getBlockStateAt(new BlockPos(x, roofY, y - 1)).getBlockId() !== 0) {
+ y -= 32
+ height += 32
+ }
+ while (World.getBlockStateAt(new BlockPos(x - 1, roofY, y)).getBlockId() !== 0) { //second iteration incase of L shape
+ x -= 32
+ width += 32
+ }
+ while (World.getBlockStateAt(new BlockPos(x + width + 1, roofY, y)).getBlockId() !== 0) {
+ width += 32
+ }
+ while (World.getBlockStateAt(new BlockPos(x, roofY, y + height + 1)).getBlockId() !== 0) {
+ height += 32
+ }
+ while (World.getBlockStateAt(new BlockPos(x + width, roofY, y + height + 1)).getBlockId() !== 0) { //second iteration incase of L shape
+ height += 32
+ }
+ while (World.getBlockStateAt(new BlockPos(x + width + 1, roofY, y + height)).getBlockId() !== 0) { //second iteration incase of L shape
+ width += 32
+ }
+ while (World.getBlockStateAt(new BlockPos(x + width, roofY, y - 1)).getBlockId() !== 0) {//second iteration incase of L shape
+ y -= 32
+ height += 32
+ }
+ while (World.getBlockStateAt(new BlockPos(x - 1, roofY, y + height)).getBlockId() !== 0) { //third iteration incase of L shape
+ x -= 32
+ width += 32
+ }
+
+
+ return {
+ x,
+ y,
+ width,
+ height,
+ cx: x + width / 2,
+ cy: y + height / 2,
+ rotation: this.getRotation(x, y, width, height, roofY)
+ }
+ }
+
+ getRoofAt(x, z) {
+ let y = 255
+ while (y > 0 && World.getBlockStateAt(new BlockPos(x, y, z)).getBlockId() === 0) y--
+
+ return y
+ }
+
+ getTopBlockAt(x, z, y) {
+ if (!y) y = this.getHeightAt(x, z)
+
+ return World.getBlockStateAt(new BlockPos(x, y, z)).getMetadata()
+ }
+ getTopBlockAt2(x, z, y) {
+ if (!y) y = this.getHeightAt(x, z)
+
+ return World.getBlockStateAt(new BlockPos(x, y, z)).getBlockId()
+ }
+ getImageForPlayer(uuid) {
+ let img = renderLibs.getImage("https://crafatar.com/avatars/" + uuid.replace(/-/g, "") + "?size=8&overlay")
+ if (!img) return this.defaultPlayerImage
+
+ return img
+ }
+ onDisable() {
+ }
+}
+
+module.exports = {
+ class: new DungeonMap()
+} \ No newline at end of file
diff --git a/features/dungeonMap2/metadata.json b/features/dungeonMap2/metadata.json
new file mode 100644
index 0000000..a32de89
--- /dev/null
+++ b/features/dungeonMap2/metadata.json
@@ -0,0 +1,8 @@
+{
+ "name": "Dungeon Map 2",
+ "description": "WIP",
+ "isHidden": false,
+ "isTogglable": true,
+ "defaultEnabled": false,
+ "sortA": 1
+} \ No newline at end of file
diff --git a/features/dungeonRoutes/index.js b/features/dungeonRoutes/index.js
index 3eb50c3..e84bd2b 100644
--- a/features/dungeonRoutes/index.js
+++ b/features/dungeonRoutes/index.js
@@ -112,7 +112,7 @@ class DungeonRoutes extends Feature {
this.idMap = new Map()
this.routesIndexMap = new Map()
- this.fullRoomData = JSON.parse(FileLib.read("SoopyV2", "features/dungeonRoutes/temproomdata.json"))
+ this.fullRoomData = JSON.parse(FileLib.read("SoopyV2", "data/roomdata.json"))
this.fullRoutesData = JSON.parse(FileLib.read("SoopyV2", "features/dungeonRoutes/routesData.json"))
this.fullRoomData.forEach((d, i) => {
d.id.forEach(id => {
diff --git a/features/waypoints/index.js b/features/waypoints/index.js
index 17cd831..0760354 100644
--- a/features/waypoints/index.js
+++ b/features/waypoints/index.js
@@ -4,6 +4,7 @@ import { m } from "../../../mappings/mappings";
import Feature from "../../featureClass/class";
import { Waypoint } from "../../utils/renderJavaUtils";
import { drawCoolWaypoint } from "../../utils/renderUtils";
+import { calculateDistanceQuick } from "../../utils/utils";
import SettingBase from "../settings/settingThings/settingBase";
import ToggleSetting from "../settings/settingThings/toggle";
import minewaypoints_socket from "./minewaypoints_socket";
@@ -44,12 +45,6 @@ class Waypoints extends Feature {
this.userWaypointsArr = Object.values(this.userWaypoints)
this.updateWaypointsHashes()
this.waypointsChanged = false
- this.lastTp = 0
- this.registerEvent("messageSent", (m) => {
- if (m.toLowerCase().startsWith("/warp")) {
- this.lastTp = Date.now()
- }
- })
this.patcherWaypoints = []
@@ -165,7 +160,8 @@ class Waypoints extends Feature {
minewaypoints_socket.setLocationHandler = (area, loc) => {
this.locations[area || loc[0].area] = loc;
}
-
+ let lastLoc = [0, 0, 0]
+ let lastTp = 0
this.registerEvent("tick", () => {
try {
if (Scoreboard.getLines().length < 2) return;
@@ -179,6 +175,11 @@ class Waypoints extends Feature {
minewaypoints_socket.setServer(server, World.getWorld().func_82737_E())
+ let loc = [Player.getX(), Player.getY(), Player.getZ()]
+ if (calculateDistanceQuick(lastLoc, loc) > 25) {
+ this.lastTp = Date.now()
+ }
+
if (Date.now() - this.lastSend > 1000 && Date.now() - this.lastTp > 5000) {
Scoreboard.getLines().forEach(line => {
line = ChatLib.removeFormatting(line.getName()).replace(/[^0-9A-z]/g, "")