diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-05-15 13:47:44 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-05-15 13:47:44 +0800 |
commit | 62bb98cb9576f23c8cc2c06446b52ad4aa4a4884 (patch) | |
tree | 71b5ad63056fa05873594bbeb27656219bc34c8f /features | |
parent | 7112c1e3da740b20857c6d9eefd2803632f3d248 (diff) | |
download | SoopyV2-62bb98cb9576f23c8cc2c06446b52ad4aa4a4884.tar.gz SoopyV2-62bb98cb9576f23c8cc2c06446b52ad4aa4a4884.tar.bz2 SoopyV2-62bb98cb9576f23c8cc2c06446b52ad4aa4a4884.zip |
fix dungeon map
Diffstat (limited to 'features')
-rw-r--r-- | features/betterGuis/index.js | 79 | ||||
-rw-r--r-- | features/dataLoader/index.js | 5 | ||||
-rw-r--r-- | features/dungeonMap/index.js | 7 |
3 files changed, 85 insertions, 6 deletions
diff --git a/features/betterGuis/index.js b/features/betterGuis/index.js index f2af866..cb0b5a0 100644 --- a/features/betterGuis/index.js +++ b/features/betterGuis/index.js @@ -6,6 +6,8 @@ import { f } from "../../../mappings/mappings"; import ToggleSetting from "../settings/settingThings/toggle"; import MuseumGui from "./museumGui.js"; import DungeonReadyGui from "./dungeonReadyGui"; +import { SoopyGui } from "../../../guimanager"; +import TextBox from "../../../guimanager/GuiElement/TextBox"; class BetterGuis extends Feature { constructor() { @@ -24,6 +26,8 @@ class BetterGuis extends Feature { this.museumGuiEnabled = new ToggleSetting("Custom Museum GUI", "Custom gui for the Museum", true, "custom_museum_enabled", this) this.dungeonReadyGuiEnabled = new ToggleSetting("Custom Dungeon Ready GUI (UNFINISHED)", "Custom gui for the dungeon ready up menu", false, "custom_dungeon_ready_enabled", this) + this.chestSearchBar = new ToggleSetting("Inventory Search Bar", "u can use '&' to make it filter buy stuff that contains multiple things", false, "inv_search", this) + this.lastWindowId = 0 this.shouldHold = 10 this.clickSlot = -1 @@ -121,6 +125,79 @@ class BetterGuis extends Feature { this.registerStep(true, 10, this.step) this.registerEvent("worldUnload", () => { this.museumGui.saveMuseumCache.call(this.museumGui) }) this.registerStep(false, 30, () => { this.museumGui.saveMuseumCache.call(this.museumGui) }) + + + this.invSearchSoopyGui = new SoopyGui() + this.invSearchSoopyGui._renderBackground = () => { } + + this.invSearchTextBox = new TextBox().setPlaceholder("Click to search").setLocation(0.4, 0.05, 0.2, 0.05) + this.invSearchSoopyGui.element.addChild(this.invSearchTextBox) + + this.slotMatches = new Map() + + this.registerEvent("guiRender", this.postGuiRender).registeredWhen(() => this.chestSearchBar.getValue()) + this.registerEvent("guiMouseClick", this.guiMouseClick).registeredWhen(() => this.chestSearchBar.getValue()) + this.registerEvent("guiKey", this.guiKey).registeredWhen(() => this.chestSearchBar.getValue()) + this.registerEvent("renderSlot", this.renderSlot).registeredWhen(() => this.chestSearchBar.getValue()) + this.registerEvent("guiOpened", this.guiOpened).registeredWhen(() => this.chestSearchBar.getValue()) + } + + postGuiRender(x, y, gui) { + if (gui.class.toString() !== "class net.minecraft.client.gui.inventory.GuiChest") return + + this.invSearchSoopyGui._render(x, y, 0) + } + guiMouseClick(x, y, button, gui) { + if (gui.class.toString() !== "class net.minecraft.client.gui.inventory.GuiChest") return + + this.invSearchSoopyGui._onClick(x, y, button) + } + guiKey(char, code, gui, event) { + if (gui.class.toString() !== "class net.minecraft.client.gui.inventory.GuiChest") return + + this.invSearchSoopyGui._onKeyPress(char, code) + + if (this.invSearchTextBox.text.selected) { + cancel(event) + this.slotMatches.clear() + } + } + guiOpened() { + this.slotMatches.clear() + } + + renderSlot(slot, gui, event) { + if (gui.class.toString() !== "class net.minecraft.client.gui.inventory.GuiChest") return + if (!this.invSearchTextBox.getText()) return + + let searchText = this.invSearchTextBox.getText().toLowerCase() + + let isMatching = false + let slotMatches = this.slotMatches.get(slot.getIndex()) + if (slotMatches && Date.now() - slotMatches.timestamp < 500) { + if (!slotMatches.isMatching) { + Renderer.translate(0, 0, 100) + Renderer.drawRect(Renderer.color(0, 0, 0, 200), slot.getDisplayX(), slot.getDisplayY(), 8 * Renderer.screen.getScale(), 8 * Renderer.screen.getScale()) + } + return + } + let item = slot.getItem() + if (item) { + isMatching = !searchText.split("&").map(a => { + a = a.trim() + let isMatching2 = false + if (ChatLib.removeFormatting(item.getName()).toLowerCase().includes(a)) isMatching2 = true + if (!isMatching2 && item.getLore().some(b => ChatLib.removeFormatting(b).toLowerCase().includes(a))) isMatching2 = true + return isMatching2 + }).includes(false) + } + + this.slotMatches.set(slot.getIndex(), { isMatching, timestamp: Date.now() }) + + if (!isMatching) { + Renderer.translate(0, 0, 100) + Renderer.drawRect(Renderer.color(0, 0, 0, 200), slot.getDisplayX(), slot.getDisplayY(), 8 * Renderer.screen.getScale(), 8 * Renderer.screen.getScale()) + } } guiClicked(mouseX, mouseY, button, gui, event) { @@ -228,6 +305,8 @@ class BetterGuis extends Feature { onDisable() { this.initVariables() + + this.invSearchSoopyGui.delete() } } diff --git a/features/dataLoader/index.js b/features/dataLoader/index.js index 21bfe76..f0ede23 100644 --- a/features/dataLoader/index.js +++ b/features/dataLoader/index.js @@ -47,8 +47,6 @@ class DataLoader extends Feature { worldLoad() { this.area = undefined this.areaFine = undefined - - this.worldLoaded = true } loadApi() { @@ -69,9 +67,8 @@ class DataLoader extends Feature { if (!key) return if (this.loadedApiDatas[type] !== undefined) { - if (Date.now() - this.loadedApiDatas[type] < 5000 && !this.worldLoaded) return + if (Date.now() - this.loadedApiDatas[type] < 5000) return } - this.worldLoaded = false this.loadedApiDatas[type] = Date.now() diff --git a/features/dungeonMap/index.js b/features/dungeonMap/index.js index fd8b0a0..bdaaf23 100644 --- a/features/dungeonMap/index.js +++ b/features/dungeonMap/index.js @@ -482,7 +482,10 @@ class DungeonMap extends Feature { let ry = 0 for (let x = 0; x < 128; x += 5) { for (let y = 0; y < 128; y += 5) { - if (bytes[x + y * 128] === 30) { + if (bytes[x + y * 128] === 30 + && bytes[x + 1 + y * 128] === 30 + && bytes[x + 2 + y * 128] === 30 + && bytes[x + 3 + y * 128] === 30) { rx = x ry = y while (bytes[(rx - 1) + ry * 128] === 30) { @@ -508,6 +511,7 @@ class DungeonMap extends Feature { roomWidth1++ } let roomWidth = Math.floor(Math.max(roomWidth1, roomWidth2) * 5 / 4) + console.log(roomWidth) this.mapScale = 32 / roomWidth let mortLocationOnMap roomOffsets = [rx % roomWidth - 3, ry % roomWidth - 3] @@ -582,7 +586,6 @@ class DungeonMap extends Feature { } } } - } } |