From 99d0a61cc4b85256c56aceb496045b0a23663733 Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Thu, 30 Dec 2021 01:54:09 +0000 Subject: [PATCH 1/4] worldpoint: use passed plane when getting instance chunk for localpoint Without this, fromLocalInstance can only find the template chunk for the player's current plane. --- .../src/main/java/net/runelite/api/coords/WorldPoint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java b/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java index cafb9e9115..8b31f7c499 100644 --- a/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java +++ b/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java @@ -198,7 +198,7 @@ public class WorldPoint // get the template chunk for the chunk int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks(); - int templateChunk = instanceTemplateChunks[client.getPlane()][chunkX][chunkY]; + int templateChunk = instanceTemplateChunks[plane][chunkX][chunkY]; int rotation = templateChunk >> 1 & 0x3; int templateChunkY = (templateChunk >> 3 & 0x7FF) * CHUNK_SIZE; From c23e499c92cd4e82e47dd9bbff05e027d53e43bf Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Thu, 30 Dec 2021 01:59:48 +0000 Subject: [PATCH 2/4] roof removal: use worldpoint's plane instead of current plane This allows for overrides on template chunks to be defined based on the chunk's position, not where the chunk ends up in the scene. I think this only really matters for the POH, which stores each style across all 4 planes of 3 (or 7) regions. --- .../client/plugins/roofremoval/RoofRemovalPlugin.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalPlugin.java index 9f86d9a47e..d9d711ab41 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalPlugin.java @@ -250,15 +250,15 @@ public class RoofRemovalPlugin extends Plugin // Properly account for instances shifting worldpoints around final WorldPoint wp = WorldPoint.fromLocalInstance(client, tile.getLocalLocation(), tile.getPlane()); - int regionID = wp.getRegionID() << 2 | z; - if (!overrides.containsKey(regionID)) + int regionAndPlane = wp.getRegionID() << 2 | wp.getPlane(); + if (!overrides.containsKey(regionAndPlane)) { continue; } int rx = wp.getRegionX(); int ry = wp.getRegionY(); - long[] region = overrides.get(regionID); + long[] region = overrides.get(regionAndPlane); if ((region[ry] & (1L << rx)) != 0) { settings[z][x][y] |= Constants.TILE_FLAG_UNDER_ROOF; From 7bacb13ac52fc381eba9fa36a4f905bc164b25d9 Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Thu, 30 Dec 2021 02:00:53 +0000 Subject: [PATCH 3/4] roof removal: add overrides for unused area in the POH dungeon --- .../plugins/roofremoval/overrides.jsonc | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/roofremoval/overrides.jsonc b/runelite-client/src/main/resources/net/runelite/client/plugins/roofremoval/overrides.jsonc index df0cc06c5e..04433ef5a0 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/roofremoval/overrides.jsonc +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/roofremoval/overrides.jsonc @@ -3328,5 +3328,35 @@ "z1": 0, "z2": 0 } + ], + "7513": [ // POH styles 1-4 + { + "rx1": 24, + "ry1": 0, + "rx2": 31, + "ry2": 7, + "z1": 0, + "z2": 3 + } + ], + "7769": [ // POH styles 5-8 + { + "rx1": 24, + "ry1": 0, + "rx2": 31, + "ry2": 7, + "z1": 0, + "z2": 3 + } + ], + "8025": [ // POH styles 9-12 + { + "rx1": 24, + "ry1": 0, + "rx2": 31, + "ry2": 7, + "z1": 0, + "z2": 3 + } ] } From 13154de18f0e967c0d4e6868f46e7d766a00a279 Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Thu, 30 Dec 2021 02:13:26 +0000 Subject: [PATCH 4/4] roof removal: add support for always hiding roofs in POH --- .../roofremoval/RoofRemovalConfig.java | 38 +++++++++++-- .../RoofRemovalConfigOverride.java | 45 ++++++++++++++++ .../roofremoval/RoofRemovalPlugin.java | 53 +++++++++++++++---- 3 files changed, 121 insertions(+), 15 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalConfigOverride.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalConfig.java index 39bf615853..4a32c41b36 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalConfig.java @@ -27,16 +27,32 @@ package net.runelite.client.plugins.roofremoval; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.ConfigSection; @ConfigGroup(RoofRemovalConfig.CONFIG_GROUP) public interface RoofRemovalConfig extends Config { String CONFIG_GROUP = "roofremoval"; + @ConfigSection( + name = "Modes", + description = "In what situations should roofs be removed", + position = 0 + ) + String modesSection = "modes"; + + @ConfigSection( + name = "Area Overrides", + description = "Always remove roofs in specific areas", + position = 1 + ) + String overridesSection = "overrides"; + @ConfigItem( keyName = "removePosition", name = "Player's position", - description = "Remove roofs above the player's position" + description = "Remove roofs above the player's position", + section = modesSection ) default boolean removePosition() { @@ -46,7 +62,8 @@ public interface RoofRemovalConfig extends Config @ConfigItem( keyName = "removeHovered", name = "Hovered tile", - description = "Remove roofs above the hovered tile" + description = "Remove roofs above the hovered tile", + section = modesSection ) default boolean removeHovered() { @@ -56,7 +73,8 @@ public interface RoofRemovalConfig extends Config @ConfigItem( keyName = "removeDestination", name = "Destination tile", - description = "Remove roofs above the destination tile" + description = "Remove roofs above the destination tile", + section = modesSection ) default boolean removeDestination() { @@ -66,10 +84,22 @@ public interface RoofRemovalConfig extends Config @ConfigItem( keyName = "removeBetween", name = "Between camera & player", - description = "Remove roofs between the camera and the player at low camera angles" + description = "Remove roofs between the camera and the player at low camera angles", + section = modesSection ) default boolean removeBetween() { return true; } + + @ConfigItem( + keyName = "overridePOH", + name = "Player Owned House", + description = "Always remove roofs while in the Player Owned House", + section = overridesSection + ) + default boolean overridePOH() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalConfigOverride.java b/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalConfigOverride.java new file mode 100644 index 0000000000..478f61ee4b --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalConfigOverride.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021 Hydrox6 + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.roofremoval; + +import lombok.Getter; +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +@Getter +enum RoofRemovalConfigOverride +{ + POH(RoofRemovalConfig::overridePOH, 7257, 7513, 7514, 7769, 7770, 8025, 8026); + + private final Predicate enabled; + private final List regions; + + RoofRemovalConfigOverride(Predicate enabled, Integer... regions) + { + this.enabled = enabled; + this.regions = Arrays.asList(regions); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalPlugin.java index d9d711ab41..622974387e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/roofremoval/RoofRemovalPlugin.java @@ -34,8 +34,10 @@ import java.io.InputStreamReader; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -86,6 +88,7 @@ public class RoofRemovalPlugin extends Plugin private RoofRemovalConfig config; private final Map overrides = new HashMap<>(); + private final Set configOverrideRegions = new HashSet<>(); @Provides RoofRemovalConfig getConfig(ConfigManager configManager) @@ -139,7 +142,21 @@ public class RoofRemovalPlugin extends Plugin return; } - client.getScene().setRoofRemovalMode(buildRoofRemovalFlags()); + if (e.getKey().startsWith("remove")) + { + client.getScene().setRoofRemovalMode(buildRoofRemovalFlags()); + } + else if (e.getKey().startsWith("override")) + { + buildConfigOverrides(); + clientThread.invoke(() -> + { + if (client.getGameState() == GameState.LOGGED_IN) + { + client.setGameState(GameState.LOADING); + } + }); + } } private int buildRoofRemovalFlags() @@ -164,6 +181,18 @@ public class RoofRemovalPlugin extends Plugin return roofRemovalMode; } + private void buildConfigOverrides() + { + configOverrideRegions.clear(); + for (RoofRemovalConfigOverride configOverride : RoofRemovalConfigOverride.values()) + { + if (configOverride.getEnabled().test(config)) + { + configOverrideRegions.addAll(configOverride.getRegions()); + } + } + } + private void performRoofRemoval() { assert client.isClientThread(); @@ -220,7 +249,7 @@ public class RoofRemovalPlugin extends Plugin { for (int z = 0; z < Constants.MAX_Z; z++) { - if (overrides.containsKey(regionID << 2 | z)) + if (overrides.containsKey(regionID << 2 | z) || configOverrideRegions.contains(regionID)) { regionsHaveOverrides = true; break outer; @@ -251,18 +280,20 @@ public class RoofRemovalPlugin extends Plugin final WorldPoint wp = WorldPoint.fromLocalInstance(client, tile.getLocalLocation(), tile.getPlane()); int regionAndPlane = wp.getRegionID() << 2 | wp.getPlane(); - if (!overrides.containsKey(regionAndPlane)) - { - continue; - } - - int rx = wp.getRegionX(); - int ry = wp.getRegionY(); - long[] region = overrides.get(regionAndPlane); - if ((region[ry] & (1L << rx)) != 0) + if (configOverrideRegions.contains(wp.getRegionID())) { settings[z][x][y] |= Constants.TILE_FLAG_UNDER_ROOF; } + else if (overrides.containsKey(regionAndPlane)) + { + int rx = wp.getRegionX(); + int ry = wp.getRegionY(); + long[] region = overrides.get(regionAndPlane); + if ((region[ry] & (1L << rx)) != 0) + { + settings[z][x][y] |= Constants.TILE_FLAG_UNDER_ROOF; + } + } } } }