diff options
| -rw-r--r-- | features/dungeonRoutes/index.js | 268 | ||||
| -rw-r--r-- | features/dungeonRoutes/routesData.json | 6200 | ||||
| -rw-r--r-- | features/dungeonRoutes/temproomdata.json | 387 | ||||
| -rw-r--r-- | features/soopyGui/index.js | 2 | ||||
| -rw-r--r-- | features/waypoints/index.js | 8 | ||||
| -rw-r--r-- | utils/renderUtils.js | 44 |
6 files changed, 6754 insertions, 155 deletions
diff --git a/features/dungeonRoutes/index.js b/features/dungeonRoutes/index.js index 6439f49..1c49dab 100644 --- a/features/dungeonRoutes/index.js +++ b/features/dungeonRoutes/index.js @@ -1,9 +1,12 @@ /// <reference types="../../../CTAutocomplete" /> /// <reference lib="es2015" /> +import { m } from "../../../mappings/mappings"; import Feature from "../../featureClass/class"; -import { drawBoxAtBlock, drawFilledBox, drawLinePoints } from "../../utils/renderUtils"; +import { drawBoxAtBlock, drawBoxAtBlock2, drawFilledBox, drawLine, drawLinePoints } from "../../utils/renderUtils"; import SettingBase from "../settings/settingThings/settingBase"; +const EntityItem = Java.type("net.minecraft.entity.item.EntityItem") + class DungeonRoutes extends Feature { constructor() { @@ -21,11 +24,19 @@ class DungeonRoutes extends Feature { this.recentEtherwarps = [] this.recentMines = [] this.recentLocations = [] + this.recentInteracts = [] this.recentTnts = [] this.lastLocationUpdatedTime = Date.now() this.registerEvent("soundPlay", this.playSound) this.registerEvent("worldLoad", this.worldLoad) + this.registerEvent("playerInteract", this.playerInteract) + this.registerForge(net.minecraftforge.event.entity.EntityJoinWorldEvent, this.entityJoinWorldEvent) + let packetRecieved = this.registerCustom("packetReceived", this.pickupItem) + + try { + packetRecieved.trigger.setPacketClasses([net.minecraft.network.play.server.S0DPacketCollectItem]) + } catch (e) { }//older ct version this.registerStep(true, 5, () => { let roomId = this.getCurrentRoomId() @@ -36,16 +47,21 @@ class DungeonRoutes extends Feature { this.recentMines = [] this.recentLocations = [] this.recentTnts = [] + this.recentInteracts = [] + + this.currRoomData = this.getRoomWorldData() + + this.currentRouteDisplay = this.routesIndexMap.get(this.fullRoomData[this.idMap.get(roomId)].index) + ChatLib.chat(JSON.stringify(this.currentRouteDisplay, undefined, 2)) } + if (!this.recordRoute) return if (this.recentLocations.length === 0 || Math.ceil(Player.getX()) !== this.recentLocations[this.recentLocations.length - 1].loc[0] || Math.ceil(Player.getY()) !== this.recentLocations[this.recentLocations.length - 1].loc[1] || Math.ceil(Player.getZ()) !== this.recentLocations[this.recentLocations.length - 1].loc[2]) { this.recentLocations.push({ loc: [Math.ceil(Player.getX()), Math.ceil(Player.getY()), Math.ceil(Player.getZ())], id: this.actionId++ }) - - this.checkForRemove() } }) @@ -57,22 +73,208 @@ class DungeonRoutes extends Feature { this.recentMines.forEach(({ loc }) => { drawFilledBox(loc.x, loc.y - 0.5, loc.z, 1, 1, 0, 1, 0, 50 / 255, true) }) - if (this.recentLocations.length >= 2) drawLinePoints(this.recentLocations.map(a => [a.loc[0] - 0.5, a.loc[1] + 0.1, a.loc[2] - 0.5]), 0, 0, 255, 2, true) + this.recentTnts.forEach(({ loc }) => { + drawFilledBox(loc.x, loc.y - 0.5, loc.z, 1, 1, 1, 0, 0, 50 / 255, true) + }) + this.recentInteracts.forEach(({ loc }) => { + drawFilledBox(loc.x, loc.y, loc.z, 1, 1, 0, 0, 1, 50 / 255, true) + drawBoxAtBlock(loc.x - 0.5, loc.y, loc.z - 0.5, 0, 0, 1, 1, 1, 1) + }) + if (this.recentLocations.length >= 2) drawLinePoints(this.recentLocations.map(a => [a.loc[0] - 0.5, a.loc[1] + 0.1, a.loc[2] - 0.5]), 0, 0, 255, 2, false) + + if (this.currRoomData) { + if (this.currentRouteDisplay) { + this.currentRouteDisplay.etherwarps.forEach(loc => { + let coords = this.toRoomCoordinates(loc[0], loc[1] - 1, loc[2]) + drawFilledBox(coords[0] + 0.5, coords[1], coords[2] + 0.5, 1, 1, 1, 0, 0, 50 / 255, true) + drawBoxAtBlock(coords[0], coords[1], coords[2], 1, 0, 0, 1, 1, 1) + }) + this.currentRouteDisplay.mines.forEach(loc => { + let coords = this.toRoomCoordinates(loc[0], loc[1] - 1, loc[2]) + drawFilledBox(coords[0] + 0.5, coords[1] + 0.5, coords[2] + 0.5, 1, 1, 0, 255, 0, 50 / 255, true) + }) + this.currentRouteDisplay.tnts.forEach(loc => { + let coords = this.toRoomCoordinates(loc[0], loc[1] - 1, loc[2]) + drawFilledBox(coords[0] + 0.5, coords[1] + 0.5, coords[2] + 0.5, 1, 1, 255, 0, 0, 50 / 255, true) + }) + this.currentRouteDisplay.interacts.forEach(loc => { + let coords = this.toRoomCoordinates(loc[0], loc[1], loc[2]) + drawFilledBox(coords[0] + 0.5, coords[1], coords[2] + 0.5, 1, 1, 0, 0, 1, 50 / 255, true) + drawBoxAtBlock(coords[0], coords[1], coords[2], 0, 0, 1, 1, 1, 1) + }) + + if (this.currentRouteDisplay.locations.length >= 2) drawLinePoints(this.currentRouteDisplay.locations.map(a => this.toRoomCoordinates(...a)).map(a => [a[0] - 0.5, a[1] + 0.1, a[2] - 0.5]), 0, 0, 255, 2, false) + + } + } + }) + this.tempItemIdLocs = new Map() + this.idMap = new Map() + this.routesIndexMap = new Map() this.fullRoomData = JSON.parse(FileLib.read("SoopyV2", "features/dungeonRoutes/temproomdata.json")) + this.fullRoutesData = JSON.parse(FileLib.read("SoopyV2", "features/dungeonRoutes/routesData.json")) this.fullRoomData.forEach((d, i) => { d.id.forEach(id => { this.idMap.set(id, i) }) + this.idMap.set(d.index, i) + }) + this.fullRoutesData.forEach((d, i) => { + this.routesIndexMap.set(d.index, d) }) - let roomData = {} this.lastRoomId = undefined + this.currRoomData = undefined + this.currentRouteDisplay = undefined + this.registerCommand("roomid", (...name) => { ChatLib.chat(JSON.stringify(this.getCurrentRoomData(), undefined, 2)) + ChatLib.chat(JSON.stringify(this.getRoomWorldData(), undefined, 2)) + }) + this.recordRoute = false + + this.registerCommand("startroute", (...name) => { + this.recordRoute = true + this.recentEtherwarps = [] + this.recentMines = [] + this.recentLocations = [] + this.recentInteracts = [] + this.recentTnts = [] + ChatLib.chat(this.FeatureManager.messagePrefix + "Started recording route!") }) + + this.registerCommand("saveroute", () => { + let data = { + index: this.fullRoomData[this.idMap.get(this.lastRoomId)].index, + etherwarps: this.recentEtherwarps.map(ether => this.fromRoomCoordinates(ether.loc.x - 0.5, ether.loc.y, ether.loc.z - 0.5)), + mines: this.recentMines.map(ether => this.fromRoomCoordinates(ether.loc.x - 0.5, ether.loc.y, ether.loc.z - 0.5)), + locations: this.recentLocations.map(ether => this.fromRoomCoordinates(ether.loc[0], ether.loc[1], ether.loc[2])), + interacts: this.recentInteracts.map(ether => this.fromRoomCoordinates(ether.loc.x - 0.5, ether.loc.y, ether.loc.z - 0.5)), + tnts: this.recentTnts.map(ether => this.fromRoomCoordinates(ether.loc.x - 0.5, ether.loc.y, ether.loc.z - 0.5)), + } + + ChatLib.chat(JSON.stringify(data, undefined, 4)) + ChatLib.chat(this.FeatureManager.messagePrefix + "Saved route!") + this.recordRoute = false + }) + } + + toRoomCoordinates(x, y, z) { //From relative coords to world coords + if (!this.currRoomData) return null + + if (this.currRoomData.rotation === 2) { + z *= -1; + [x, z] = [z, x] + } else if (this.currRoomData.rotation === 3) { + x *= -1 + z *= -1 + } else if (this.currRoomData.rotation === 4) { + x *= -1; + [x, z] = [z, x] + } + + return [this.currRoomData.cx + x, y, this.currRoomData.cy + z] + } + fromRoomCoordinates(x, y, z) { //from world coords to relative coords + if (!this.currRoomData) return null + + x -= this.currRoomData.cx + z -= this.currRoomData.cy + + if (this.currRoomData.rotation === 2) { + [x, z] = [z, x] + z *= -1 + } else if (this.currRoomData.rotation === 3) { + x *= -1 + z *= -1 + } else if (this.currRoomData.rotation === 4) { + [x, z] = [z, x] + x *= -1 + } + + return [x, y, z] + } + + 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 1 + if (this.getTopBlockAt(x + width, y, roofY) === 11) return 2 + if (this.getTopBlockAt(x + width, y + height, roofY) === 11) return 3 + if (this.getTopBlockAt(x, y + height, roofY) === 11) return 4 + } else { + let one = this.getTopBlockAt(x + width / 2 + 1, y + height / 2, roofY) + let two = this.getTopBlockAt(x + width / 2 - 1, y + height / 2, roofY) + let three = this.getTopBlockAt(x + width / 2, y + height / 2 + 1, roofY) + let four = this.getTopBlockAt(x + width / 2, y + height / 2 - 1, roofY) + + if (one === 0 && three === 0) return 1 + if (two === 0 && three === 0) return 2 + if (one === 0 && three === 0) return 3 + if (two === 0 && four === 0) return 4 + } + + 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 + } + + + 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() } getCurrentRoomData() { @@ -92,38 +294,55 @@ class DungeonRoutes extends Feature { this.recentEtherwarps = [] this.recentMines = [] this.recentLocations = [] + this.recentInteracts = [] this.recentTnts = [] } - checkForRemove() { - if (this.recentLocations.length + this.recentMines.length + this.recentEtherwarps.length + this.recentTnts.length > 50) { - let arrs = [this.recentLocations, this.recentMines, this.recentEtherwarps, this.recentTnts] - let smallestArr = undefined + entityJoinWorldEvent(event) { + if (event.entity instanceof EntityItem) { + // console.log("Blaze joined world") + let e = new Entity(event.entity) + let pos = { x: e.getX(), y: e.getY(), z: e.getZ() } - if (this.recentLocations[0].id < this.recentMines[0].id && this.recentLocations[0].id < this.recentEtherwarps[0].id) { - this.recentLocations.shift() - return - } - if (this.recentMines[0].id < this.recentLocations[0].id && this.recentMines[0].id < this.recentEtherwarps[0].id) { - this.recentMines.shift() - return - } - if (this.recentEtherwarps[0].id < this.recentMines[0].id && this.recentEtherwarps[0].id < this.recentLocations[0].id) { - this.recentEtherwarps.shift() - return - } + this.tempItemIdLocs.set(event.entity[m.getEntityId.Entity](), pos) + // console.log(event.entity[m.getEntityId.Entity]()) } } + pickupItem(packet) { + if (!this.recordRoute) return + let packetType = new String(packet.class.getSimpleName()).valueOf() + if (packetType === "S0DPacketCollectItem") { + let pos = this.tempItemIdLocs.get(packet[m.getCollectedItemEntityID]()) + + if (pos) this.recentInteracts.push({ loc: pos, id: this.actionId++ }) + } + } + + playerInteract(action, position, event) { + if (!this.recordRoute) return + if (action.toString() !== "RIGHT_CLICK_BLOCK") return + + let pos = { x: Player.lookingAt().getX() + 0.5, y: Player.lookingAt().getY(), z: Player.lookingAt().getZ() + 0.5 } + + let id = Player.lookingAt().getType().getID() + if (id !== 54 && id !== 144 && id !== 69) return + + this.recentInteracts.push({ loc: pos, id: this.actionId++ }) + } + playSound(pos, name, volume, pitch, categoryName, event) { + if (!this.recordRoute) return + let nameSplitted = name.split(".") if (name === "mob.enderdragon.hit") { //etherwarp this.recentEtherwarps.push({ loc: pos, id: this.actionId++ }) - this.checkForRemove() } - if (name === "random.explode") { //etherwarp + if (name === "random.explode" && pitch !== 1) { //tnt OR MIGHT BE spirit scepter this.recentTnts.push({ loc: pos, id: this.actionId++ }) - this.checkForRemove() + } + if (name === "mob.bat.death") { + this.recentInteracts.push({ loc: pos, id: this.actionId++ }) } if (nameSplitted[0] === "dig") { //mining block if (!this.recentMines.some(a => @@ -132,7 +351,6 @@ class DungeonRoutes extends Feature { && a.loc.z === pos.z )) { this.recentMines.push({ loc: pos, id: this.actionId++ }) - this.checkForRemove() } } } diff --git a/features/dungeonRoutes/routesData.json b/features/dungeonRoutes/routesData.json new file mode 100644 index 0000000..2a6db6c --- /dev/null +++ b/features/dungeonRoutes/routesData.json @@ -0,0 +1,6200 @@ +[ + { + "index": 0, + "etherwarps": [ + [ + -8, + 76, + 14 + ], + [ + -13, + 71, + 5 + ], + [ + 13, + 73, + 9 + ] + ] + }, + { + "index": 128, + "etherwarps": [ + [ + 2, + 72, + 3 + ], + [ + 0, + 91, + -10 + ], + [ + 8, + 72, + -9 + ] + ] + }, + { + "index": 127, + "etherwarps": [ + [ + 0, + 77, + -12 + ], + [ + 0, + 80, + 14 + ], + [ + -12, + 72, + 0 + ] + ] + }, + { + "index": 95, + "etherwarps": [], + "mines": [ + [ + -18, + 51.5, + 22 + ], + [ + -18, + 52.5, + 22 + ] + ], + "locations": [ + [ + -11, + 69, + 4 + ], + [ + -12, + 69, + 5 + ], + [ + -13, + 69, + 5 + ], + [ + -13, + 69, + 6 + ], + [ + -13, + 69, + 7 + ], + [ + -13, + 69, + 8 + ], + [ + -13, + 68, + 8 + ], + [ + -13, + 65, + 8 + ], + [ + -12, + 62, + 9 + ], + [ + -12, + 57, + 9 + ], + [ + -12, + 56, + 11 + ], + [ + -10, + 56, + 15 + ], + [ + -10, + 58, + 14 + ], + [ + -9, + 58, + 14 + ], + [ + -9, + 57, + 14 + ], + [ + -8, + 57, + 15 + ], + [ + -7, + 57, + 15 + ], + [ + -9, + 57, + 16 + ], + [ + -11, + 57, + 17 + ], + [ + -12, + 56, + 18 + ], + [ + -12, + 53, + 18 + ], + [ + -12, + 50, + 19 + ], + [ + -13, + 50, + 22 + ], + [ + -14, + 50, + 23 + ], + [ + -15, + 50, + 23 + ], + [ + -14, + 50, + 24 + ], + [ + -13, + 50, + 23 + ], + [ + -13, + 50, + 20 + ], + [ + -12, + 50, + 19 + ], + [ + -13, + 50, + 19 + ], + [ + -13, + 51, + 16 + ], + [ + -13, + 51, + 15 + ], + [ + -15, + 51, + 4 + ], + [ + -15, + 50, + 3 + ], + [ + -16, + 48, + -6 + ], + [ + -16, + 48, + -5 + ], + [ + -16, + 48, + -8 + ], + [ + -16, + 48, + -17 + ], + [ + -15, + 47, + -20 + ], + [ + -14, + 47, + -22 + ], + [ + -12, + 48, + -25 + ], + [ + -12, + 47, + -25 + ], + [ + -10, + 47, + -24 + ], + [ + -9, + 47, + -24 + ], + [ + -9, + 47, + -23 + ], + [ + -8, + 47, + -22 + ], + [ + -6, + 47, + -22 + ], + [ + -5, + 47, + -22 + ], + [ + -5, + 46, + -22 + ], + [ + -5, + 46, + -23 + ], + [ + -7, + 47, + -23 + ], + [ + -9, + 47, + -24 + ], + [ + -11, + 47, + -24 + ], + [ + -15, + 47, + -22 + ], + [ + -17, + 47, + -20 + ], + [ + -18, + 46, + -19 + ], + [ + -18, + 46, + -18 + ], + [ + -18, + 59, + -15 + ], + [ + -18, + 72, + -12 + ], + [ + -18, + 85, + -9 + ], + [ + -18, + 83, + -8 + ], + [ + -17, + 80, + -8 + ], + [ + -16, + 76, + -8 + ], + [ + -9, + 90, + -7 + ], + [ + -9, + 89, + -7 + ], + [ + -2, + 95, + -7 + ], + [ + -2, + 94, + -7 + ], + [ + -1, + 93, + -7 + ], + [ + -4, + 92, + -7 + ], + [ + -7, + 92, + -6 + ], + [ + -9, + 91, + -5 + ], + [ + -11, + 88, + -4 + ], + [ + -14, + 84, + 1 + ], + [ + -15, + 85, + 3 + ], + [ + -15, + 86, + 3 + ], + [ + -15, + 86, + 5 + ], + [ + -15, + 85, + 8 + ], + [ + -15, + 83, + 9 + ], + [ + -15, + 80, + 11 + ], + [ + -15, + 69, + 17 + ] + ], + "interacts": [ + [ + -20, + 52, + 23 + ], + [ + 2, + 92, + -7 + ] + ], + "tnts": [] + }, + { + "index": 75, + "etherwarps": [ + [ + -54, + 76, + 6 + ], + [ + -60, + 74, + -12 + ] + ], + "mines": [ + [ + -60, + 74.5, + -12 + ], + [ + -60, + 73.5, + -12 + ], + [ + -60, + 72.5, + -12 + ], + [ + -60, + 71.5, + -12 + ] + ], + "locations": [ + [ + -51, + 69, + -3 + ], + [ + -53, + 77, + 5 + ], + [ + -53, + 76, + 5 + ], + [ + -54, + 76, + 8 + ], + [ + -56, + 76, + 10 + ], + [ + -59, + 76, + 10 + ], + [ + -60, + 76, + 10 + ], + [ + -60, + 76, + 11 + ], + [ + -59, + 76, + 10 + ], + [ + -57, + 76, + 9 + ], + [ + -57, + 76, + 10 + ], + [ + -55, + 76, + 11 + ], + [ + -53, + 76, + 9 + ], + [ + -53, + 76, + 8 + ], + [ + -53, + 76, + 7 + ], + [ + -53, + 76, + 6 + ], + [ + -54, + 76, + 5 + ], + [ + -59, + 75, + -13 + ], + [ + -59, + 74, + -13 + ], + [ + -59, + 73, + -13 + ], + [ + -59, + 72, + -13 + ], + [ + -59, + 69, + -13 + ], + [ + -59, + 67, + -13 + ], + [ + -59, + 65, + -13 + ], + [ + -57, + 65, + -11 + ], + [ + -58, + 65, + -12 + ], + [ + -59, + 65, + -12 + ], + [ + -59, + 65, + -13 + ], + [ + -61, + 65, + -13 + ], + [ + -61, + 66, + -12 + ], + [ + -61, + 74, + -12 + ], + [ + -60, + 75, + -12 + ], + [ + -61, + 73, + -12 + ], + [ + -48, + 78, + -12 + ], + [ + -49, + 78, + -12 + ], + [ + -40, + 83, + -12 + ], + [ + -41, + 84, + -12 + ], + [ + -39, + 83, + -12 + ], + [ + -36, + 82, + -12 + ], + [ + -32, + 82, + -12 + ], + [ + -13, + 82, + -10 + ], + [ + -10, + 82, + -10 + ], + [ + -6, + 82, + -10 + ], + [ + -1, + 82, + -10 + ], + [ + 15, + 82, + -10 + ], + [ + 18, + 82, + -10 + ], + [ + 22, + 82, + -10 + ], + [ + 31, + 82, + -10 + ], + [ + 30, + 82, + -10 + ], + [ + 32, + 82, + -10 + ], + [ + 35, + 82, + -10 + ], + [ + 41, + 83, + -9 + ], + [ + 44, + 83, + -8 + ], + [ + 48, + 83, + -8 + ], + [ + 50, + 84, + -5 + ], + [ + 51, + 85, + -2 + ], + [ + 52, + 84, + 0 + ], + [ + 51, + 93, + 9 + ], + [ + 51, + 92, + 9 + ], + [ + 51, + 92, + 8 + ], + [ + 53, + 92, + 6 + ], + [ + 53, + 91, + 5 + ], + [ + 54, + 89, + 4 + ], + [ + 54, + 86, + 4 + ], + [ + 55, + 83, + 3 + |
