Skip to content

Commit

Permalink
Release v5.2.4
Browse files Browse the repository at this point in the history
- Fixed map going fuckie wuckie when it finishes scanning
- Visited rooms sorts time spent in room descending
  • Loading branch information
UnclaimedBloom6 committed Jan 10, 2023
1 parent 9b8a776 commit fa70766
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 42 deletions.
57 changes: 29 additions & 28 deletions IllegalMap/Components/DmapDungeon.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ export default new class DmapDungeon {

register("command", () => {
this.rooms.forEach(a => ChatLib.chat(`${a.name} - ${JSON.stringify(a.components)}`))
ChatLib.chat(`To Scan: ${this.toScan.size} - ${JSON.stringify([...this.toScan])}`)
ChatLib.chat(`Confirmed Rotation: ${this.rooms.map(a => a.confirmedRotation).length}/${this.rooms.length}`)
}).setName("/r")

register("command", () => {
Expand Down Expand Up @@ -199,7 +201,9 @@ export default new class DmapDungeon {
// Room
if (!(gx%2) && !(gz%2)) {
this.toScan.delete(v)
if (this.getRoomWithComponent([rx, rz])) return
// ChatLib.chat(`Scanned ${v}`)
let existing = this.getRoomWithComponent([rx, rz])
if (existing && existing.roofLevel) return
let room = new Room([[rx, rz]], roofHeight)
let existingRoom = this.getRoomWithComponent([rx, rz])
if (existingRoom) {
Expand Down Expand Up @@ -268,8 +272,8 @@ export default new class DmapDungeon {
this.fullyScanned = true
this.scanFromEntrance()

let trap = this.rooms.find(a => a.type == "trap")
if (trap) this.trapType = trap.name.split(" ")[0]
// let trap = this.rooms.find(a => a.type == "trap")
// if (trap) this.trapType = trap.name.split(" ")[0]
}

this.secrets = this.rooms.reduce((a, b) => a + b.secrets, 0)
Expand Down Expand Up @@ -373,6 +377,7 @@ export default new class DmapDungeon {
yy++
if (wasVisited(xx, yy)) continue
let i = x + y*128
if (i%1) break
if (colors[i] == 0) continue

let center = colors[i-1] // Pixel where the checkmarks spawn
Expand Down Expand Up @@ -428,7 +433,9 @@ export default new class DmapDungeon {
* @returns {Room|null}
*/
getRoomWithComponent([x, z]) {
return this.rooms.find(a => a && a.components.some(b => b[0] == x && b[1] == z)) ?? null
let ind = this.rooms.findIndex(a => a && a.components.some(b => b[0] == x && b[1] == z))
if (ind == -1) return null
return this.rooms[ind]
}
/**
* Gets the room at a set of real world coordinates. Iif there is no room at those coordinates, then return null.
Expand Down Expand Up @@ -460,41 +467,35 @@ export default new class DmapDungeon {
* @returns
*/
scanFromEntrance() {
let entrance = this.rooms.find(a => a.type == "entrance")
let entrance = this.rooms.findIndex(a => a.type == "entrance")
if (!entrance) return
entrance.parent = null
let queue = [entrance]
let queue = [this.rooms[entrance]]
let visited = []
let rooms = []
// let rooms = []
const directions = [[1,0],[-1,0],[0,1],[0,-1]]
while (queue.length) {
let currentRoom = queue.pop()
if (visited.some(a => a.name == currentRoom.name)) continue
visited.push(currentRoom)
rooms.push(currentRoom)
currentRoom.realComponents.forEach(c => {
let [x, z] = c
// Branch out in all four directions looking for doors
;[
[16, 0],
[-16, 0],
[0, 16],
[0, -16]
].forEach(a => {
let [dx, dz] = a
if (!World.getBlockAt(x+dx, 68, z+dz).type.getID()) return // Not a door or room
let room = this.getRoomAt([x+dx*2, z+dz*2])
if (!room || room == currentRoom) return
if (visited.some(a => a.name == room.name)) return currentRoom.parent = room

currentRoom.components.forEach(c => {
let [cx, cz] = c
let [doubledX, doubledZ] = c.map(a => a*2)
directions.forEach(([dx, dz]) => {
if (currentRoom.hasComponent([cx+dx, cz+dz])) return
let [nx, nz] = [doubledX+dx, doubledZ+dz]
let door = this.doors.find(a => a.gX == nx && a.gZ == nz)
if (!door) return
let room = this.getRoomWithComponent([cx+dx, cz+dz])
if (!room) return
if (visited.some(a => a.name == room.name) || room == currentRoom) return
room.parent = currentRoom
queue.push(room)
})

})
}
// rooms.forEach(r => {
// let parent = r.parent ? r.parent.name : null
// ChatLib.chat(`${r.name}: ${parent}`)
// })
this.rooms = rooms
// this.rooms.forEach(r => ChatLib.chat(`${r?.name} - ${r.parent?.name}`))
}
/**
* Returns an array of room objects of the rooms from room1 to room2. If room1 or room2 does not exist, returns null.
Expand Down
2 changes: 1 addition & 1 deletion IllegalMap/Components/Door.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ export class Door {
this.type = type
}
toString() {
return `Door[x=${this.x}, z=${this.z}, type=${this.type}, explored=${this.explored}]`
return `Door[xz=${this.x},${this.z}, gXgZ=${this.gX},${this.gZ} type=${this.type}, explored=${this.explored}]`
}
}
16 changes: 9 additions & 7 deletions IllegalMap/Components/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,16 @@ export class Room {
* @param {Room} room
*/
mergeRoom(room) {
if ([this.name, room.name].includes("Entrance")) return
room.components.forEach(([x, z]) => {
if (this.hasComponent([x, z])) return
this.addComponent([x, z])
})
if (!this.name && room.name) this.setRoomFromName(room.name)

if (!this.confirmedRotation && room.confirmedRotation) {
this.rotation = room.rotation
this.confirmedRotation = true
}
this.update()
}
hasComponent([x, z]) {
Expand All @@ -144,23 +148,21 @@ export class Room {
// Uses the blue stained clay on the roof to find the rotation of the room. Works reliably.
if (!World.getWorld()) return

if (!this.roofLevel) return
if (!this.roofLevel || this.confirmedRotation) return

for (let c of this.realComponents) {
let [x, z] = c
if (!chunkLoaded([x, 0, z])) continue
let offset = Math.floor(roomSize/2)
;[[x-offset, this.roofLevel, z-offset],
[x-offset, this.roofLevel, z+offset],
[x+offset, this.roofLevel, z+offset],
[x+offset, this.roofLevel, z-offset]].forEach((v, i) => {
let checkCoords = [[x-offset, this.roofLevel, z-offset],[x-offset, this.roofLevel, z+offset],[x+offset, this.roofLevel, z+offset],[x+offset, this.roofLevel, z-offset]]
checkCoords.forEach((v, i) => {
let block = World.getBlockAt(...v)
if (!block || !block.type) return
// Must be blue stained terracotta
if (block.type.getID() !== 159 || block.getMetadata() !== 11) return
this.rotation = i * 90
this.corner = [...v]
if (fullyScanned) this.confirmedRotation = true
this.confirmedRotation = true
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion IllegalMap/extra/PlayerTrackerCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const roomsCommand = register("command", (player) => {

const printRooms = (p) => {
let hover = `&a${p.getName(true)}&e's Visited Rooms &6(${Object.keys(p.visitedRooms).length})`
let sorted = sortObjectByValues(p.visitedRooms)
let sorted = sortObjectByValues(p.visitedRooms, true)
hover += Object.keys(sorted).map(a => `\n&a${getColoredName(a)} &e- &b${toSeconds(sorted[a])}s`).join("")
new Message(new TextComponent(`&b${p.getName(true)}&a's Visited Rooms &7(Hover)`).setHover("show_text", hover)).chat()
}
Expand Down
2 changes: 1 addition & 1 deletion IllegalMap/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "IllegalMap",
"description": "Ur mom! !!",
"entry": "index.js",
"version": "5.2.3",
"version": "5.2.4",
"creator": "UnclaimedBloom6",
"requires": [
"BloomCore",
Expand Down
5 changes: 3 additions & 2 deletions IllegalMapAPI.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"moduleName": "IllegalMap",
"latestVersion": "5.2.3",
"latestVersion": "5.2.4",
"author": "UnclaimedBloom6",
"changelog": [
"Fixed breaking change from BloomCore update."
"Fixed map going fuckie wuckie when it finishes scanning",
"Visited rooms sorts time spent in room descending"
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# IllegalMap

##### Current Version: 5.2.3 for ChatTriggers 2.1.5 or higher
Last Updated: December 8
##### Current Version: 5.2.4 for ChatTriggers 2.1.5 or higher
Last Updated: January 10

If you find a bug or want to make a suggestion, then join my Discord server: https://discord.gg/pykzREcAuZ
**I will not consider adding features that are too cheaty, pointless or are just unrelated to this module.**
Expand Down

0 comments on commit fa70766

Please sign in to comment.