aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2023-12-11 12:08:24 -0800
committerGitHub <noreply@github.com>2023-12-11 21:08:24 +0100
commit9a5d44a2a68a20429b5d66328f1e2a3a7cfca03b (patch)
treef18bd603f3a137c49cc5686e37eccce236cdcfd1 /src/main
parent5938c9a1220a390d930adf9067c606c7f0d1c667 (diff)
downloadskyhanni-9a5d44a2a68a20429b5d66328f1e2a3a7cfca03b.tar.gz
skyhanni-9a5d44a2a68a20429b5d66328f1e2a3a7cfca03b.tar.bz2
skyhanni-9a5d44a2a68a20429b5d66328f1e2a3a7cfca03b.zip
Feature: Highlight Placeable NPCs (Stranded) (#723)
Highlights NPCs in the stranded menu that are placeable but not placed. #723
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/stranded/StrandedConfig.java14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt69
4 files changed, 91 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index b94e00483..5b11e02cc 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -309,6 +309,7 @@ import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerFirePitsWarning
import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper
import at.hannibal2.skyhanni.features.slayer.enderman.EndermanSlayerFeatures
import at.hannibal2.skyhanni.features.slayer.enderman.EndermanSlayerHideParticles
+import at.hannibal2.skyhanni.features.stranded.HighlightPlaceableNpcs
import at.hannibal2.skyhanni.features.summonings.SummoningMobManager
import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
@@ -670,6 +671,7 @@ class SkyHanniMod {
loadModule(PestSpawnTimer)
loadModule(PestFinder())
loadModule(SprayFeatures())
+ loadModule(HighlightPlaceableNpcs())
loadModule(PresentWaypoints())
loadModule(JyrreTimer())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index bb0861e83..e4f9e548e 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -12,8 +12,8 @@ import at.hannibal2.skyhanni.config.features.dev.DevConfig;
import at.hannibal2.skyhanni.config.features.dungeon.DungeonConfig;
import at.hannibal2.skyhanni.config.features.event.EventConfig;
import at.hannibal2.skyhanni.config.features.fishing.FishingConfig;
-import at.hannibal2.skyhanni.config.features.gui.GUIConfig;
import at.hannibal2.skyhanni.config.features.garden.GardenConfig;
+import at.hannibal2.skyhanni.config.features.gui.GUIConfig;
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig;
import at.hannibal2.skyhanni.config.features.itemability.ItemAbilityConfig;
import at.hannibal2.skyhanni.config.features.markedplayer.MarkedPlayerConfig;
@@ -22,6 +22,7 @@ import at.hannibal2.skyhanni.config.features.minion.MinionsConfig;
import at.hannibal2.skyhanni.config.features.misc.MiscConfig;
import at.hannibal2.skyhanni.config.features.rift.RiftConfig;
import at.hannibal2.skyhanni.config.features.slayer.SlayerConfig;
+import at.hannibal2.skyhanni.config.features.stranded.StrandedConfig;
import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.Config;
import io.github.moulberry.moulconfig.Social;
@@ -138,6 +139,10 @@ public class Features extends Config {
public SlayerConfig slayer = new SlayerConfig();
@Expose
+ @Category(name = "Stranded", desc = "Features for the Stranded game mode.")
+ public StrandedConfig stranded = new StrandedConfig();
+
+ @Expose
@Category(name = "The Rift", desc = "Features for The Rift dimension.")
public RiftConfig rift = new RiftConfig();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/stranded/StrandedConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/stranded/StrandedConfig.java
new file mode 100644
index 000000000..8e5b2824c
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/stranded/StrandedConfig.java
@@ -0,0 +1,14 @@
+package at.hannibal2.skyhanni.config.features.stranded;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
+
+public class StrandedConfig {
+ @Expose
+ @ConfigOption(name = "Highlight Placeable NPCs", desc = "Highlight NPCs that can be placed, but aren't, in the NPC menu.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean highlightPlaceableNpcs = false;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt b/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt
new file mode 100644
index 000000000..52c450ca4
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt
@@ -0,0 +1,69 @@
+package at.hannibal2.skyhanni.features.stranded
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.events.InventoryCloseEvent
+import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.highlight
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class HighlightPlaceableNpcs {
+ private val config get() = SkyHanniMod.feature.stranded.highlightPlaceableNpcs
+ private val locationPattern = "§7Location: §f\\[§e\\d+§f, §e\\d+§f, §e\\d+§f]".toPattern()
+
+ private var inInventory = false
+ private var highlightedItems = emptyList<Int>()
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
+ inInventory = false
+ if (!isEnabled()) return
+
+ if (event.inventoryName != "Island NPCs") return
+
+ val highlightedItems = mutableListOf<Int>()
+ for ((slot, stack) in event.inventoryItems) {
+ if (isPlaceableNpc(stack.getLore())) {
+ highlightedItems.add(slot)
+ }
+ }
+ inInventory = true
+ this.highlightedItems = highlightedItems
+ }
+
+ @SubscribeEvent
+ fun onInventoryClose(event: InventoryCloseEvent) {
+ inInventory = false
+ highlightedItems = emptyList()
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOW)
+ fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
+ if (!isEnabled() || !inInventory) return
+ for (slot in InventoryUtils.getItemsInOpenChest()) {
+ if (slot.slotIndex in highlightedItems) {
+ slot highlight LorenzColor.GREEN
+ }
+ }
+ }
+
+ private fun isPlaceableNpc(lore: List<String>): Boolean {
+ // Checking if NPC & placeable
+ if (lore.isEmpty() || !(lore.last() == "§ethis NPC!" || lore.last() == "§eyour location!")) {
+ return false
+ }
+
+ // Checking if is already placed
+ for (line in lore) {
+ if (locationPattern.matcher(line).matches()) return false
+ }
+ return true
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config
+}