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; 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 9f86d9a47e..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; @@ -250,19 +279,21 @@ 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)) - { - continue; - } - - int rx = wp.getRegionX(); - int ry = wp.getRegionY(); - long[] region = overrides.get(regionID); - if ((region[ry] & (1L << rx)) != 0) + int regionAndPlane = wp.getRegionID() << 2 | wp.getPlane(); + 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; + } + } } } } 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 + } ] }