From ebefae8ba16605304779618571485b07f91bb2f4 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:07:27 +0100 Subject: Disabled Diana Inquis Share key while inside any gui. - hannibal2 --- .../hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index 0c4e031f9..e466c88a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.network.play.server.S02PacketChat import net.minecraftforge.event.entity.EntityJoinWorldEvent @@ -165,6 +166,7 @@ object InquisitorWaypointShare { @SubscribeEvent fun onKeyClick(event: LorenzKeyPressEvent) { if (!isEnabled()) return + if (Minecraft.getMinecraft().currentScreen != null) return if (event.keyCode == config.keyBindShare) sendInquisitor() } -- cgit From 76a1c7eb680cb31b050fb848a6a070d33df037c3 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Nov 2023 20:21:10 +0100 Subject: Added option to show king talisman helper outside Dwarven Mines. Fixed King Talisman Helper once again. --- .../skyhanni/config/features/MiningConfig.java | 32 +++++++++---- .../skyhanni/features/mining/KingTalismanHelper.kt | 56 ++++++++++++++++++---- 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java index 840096cac..5272336df 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiningConfig.java @@ -92,19 +92,33 @@ public class MiningConfig { } @Expose - @ConfigOption(name = "Highlight Commission Mobs", desc = "Highlight Mobs that are part of active commissions.") - @ConfigEditorBoolean - @FeatureToggle - public boolean highlightCommissionMobs = false; + @ConfigOption(name = "King Talisman", desc = "") + @Accordion + public KingTalismanConfig kingTalisman = new KingTalismanConfig(); + + public static class KingTalismanConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show kings you have not talked to yet, and when the next missing king will appear.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + + @Expose + @ConfigOption(name = "Outside Mines", desc = "Show the display even while outside the Dwarven Mines.") + @ConfigEditorBoolean + @FeatureToggle + public boolean outsideMines = false; + + @Expose + public Position position = new Position(-400, 220, false, true); + } @Expose - @ConfigOption(name = "King Talisman Helper", desc = "Show kings you have not talked to yet, and when the next missing king will appear.") + @ConfigOption(name = "Highlight Commission Mobs", desc = "Highlight Mobs that are part of active commissions.") @ConfigEditorBoolean @FeatureToggle - public boolean kingTalismanHelper = false; - - @Expose - public Position kingTalismanHelperPos = new Position(-400, 220, false, true); + public boolean highlightCommissionMobs = false; @Expose @ConfigOption(name = "Names in Core", desc = "Show the names of the 4 areas while in the center of the Crystal Hollows.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt index af6a7dbfd..1404e685f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -13,13 +14,16 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.TimeUtils import io.github.moulberry.notenoughupdates.util.SkyBlockTime +import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.Collections class KingTalismanHelper { - private val config get() = SkyHanniMod.feature.mining + private val config get() = SkyHanniMod.feature.mining.kingTalisman + private var currentOffset: Int? = null private val kingLocation = LorenzVec(129.6, 196.5, 194.1) private val kingCircles = listOf( @@ -33,10 +37,11 @@ class KingTalismanHelper { ) private var allKingsDisplay = emptyList() - private var farDisplay = "" + private var farDisplay = "Visit the king to sync up." private var display = emptyList() - fun isNearby() = LorenzUtils.skyBlockArea == "Royal Palace" && kingLocation.distanceToPlayer() < 10 + private fun isNearby() = IslandType.DWARVEN_MINES.isInIsland() && LorenzUtils.skyBlockArea == "Royal Palace" && + kingLocation.distanceToPlayer() < 10 @SubscribeEvent fun onTick(event: LorenzTickEvent) { @@ -46,17 +51,48 @@ class KingTalismanHelper { display = emptyList() return } + val nearby = isNearby() + if (nearby) { + if (currentOffset == null) { + checkOffset() + } + } + + if (currentOffset == null) return update() - display = if (isNearby()) allKingsDisplay else Collections.singletonList(farDisplay) + display = if (nearby) allKingsDisplay else Collections.singletonList(farDisplay) + } + + private fun checkOffset() { + val currentKing = getCurrentKing() + + val king = + EntityUtils.getEntitiesNearby(LorenzVec(129.6, 196.0, 196.7), 2.0) + .filter { it.name.startsWith("§6§lKing ") }.first() + val foundKing = "§6§lKing (?.*)".toPattern().matchMatcher(king.name) { + group("name") + } ?: return + + println(" ") + + val currentId = kingCircles.indexOf(currentKing) + println("currentKing: $currentKing $currentId") + + val foundId = kingCircles.indexOf(foundKing) + println("currentKing: $foundKing $foundId") + + currentOffset = currentId - foundId } - fun isEnabled() = config.kingTalismanHelper && IslandType.DWARVEN_MINES.isInIsland() + fun isEnabled() = config.enabled && LorenzUtils.inSkyBlock + && (IslandType.DWARVEN_MINES.isInIsland() || config.outsideMines) @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (event.inventoryName != "Commissions") return if (!isEnabled()) return + if (currentOffset == null) return if (!isNearby()) return val profileSpecific = ProfileStorageData.profileSpecific ?: return @@ -120,12 +156,14 @@ class KingTalismanHelper { } private fun getKingTimes(): MutableMap { + val currentOffset = currentOffset ?: 0 val oneSbDay = 1000 * 60 * 20 val oneCircleTime = oneSbDay * kingCircles.size val kingTime = mutableMapOf() for ((index, king) in kingCircles.withIndex()) { - - val startTime = SkyBlockTime(day = index + 2 - kingCircles.size) +// val startTime = SkyBlockTime(day = index + 2 - kingCircles.size) +// val startTime = SkyBlockTime(day = index - kingCircles.size) + val startTime = SkyBlockTime(day = index + currentOffset - kingCircles.size) var timeNext = startTime.toMillis() while (timeNext < System.currentTimeMillis()) { timeNext += oneCircleTime @@ -140,8 +178,8 @@ class KingTalismanHelper { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!config.kingTalismanHelper) return + if (!config.enabled) return - config.kingTalismanHelperPos.renderStrings(display, posLabel = "King Talisman Helper") + config.position.renderStrings(display, posLabel = "King Talisman Helper") } } -- cgit From af3e264dbeba9ab4b9ba4bae1334fa31232f7d78 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Nov 2023 20:21:50 +0100 Subject: code cleanup --- .../skyhanni/features/mining/KingTalismanHelper.kt | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt index 1404e685f..33d5b174c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt @@ -65,23 +65,14 @@ class KingTalismanHelper { } private fun checkOffset() { - val currentKing = getCurrentKing() - - val king = - EntityUtils.getEntitiesNearby(LorenzVec(129.6, 196.0, 196.7), 2.0) - .filter { it.name.startsWith("§6§lKing ") }.first() + val king = EntityUtils.getEntitiesNearby(LorenzVec(129.6, 196.0, 196.7), 2.0) + .filter { it.name.startsWith("§6§lKing ") }.first() val foundKing = "§6§lKing (?.*)".toPattern().matchMatcher(king.name) { group("name") } ?: return - println(" ") - - val currentId = kingCircles.indexOf(currentKing) - println("currentKing: $currentKing $currentId") - + val currentId = kingCircles.indexOf(getCurrentKing()) val foundId = kingCircles.indexOf(foundKing) - println("currentKing: $foundKing $foundId") - currentOffset = currentId - foundId } -- cgit From ec2d189ede2487a98943339fa7816a0e948e7a90 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Nov 2023 20:41:55 +0100 Subject: Auto reset on year change, also added /shkingfix support --- .../hannibal2/skyhanni/config/commands/Commands.kt | 5 ++ .../skyhanni/features/mining/KingTalismanHelper.kt | 54 ++++++++++++++-------- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 1e32ff718..82318656a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -24,6 +24,7 @@ import at.hannibal2.skyhanni.features.garden.farming.FarmingWeightDisplay import at.hannibal2.skyhanni.features.garden.farming.GardenStartLocation import at.hannibal2.skyhanni.features.garden.fortuneguide.CaptureFarmingGear import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI +import at.hannibal2.skyhanni.features.mining.KingTalismanHelper import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.CollectionTracker import at.hannibal2.skyhanni.features.misc.LockMouseLook @@ -218,6 +219,10 @@ object Commands { "shrepostatus", "Shows the status of all the mods constants" ) { SkyHanniMod.repo.displayRepoStatus(false) } + registerCommand( + "shkingfix", + "Reseting the local King Talisman Helper offset." + ) { KingTalismanHelper.kingFix() } } private fun developersDebugFeatures() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt index 33d5b174c..e9fc47dca 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt @@ -23,7 +23,23 @@ import java.util.Collections class KingTalismanHelper { private val config get() = SkyHanniMod.feature.mining.kingTalisman - private var currentOffset: Int? = null + + companion object { + private var currentOffset: Int? = null + private var skyblockYear = 0 + + private fun getCurrentOffset(): Int? { + if (SkyBlockTime.now().year != skyblockYear) { + return null + } + return currentOffset + } + + fun kingFix() { + currentOffset = null + LorenzUtils.chat("§e[SkyHanni] Reset internal offset of King Talisman Helper.") + } + } private val kingLocation = LorenzVec(129.6, 196.5, 194.1) private val kingCircles = listOf( @@ -37,7 +53,7 @@ class KingTalismanHelper { ) private var allKingsDisplay = emptyList() - private var farDisplay = "Visit the king to sync up." + private var farDisplay = "" private var display = emptyList() private fun isNearby() = IslandType.DWARVEN_MINES.isInIsland() && LorenzUtils.skyBlockArea == "Royal Palace" && @@ -46,21 +62,22 @@ class KingTalismanHelper { @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!event.isMod(20)) return + if (!isEnabled()) return + val profileSpecific = ProfileStorageData.profileSpecific ?: return - if (!isEnabled()) { - display = emptyList() - return - } val nearby = isNearby() - if (nearby) { - if (currentOffset == null) { - checkOffset() - } + if (nearby && getCurrentOffset() == null) { + checkOffset() } - if (currentOffset == null) return + val kingsTalkedTo = profileSpecific.mining.kingsTalkedTo + if (getCurrentOffset() == null) { + val allKings = kingsTalkedTo.size == kingCircles.size + display = if (allKings) emptyList() else listOf("§cVisit the king to sync up.") + return + } - update() + update(kingsTalkedTo) display = if (nearby) allKingsDisplay else Collections.singletonList(farDisplay) } @@ -74,6 +91,7 @@ class KingTalismanHelper { val currentId = kingCircles.indexOf(getCurrentKing()) val foundId = kingCircles.indexOf(foundKing) currentOffset = currentId - foundId + skyblockYear = SkyBlockTime.now().year } fun isEnabled() = config.enabled && LorenzUtils.inSkyBlock @@ -83,7 +101,7 @@ class KingTalismanHelper { fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (event.inventoryName != "Commissions") return if (!isEnabled()) return - if (currentOffset == null) return + if (getCurrentOffset() == null) return if (!isNearby()) return val profileSpecific = ProfileStorageData.profileSpecific ?: return @@ -92,14 +110,12 @@ class KingTalismanHelper { if (currentKing !in kingsTalkedTo) { LorenzUtils.debug("Found new king!") kingsTalkedTo.add(currentKing) - update() + update(kingsTalkedTo) display = allKingsDisplay } } - private fun update() { - val profileSpecific = ProfileStorageData.profileSpecific ?: return - val kingsTalkedTo = profileSpecific.mining.kingsTalkedTo + private fun update(kingsTalkedTo: MutableList) { if (kingsTalkedTo.size == kingCircles.size) { allKingsDisplay = Collections.singletonList("§eAll Kings found.") farDisplay = "" @@ -147,7 +163,7 @@ class KingTalismanHelper { } private fun getKingTimes(): MutableMap { - val currentOffset = currentOffset ?: 0 + val currentOffset = getCurrentOffset() ?: 0 val oneSbDay = 1000 * 60 * 20 val oneCircleTime = oneSbDay * kingCircles.size val kingTime = mutableMapOf() @@ -169,7 +185,7 @@ class KingTalismanHelper { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!config.enabled) return + if (!isEnabled()) return config.position.renderStrings(display, posLabel = "King Talisman Helper") } -- cgit From 2ce84766100584a5aaf516a2cbf0907585aaa07e Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Fri, 3 Nov 2023 06:48:51 +1100 Subject: actually fix mouse locking (#662) Fixed mouse sensitivity stuck after restarting by storing old sensitivity. #662 --- .../java/at/hannibal2/skyhanni/config/Storage.java | 11 ++-- .../skyhanni/features/misc/LockMouseLook.kt | 72 +++++++++++----------- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 21ed83b00..a63477a07 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -1,16 +1,16 @@ package at.hannibal2.skyhanni.config; import at.hannibal2.skyhanni.data.model.ComposterUpgrade; +import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNode; +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData; import at.hannibal2.skyhanni.features.dungeon.DungeonAPI; +import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasure; import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity; import at.hannibal2.skyhanni.features.garden.CropAccessory; import at.hannibal2.skyhanni.features.garden.CropType; import at.hannibal2.skyhanni.features.garden.farming.FarmingArmorDrops; import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; -import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNode; -import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasure; -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData; import at.hannibal2.skyhanni.features.mining.powdertracker.PowderChestReward; import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker; import at.hannibal2.skyhanni.features.misc.visualwords.VisualWord; @@ -31,6 +31,9 @@ public class Storage { @Expose public boolean hasPlayedBefore = false; + @Expose + public Float savedMouseSensitivity = .5f; + @Expose public Map> knownFeatureToggles = new HashMap<>(); @@ -457,4 +460,4 @@ public class Storage { public Map bosses = new HashMap<>(); } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt index 8873c7402..b4ab08459 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt @@ -1,36 +1,36 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import net.minecraft.client.Minecraft -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object LockMouseLook { - private var lockedMouse = false - private var oldSensitivity = 0F - private val lockedPosition = -1F / 3F - - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - if (lockedMouse) toggleLock() - val gameSettings = Minecraft.getMinecraft().gameSettings - if (gameSettings.mouseSensitivity == lockedPosition) { - gameSettings.mouseSensitivity = 0.5f - LorenzUtils.chat("§e[SkyHanni] §bReset your mouse sensitivity to 100%.") - } - } - - fun toggleLock() { - lockedMouse = !lockedMouse - - val gameSettings = Minecraft.getMinecraft().gameSettings - if (lockedMouse) { - oldSensitivity = gameSettings.mouseSensitivity - gameSettings.mouseSensitivity = lockedPosition - LorenzUtils.chat("§e[SkyHanni] §bMouse rotation is now locked. Type /shmouselock to unlock your rotation") - } else { - gameSettings.mouseSensitivity = oldSensitivity - LorenzUtils.chat("§e[SkyHanni] §bMouse rotation is now unlocked.") - } - } -} +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object LockMouseLook { + private var lockedMouse = false + private const val lockedPosition = -1F / 3F + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + if (lockedMouse) toggleLock() + val gameSettings = Minecraft.getMinecraft().gameSettings + if (gameSettings.mouseSensitivity == lockedPosition) { + gameSettings.mouseSensitivity = SkyHanniMod.feature.storage.savedMouseSensitivity + LorenzUtils.chat("§e[SkyHanni] §bMouse rotation is now unlocked because you left it locked.") + } + } + + fun toggleLock() { + val gameSettings = Minecraft.getMinecraft().gameSettings ?: return + lockedMouse = !lockedMouse + + if (lockedMouse) { + SkyHanniMod.feature.storage.savedMouseSensitivity = gameSettings.mouseSensitivity + gameSettings.mouseSensitivity = lockedPosition + LorenzUtils.chat("§e[SkyHanni] §bMouse rotation is now locked. Type /shmouselock to unlock your rotation") + } else { + gameSettings.mouseSensitivity = SkyHanniMod.feature.storage.savedMouseSensitivity + LorenzUtils.chat("§e[SkyHanni] §bMouse rotation is now unlocked.") + } + } +} -- cgit From 7df75c9469bedda34ffce42273abc96f952f613a Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 2 Nov 2023 22:20:32 +0100 Subject: Add visitor highlighter/blocker (#653) Added Highlight Visitors in SkyBlock. Block Interacting with Visitors. #653 --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../skyhanni/config/features/GardenConfig.java | 35 +++++++ .../visitor/HighlightVisitorsOutsideOfGarden.kt | 101 +++++++++++++++++++++ .../test/command/CopyNearbyEntitiesCommand.kt | 3 +- .../skyhanni/utils/jsonobjects/GardenJson.java | 21 ++++- 5 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 8a0805a77..e91fbb1ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -160,6 +160,7 @@ import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorDropStatistics import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorTimer +import at.hannibal2.skyhanni.features.garden.visitor.HighlightVisitorsOutsideOfGarden import at.hannibal2.skyhanni.features.garden.visitor.VisitorListener import at.hannibal2.skyhanni.features.inventory.AuctionsHighlighter import at.hannibal2.skyhanni.features.inventory.ChestValue @@ -354,6 +355,7 @@ class SkyHanniMod { loadModule(VisitorListener()) loadModule(OwnInventoryData()) loadModule(ToolTipData()) + loadModule(HighlightVisitorsOutsideOfGarden()) loadModule(GuiEditManager()) loadModule(UpdateManager) loadModule(CropAccessoryData()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java index d550d3f72..a5d9847ca 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GardenConfig.java @@ -331,6 +331,41 @@ public class GardenConfig { defaultKey = Keyboard.KEY_NONE ) public int acceptHotkey = Keyboard.KEY_NONE; + + + @Expose + @ConfigOption( + name = "Highlight Visitors in SkyBlock", + desc = "Highlights Visitors outside of the Garden" + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean highlightVisitors = false; + + + @Expose + @ConfigOption( + name = "Block Interacting with Visitors", + desc = "Blocks you from interacting with / unlocking Visitors to allow for Dedication Cycling" + ) + @ConfigEditorDropdown + public VisitorBlockBehaviour blockInteracting = VisitorBlockBehaviour.ONLY_ON_BINGO; + + public enum VisitorBlockBehaviour { + DONT("Don't"), ALWAYS("Always"), ONLY_ON_BINGO("Only on Bingo"); + + final String str; + + VisitorBlockBehaviour(String str) { + this.str = str; + } + + @Override + public String toString() { + return str; + } + } + } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt new file mode 100644 index 000000000..e0638c2f6 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt @@ -0,0 +1,101 @@ +package at.hannibal2.skyhanni.features.garden.visitor + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.features.GardenConfig.VisitorConfig.VisitorBlockBehaviour +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.EntityUtils.getSkinTexture +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.getLorenzVec +import at.hannibal2.skyhanni.utils.jsonobjects.GardenJson +import at.hannibal2.skyhanni.utils.toLorenzVec +import io.github.moulberry.notenoughupdates.util.SBInfo +import net.minecraft.client.Minecraft +import net.minecraft.entity.Entity +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.network.play.client.C02PacketUseEntity +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class HighlightVisitorsOutsideOfGarden { + var visitorJson = mapOf>() + + val config get() = SkyHanniMod.feature.garden.visitors + + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + visitorJson = event.getConstant( + "Garden", GardenJson::class.java + ).visitors.values.groupBy { + it.mode + } + } + + fun getSkinOrTypeFor(entity: Entity): String { + if (entity is EntityPlayer) { + return entity.getSkinTexture() ?: "no skin" + } + return entity.javaClass.simpleName + } + + fun isVisitor(entity: Entity): Boolean { + val mode = SBInfo.getInstance().getLocation() + val possibleJsons = visitorJson[mode] ?: return false + val skinOrType = getSkinOrTypeFor(entity) + return possibleJsons.any { + ((it.position == null) || it.position!!.distance(entity.position.toLorenzVec()) < 1) + && it.skinOrType?.replace("\\n", "")?.replace("\n", "") == skinOrType + } + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!config.highlightVisitors) return + if (!event.repeatSeconds(1)) return + EntityUtils.getEntities() + .filter { it !is EntityArmorStand && isVisitor(it) } + .forEach { + RenderLivingEntityHelper.setEntityColor( + it, + LorenzColor.DARK_RED.toColor().withAlpha(50) + ) { config.highlightVisitors } + } + } + + val shouldBlock + get() = when (config.blockInteracting) { + VisitorBlockBehaviour.DONT -> false + VisitorBlockBehaviour.ALWAYS -> true + VisitorBlockBehaviour.ONLY_ON_BINGO -> SBInfo.getInstance().bingo + null -> false + } + + @SubscribeEvent + fun onClickEntity(event: PacketEvent.SendEvent) { + if (!shouldBlock) return + val world = Minecraft.getMinecraft().theWorld ?: return + val player = Minecraft.getMinecraft().thePlayer ?: return + if (player.isSneaking) return + val packet = event.packet as? C02PacketUseEntity ?: return + val entity = packet.getEntityFromWorld(world) ?: return + if (isVisitor(entity) + || (entity is EntityArmorStand && EntityUtils.getEntitiesNearby( + entity.getLorenzVec(), + 2.0 + ).any { isVisitor(it) }) + ) { + event.isCanceled = true + LorenzUtils.clickableChat( + "§e[SkyHanniBal] Blocked you from interacting with a visitor. Sneak to bypass or click here to change settings.", + "/sh block interacting with visitors" + ) + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt index b7c4ae4a1..97cd1c4ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt @@ -45,6 +45,7 @@ object CopyNearbyEntitiesCommand { resultList.add("name: '" + entity.name + "'") resultList.add("displayName: '${displayName.formattedText}'") resultList.add("entityId: ${entity.entityId}") + resultList.add("uuid version: ${entity.uniqueID.version()} ${if(entity.uniqueID.version() != 4) "NPC " else ""}(${entity.uniqueID})") resultList.add("location data:") resultList.add("- vec: $vec") resultList.add("- distance: $distance") @@ -167,4 +168,4 @@ object CopyNearbyEntitiesCommand { resultList.add("- type: $type") } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java index 87a80d391..265e5b11e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.utils.jsonobjects; import at.hannibal2.skyhanni.features.garden.CropType; +import at.hannibal2.skyhanni.utils.LorenzVec; import com.google.gson.annotations.Expose; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Map; @@ -26,7 +28,24 @@ public class GardenJson { @Expose public String rarity; + @Nullable + @Expose + public LorenzVec position; + + /** + * Formatted as follows: + * - If this visitor is a player, get the encoded skin value + * - If this visitor is a mob, get their mob class name + */ + @Nullable + @Expose + public String skinOrType; + + @Nullable + @Expose + public String mode; + @Expose public List need_items; } -} \ No newline at end of file +} -- cgit From 71adca9654bb933405dce2bde970b0a678a55137 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Nov 2023 22:21:20 +0100 Subject: code cleanup --- .../visitor/HighlightVisitorsOutsideOfGarden.kt | 41 ++++++++++++---------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt index e0638c2f6..99f5910ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.getSkinTexture import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.getLorenzVec import at.hannibal2.skyhanni.utils.jsonobjects.GardenJson import at.hannibal2.skyhanni.utils.toLorenzVec @@ -24,11 +25,10 @@ import net.minecraft.network.play.client.C02PacketUseEntity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class HighlightVisitorsOutsideOfGarden { - var visitorJson = mapOf>() + private var visitorJson = mapOf>() val config get() = SkyHanniMod.feature.garden.visitors - @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { visitorJson = event.getConstant( @@ -36,22 +36,27 @@ class HighlightVisitorsOutsideOfGarden { ).visitors.values.groupBy { it.mode } + for (list in visitorJson.values) { + for (visitor in list) { + visitor.skinOrType = visitor.skinOrType?.replace("\\n", "")?.replace("\n", "") + } + } } - fun getSkinOrTypeFor(entity: Entity): String { + private fun getSkinOrTypeFor(entity: Entity): String { if (entity is EntityPlayer) { return entity.getSkinTexture() ?: "no skin" } return entity.javaClass.simpleName } - fun isVisitor(entity: Entity): Boolean { + private fun isVisitor(entity: Entity): Boolean { val mode = SBInfo.getInstance().getLocation() val possibleJsons = visitorJson[mode] ?: return false val skinOrType = getSkinOrTypeFor(entity) return possibleJsons.any { - ((it.position == null) || it.position!!.distance(entity.position.toLorenzVec()) < 1) - && it.skinOrType?.replace("\\n", "")?.replace("\n", "") == skinOrType + (it.position == null || it.position!!.distance(entity.position.toLorenzVec()) < 1) + && it.skinOrType == skinOrType } } @@ -69,14 +74,17 @@ class HighlightVisitorsOutsideOfGarden { } } - val shouldBlock + private val shouldBlock get() = when (config.blockInteracting) { VisitorBlockBehaviour.DONT -> false VisitorBlockBehaviour.ALWAYS -> true - VisitorBlockBehaviour.ONLY_ON_BINGO -> SBInfo.getInstance().bingo + VisitorBlockBehaviour.ONLY_ON_BINGO -> LorenzUtils.isBingoProfile null -> false } + private fun isVisitorNearby(location: LorenzVec) = + EntityUtils.getEntitiesNearby(location, 2.0).any { isVisitor(it) } + @SubscribeEvent fun onClickEntity(event: PacketEvent.SendEvent) { if (!shouldBlock) return @@ -85,17 +93,14 @@ class HighlightVisitorsOutsideOfGarden { if (player.isSneaking) return val packet = event.packet as? C02PacketUseEntity ?: return val entity = packet.getEntityFromWorld(world) ?: return - if (isVisitor(entity) - || (entity is EntityArmorStand && EntityUtils.getEntitiesNearby( - entity.getLorenzVec(), - 2.0 - ).any { isVisitor(it) }) - ) { + if (isVisitor(entity) || (entity is EntityArmorStand && isVisitorNearby(entity.getLorenzVec()))) { event.isCanceled = true - LorenzUtils.clickableChat( - "§e[SkyHanniBal] Blocked you from interacting with a visitor. Sneak to bypass or click here to change settings.", - "/sh block interacting with visitors" - ) + if (packet.action == C02PacketUseEntity.Action.INTERACT) { + LorenzUtils.clickableChat( + "§e[SkyHanni] Blocked you from interacting with a visitor. Sneak to bypass or click here to change settings.", + "/sh block interacting with visitors" + ) + } } } } -- cgit From 5052aca0aada1d964117542b00220c2f200c6d74 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Nov 2023 22:21:44 +0100 Subject: Create additional values in the EntityEquipmentChangeEvent for chest, leggings, feet and hand. --- .../java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt index 26705ab5e..eecc132ca 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt @@ -9,6 +9,10 @@ data class EntityEquipmentChangeEvent( val newItemStack: ItemStack? ) : LorenzEvent() { val isHead get() = equipmentSlot == EQUIPMENT_SLOT_HEAD + val isChest get() = equipmentSlot == EQUIPMENT_SLOT_CHEST + val isLeggings get() = equipmentSlot == EQUIPMENT_SLOT_LEGGINGS + val isFeet get() = equipmentSlot == EQUIPMENT_SLOT_FEET + val isHand get() = equipmentSlot == EQUIPMENT_SLOT_HAND companion object { const val EQUIPMENT_SLOT_HEAD = 4 @@ -17,4 +21,4 @@ data class EntityEquipmentChangeEvent( const val EQUIPMENT_SLOT_FEET = 1 const val EQUIPMENT_SLOT_HAND = 0 } -} \ No newline at end of file +} -- cgit From d3e11684c9efb0635f5199183f9b97ff748c54be Mon Sep 17 00:00:00 2001 From: "Erymanthus[#5074] | (u/)RayDeeUx" <51521765+RayDeeUx@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:29:05 -0400 Subject: Feature(s): Add scoreboard as data source + sunmoon (#576) In-Game Date: Adds support for reading the in-game scoreboard, and also allow sun/moon symbol customization. #576 --- .../skyhanni/config/features/GUIConfig.java | 22 ++++++++++++++++-- .../skyhanni/features/misc/InGameDateDisplay.kt | 27 ++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java index d7fd4625d..177c0b3ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java @@ -115,17 +115,35 @@ public class GUIConfig { @Expose public Position position = new Position(10, 10, false, true); + @Expose + @ConfigOption( + name = "Use Scoreboard for Date", + desc = "Uses the scoreboard instead to find the current month, date, and time. Greater \"accuracy\", depending on who's asking." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean useScoreboard = true; + + @Expose + @ConfigOption( + name = "Show Sun/Moon", + desc = "Show the sun or moon symbol seen on the scoreboard." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean includeSunMoon = true; + @Expose @ConfigOption( name = "Refresh Rate", - desc = "Change the time in seconds you would like to refresh the In-Game Date Display." + desc = "Change the time in seconds you would like to refresh the In-Game Date Display.\n§eNOTE: If \"Use Scoreboard for Date\" is enabled, this setting is ignored." ) @ConfigEditorSlider( minValue = 1, maxValue = 60, minStep = 1 ) - public int RefreshSeconds = 10; + public int refreshSeconds = 30; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt index 028b0edbc..1874d1143 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt @@ -1,28 +1,51 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils.formatted import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class InGameDateDisplay { private val config get() = SkyHanniMod.feature.gui.inGameDateConfig + private val monthAndDatePattern = ".*((Early|Late) )?(Winter|Spring|Summer|Autumn) [0-9]{1,2}(nd|rd|th|st).*".toPattern() private var display = "" @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (!event.repeatSeconds(config.RefreshSeconds)) return + if (!LorenzUtils.inSkyBlock) return + if (!config.useScoreboard && !event.repeatSeconds(config.refreshSeconds)) return + if (config.useScoreboard && !event.repeatSeconds(1)) return checkDate() } private fun checkDate() { - display = SkyBlockTime.now().formatted() + val date = SkyBlockTime.now() + var theBaseString: String + if (config.useScoreboard) { + val list = ScoreboardData.sidebarLinesFormatted //we need this to grab the moon/sun symbol + val year = "Year ${date.year}" + var monthAndDate = "??" //initalize as "??" as fallback value in case none of the scoreboard lines match + for (line in list) { monthAndDatePattern.matchMatcher(line) { monthAndDate = line } } + val time = list.find{ it.lowercase().contains("am ") || it.lowercase().contains("pm ") } ?: "??" + theBaseString = "$monthAndDate, $year ${time.trim()}".removeColor() + if (!config.includeSunMoon) theBaseString = theBaseString.replace("☽", "").replace("☀", "").replace("࿇", "") + } else { + theBaseString = date.formatted() + if (config.includeSunMoon) { + if ((date.hour >= 6) && (date.hour < 17)) theBaseString = "$theBaseString ☀" + else theBaseString = "$theBaseString ☽" + } + } + display = theBaseString } @SubscribeEvent -- cgit From 27f0b207793ddedf406fd56521d0ae0537279661 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Nov 2023 23:30:22 +0100 Subject: code cleanup --- .../skyhanni/config/features/GUIConfig.java | 27 ++++++++++--------- .../skyhanni/features/misc/InGameDateDisplay.kt | 31 +++++++++++++++------- .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 8 +++--- .../at/hannibal2/skyhanni/utils/StringUtils.kt | 4 ++- .../skyhanni/utils/jsonobjects/TabListJson.java | 11 ++++++++ 5 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TabListJson.java diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java index 177c0b3ce..79df5cdd8 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java @@ -98,15 +98,15 @@ public class GUIConfig { @Expose @ConfigOption(name = "In-Game Date", desc = "") @Accordion - public InGameDateConfig inGameDateConfig = new InGameDateConfig(); + public InGameDateConfig inGameDate = new InGameDateConfig(); public static class InGameDateConfig { @Expose @ConfigOption( - name = "Enabled", - desc = "Show the in-game date of SkyBlock (like in Apec, §ebut with mild delays§7).\n" + - "(Though this one includes the SkyBlock year!)" + name = "Enabled", + desc = "Show the in-game date of SkyBlock (like in Apec, §ebut with mild delays§7).\n" + + "(Though this one includes the SkyBlock year!)" ) @ConfigEditorBoolean @FeatureToggle @@ -117,8 +117,8 @@ public class GUIConfig { @Expose @ConfigOption( - name = "Use Scoreboard for Date", - desc = "Uses the scoreboard instead to find the current month, date, and time. Greater \"accuracy\", depending on who's asking." + name = "Use Scoreboard for Date", + desc = "Uses the scoreboard instead to find the current month, date, and time. Greater \"accuracy\", depending on who's asking." ) @ConfigEditorBoolean @FeatureToggle @@ -126,8 +126,8 @@ public class GUIConfig { @Expose @ConfigOption( - name = "Show Sun/Moon", - desc = "Show the sun or moon symbol seen on the scoreboard." + name = "Show Sun/Moon", + desc = "Show the sun or moon symbol seen on the scoreboard." ) @ConfigEditorBoolean @FeatureToggle @@ -135,13 +135,14 @@ public class GUIConfig { @Expose @ConfigOption( - name = "Refresh Rate", - desc = "Change the time in seconds you would like to refresh the In-Game Date Display.\n§eNOTE: If \"Use Scoreboard for Date\" is enabled, this setting is ignored." + name = "Refresh Rate", + desc = "Change the time in seconds you would like to refresh the In-Game Date Display." + + "\n§eNOTE: If \"Use Scoreboard for Date\" is enabled, this setting is ignored." ) @ConfigEditorSlider( - minValue = 1, - maxValue = 60, - minStep = 1 + minValue = 1, + maxValue = 60, + minStep = 1 ) public int refreshSeconds = 30; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt index 1874d1143..1b08e7ebd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt @@ -4,23 +4,33 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils.formatted +import at.hannibal2.skyhanni.utils.jsonobjects.TabListJson import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class InGameDateDisplay { - private val config get() = SkyHanniMod.feature.gui.inGameDateConfig - private val monthAndDatePattern = ".*((Early|Late) )?(Winter|Spring|Summer|Autumn) [0-9]{1,2}(nd|rd|th|st).*".toPattern() + private val config get() = SkyHanniMod.feature.gui.inGameDate + private val monthAndDatePattern = + ".*((Early|Late) )?(Winter|Spring|Summer|Autumn) [0-9]{1,2}(nd|rd|th|st).*".toPattern() private var display = "" + // sun, moon, spooky + private var sunMoonIcons = emptyList() + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + sunMoonIcons = event.getConstant("TabList").sun_moon_symbols + } + @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return - if (!LorenzUtils.inSkyBlock) return if (!config.useScoreboard && !event.repeatSeconds(config.refreshSeconds)) return if (config.useScoreboard && !event.repeatSeconds(1)) return @@ -33,16 +43,17 @@ class InGameDateDisplay { if (config.useScoreboard) { val list = ScoreboardData.sidebarLinesFormatted //we need this to grab the moon/sun symbol val year = "Year ${date.year}" - var monthAndDate = "??" //initalize as "??" as fallback value in case none of the scoreboard lines match - for (line in list) { monthAndDatePattern.matchMatcher(line) { monthAndDate = line } } - val time = list.find{ it.lowercase().contains("am ") || it.lowercase().contains("pm ") } ?: "??" + val monthAndDate = list.find { monthAndDatePattern.matches(it) } ?: "??" + val time = list.find { it.lowercase().contains("am ") || it.lowercase().contains("pm ") } ?: "??" theBaseString = "$monthAndDate, $year ${time.trim()}".removeColor() - if (!config.includeSunMoon) theBaseString = theBaseString.replace("☽", "").replace("☀", "").replace("࿇", "") + if (!config.includeSunMoon) { + sunMoonIcons.forEach { theBaseString = theBaseString.replace(it, "") } + } } else { theBaseString = date.formatted() if (config.includeSunMoon) { - if ((date.hour >= 6) && (date.hour < 17)) theBaseString = "$theBaseString ☀" - else theBaseString = "$theBaseString ☽" + theBaseString = if ((date.hour >= 6) && (date.hour < 17)) "$theBaseString ☀" + else "$theBaseString ☽" } } display = theBaseString diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 28afe3b4e..751271510 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -139,6 +139,7 @@ object LorenzUtils { } // TODO replace all calls with regex + @Deprecated("Do not use complicated string operations", ReplaceWith("Regex")) fun String.between(start: String, end: String): String = this.split(start, end)[1] // TODO use derpy() on every use case @@ -426,11 +427,12 @@ object LorenzUtils { val tileSign = (this as AccessorGuiEditSign).tileSign return (tileSign.signText[1].unformattedText.removeColor() == "^^^^^^" - && tileSign.signText[2].unformattedText.removeColor() == "Set your" - && tileSign.signText[3].unformattedText.removeColor() == "speed cap!") + && tileSign.signText[2].unformattedText.removeColor() == "Set your" + && tileSign.signText[3].unformattedText.removeColor() == "speed cap!") } - fun inIsland(island: IslandType) = inSkyBlock && (skyBlockIsland == island || island == IslandType.CATACOMBS && inDungeons) + fun inIsland(island: IslandType) = + inSkyBlock && (skyBlockIsland == island || island == IslandType.CATACOMBS && inDungeons) fun IslandType.isInIsland() = inIsland(this) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 66eb0faad..0900b3812 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -235,4 +235,6 @@ object StringUtils { fun String.convertToFormatted(): String { return this.replace("&&", "§") } -} \ No newline at end of file + + fun Pattern.matches(string: String) = matcher(string).matches() +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TabListJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TabListJson.java new file mode 100644 index 000000000..03c256256 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TabListJson.java @@ -0,0 +1,11 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; + +import java.util.List; + +public class TabListJson { + + @Expose + public List sun_moon_symbols; +} -- cgit From c14cfe950c8d0959e7c6b6fed7fd091b0cf826fe Mon Sep 17 00:00:00 2001 From: "Erymanthus[#5074] | (u/)RayDeeUx" <51521765+RayDeeUx@users.noreply.github.com> Date: Thu, 2 Nov 2023 19:04:20 -0400 Subject: Feature: The Great Spook Display Utilities and Notif Sound (#660) Added support for showing the primal fear data from tab list as gui elements and play warning sound when the next primal fear can spawn. #660 --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../skyhanni/config/features/EventConfig.java | 42 ++++++++++++++++ .../skyhanni/features/event/spook/TheGreatSpook.kt | 58 ++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index e91fbb1ae..0ef311323 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -102,6 +102,7 @@ import at.hannibal2.skyhanni.features.event.diana.InquisitorWaypointShare import at.hannibal2.skyhanni.features.event.diana.SoopyGuessBurrow import at.hannibal2.skyhanni.features.event.jerry.HighlightJerries import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker +import at.hannibal2.skyhanni.features.event.spook.TheGreatSpook import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder import at.hannibal2.skyhanni.features.fame.CityProjectFeatures import at.hannibal2.skyhanni.features.fishing.ChumBucketHider @@ -457,6 +458,7 @@ class SkyHanniMod { loadModule(NonGodPotEffectDisplay()) loadModule(SoopyGuessBurrow()) loadModule(HighlightJerries()) + loadModule(TheGreatSpook()) loadModule(GriffinBurrowHelper) loadModule(GriffinBurrowParticleFinder()) loadModule(BurrowWarpHelper()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/EventConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/EventConfig.java index 7b4d0211f..fe7e36440 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/EventConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/EventConfig.java @@ -329,6 +329,48 @@ public class EventConfig { } + @ConfigOption(name = "The Great Spook", desc = "") + @Accordion + @Expose + public GreatSpookConfig spook = new GreatSpookConfig(); + + public static class GreatSpookConfig { + + @Expose + @ConfigOption(name = "Primal Fear Timer", desc = "Shows cooldown timer for next primal fear.") + @ConfigEditorBoolean + @FeatureToggle + public boolean primalFearTimer = false; + + @Expose + @ConfigOption(name = "Primal Fear Notify", desc = "Plays a notification sound when the next primal fear can spawn.") + @ConfigEditorBoolean + @FeatureToggle + public boolean primalFearNotification = false; + + @Expose + public Position positionTimer = new Position(20, 20, false, true); + + @Expose + @ConfigOption(name = "Fear Stat Display", desc = "Shows your current Fear stat value.") + @ConfigEditorBoolean + @FeatureToggle + public boolean fearStatDisplay = false; + + @Expose + public Position positionFear = new Position(30, 30, false, true); + + @Expose + @ConfigOption(name = "IRL Time Left", desc = "Shows the IRL time left before The Great Spook ends.") + @ConfigEditorBoolean + @FeatureToggle + public boolean greatSpookTimeLeft = false; + + @Expose + public Position positionTimeLeft = new Position(40, 40, false, true); + + } + // comment in if the event is needed again // @ConfigOption(name = "300þ Anniversary Celebration", desc = "Features for the 300þ year of SkyBlock") @Accordion diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt new file mode 100644 index 000000000..f0334549e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt @@ -0,0 +1,58 @@ +package at.hannibal2.skyhanni.features.event.spook + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.TabListData +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class TheGreatSpook { +// §r§cPrimal Fears§r§7: §r§6§lREADY!! + private val config get() = SkyHanniMod.feature.event.spook + private var displayTimer = "" + private var displayFearStat = "" + private var displayTimeLeft = "" + private var notificationSeconds = 0 + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (isAllDisabled()) return + if (!event.repeatSeconds(1)) return + + if (isTimerEnabled() || isNotificationEnabled()) displayTimer = checkTabList(" §r§cPrimal Fears§r§7: ") + if (isFearStatEnabled()) displayFearStat = checkTabList(" §r§5Fear: ") + if (isTimeLeftEnabled()) displayTimeLeft = checkTabList(" §r§dEnds In§r§7: ") + if (isNotificationEnabled()) { + if (displayTimer.endsWith("READY!!")) { + if (notificationSeconds > 0) { + SoundUtils.playBeepSound() + notificationSeconds-- + } + } else if (displayTimer.isNotEmpty()) { + notificationSeconds = 5 + } + } + } + + private fun checkTabList(matchString: String): String { + return (TabListData.getTabList().find { it.contains(matchString) } ?: "").trim() + } + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { + if (isTimerEnabled()) config.positionTimer.renderString(displayTimer, posLabel = "Primal Fear Timer") + if (isFearStatEnabled()) config.positionFear.renderString(displayFearStat, posLabel = "Fear Stat Display") + if (isTimeLeftEnabled()) config.positionTimeLeft.renderString(displayTimeLeft, posLabel = "Time Left Display") + } + + private fun isTimerEnabled(): Boolean = LorenzUtils.inSkyBlock && config.primalFearTimer + + private fun isNotificationEnabled(): Boolean = LorenzUtils.inSkyBlock && config.primalFearNotification + private fun isFearStatEnabled(): Boolean = LorenzUtils.inSkyBlock && config.fearStatDisplay + private fun isTimeLeftEnabled(): Boolean = LorenzUtils.inSkyBlock && config.greatSpookTimeLeft + + private fun isAllDisabled(): Boolean = !isTimeLeftEnabled() && !isTimerEnabled() && !isFearStatEnabled() && + !isNotificationEnabled() +} -- cgit From 4b2a3c1c6e08f142df27679f948dfd63eb1a6976 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Fri, 3 Nov 2023 10:09:16 +1100 Subject: fix tool fortune (#674) Fixed tool fortune. #674 --- .../hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index 9b57e1fe1..d9161c692 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -21,6 +21,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments @@ -174,9 +175,9 @@ class FarmingFortuneDisplay { } return if (internalName.startsWith("THEORETICAL_HOE")) { listOf(10.0, 25.0, 50.0)[internalName.toString().last().digitToInt() - 1] - } else when (internalName.toString()) { - "FUNGI_CUTTER" -> 30.0 - "COCO_CHOPPER" -> 20.0 + } else when (internalName) { + "FUNGI_CUTTER".asInternalName() -> 30.0 + "COCO_CHOPPER".asInternalName() -> 20.0 else -> 0.0 } } @@ -289,4 +290,4 @@ class FarmingFortuneDisplay { event.move(3,"garden.farmingFortuneDropMultiplier", "garden.farmingFortunes.dropMultiplier") event.move(3,"garden.farmingFortunePos", "garden.farmingFortunes.pos") } -} \ No newline at end of file +} -- cgit From 379b7ee6e42f758284e6871072cd52149ecb7d34 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 3 Nov 2023 00:22:10 +0100 Subject: 0.21 Beta 17 --- CHANGELOG.md | 23 +++++++++++++++++++--- FEATURES.md | 6 ++++++ build.gradle.kts | 2 +- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e86f8588..ccf1ba1ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,10 @@ + E.g. inside the SkyBlock leveling guide. + Added Chat **Translator** - NetheriteMiner + After enabling, click on any chat message sent by another player to translate it to English. ++ Added Highlight Visitors in SkyBlock. - nea + + Highlights Visit