aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorHiZe <super@hize.be>2024-06-22 09:51:55 +0200
committerGitHub <noreply@github.com>2024-06-22 09:51:55 +0200
commit42b3ba09916c32c70666991c8a3e479f07373a6f (patch)
treeb729e579638512358461d7cf20d5c61bee059b6e /src/main/java/at/hannibal2/skyhanni/features
parent608372e88be6a33197397d1e3f5c962dc7fd7b73 (diff)
downloadskyhanni-42b3ba09916c32c70666991c8a3e479f07373a6f.tar.gz
skyhanni-42b3ba09916c32c70666991c8a3e479f07373a6f.tar.bz2
skyhanni-42b3ba09916c32c70666991c8a3e479f07373a6f.zip
Add: Special stray rabbit screen flashing (#2040)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt58
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryScreenFlash.kt62
2 files changed, 90 insertions, 30 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt
index a0c177abb..28447b1df 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt
@@ -35,27 +35,27 @@ object ChocolateFactoryDataLoader {
private val chocolatePerSecondPattern by ChocolateFactoryAPI.patternGroup.pattern(
"chocolate.persecond",
- "§6(?<amount>[\\d.,]+) §8per second"
+ "§6(?<amount>[\\d.,]+) §8per second",
)
private val chocolateAllTimePattern by ChocolateFactoryAPI.patternGroup.pattern(
"chocolate.alltime",
- "§7All-time Chocolate: §6(?<amount>[\\d,]+)"
+ "§7All-time Chocolate: §6(?<amount>[\\d,]+)",
)
private val prestigeLevelPattern by ChocolateFactoryAPI.patternGroup.pattern(
"prestige.level",
- "§6Chocolate Factory (?<prestige>[IVX]+)"
+ "§6Chocolate Factory (?<prestige>[IVX]+)",
)
private val chocolateThisPrestigePattern by ChocolateFactoryAPI.patternGroup.pattern(
"chocolate.thisprestige",
- "§7Chocolate this Prestige: §6(?<amount>[\\d,]+)"
+ "§7Chocolate this Prestige: §6(?<amount>[\\d,]+)",
)
private val chocolateForPrestigePattern by ChocolateFactoryAPI.patternGroup.pattern(
"chocolate.forprestige",
- "§7§cRequires (?<amount>\\w+) Chocolate this.*"
+ "§7§cRequires (?<amount>\\w+) Chocolate this.*",
)
private val chocolateMultiplierPattern by ChocolateFactoryAPI.patternGroup.pattern(
"chocolate.multiplier",
- "§7Total Multiplier: §6(?<amount>[\\d.]+)x"
+ "§7Total Multiplier: §6(?<amount>[\\d.]+)x",
)
/**
@@ -65,55 +65,55 @@ object ChocolateFactoryDataLoader {
*/
private val leaderboardPlacePattern by ChocolateFactoryAPI.patternGroup.pattern(
"leaderboard.place",
- "(?:§.)+You are §8#§b(?<position>[\\d,]+)(?: §7in all-time)?(?: Chocolate\\.)?"
+ "(?:§.)+You are §8#§b(?<position>[\\d,]+)(?: §7in all-time)?(?: Chocolate\\.)?",
)
private val leaderboardPercentilePattern by ChocolateFactoryAPI.patternGroup.pattern(
"leaderboard.percentile",
- "§7§8You are in the top §.(?<percent>[\\d.]+)%§8 of players!"
+ "§7§8You are in the top §.(?<percent>[\\d.]+)%§8 of players!",
)
private val barnAmountPattern by ChocolateFactoryAPI.patternGroup.pattern(
"barn.amount",
- "§7Your Barn: §.(?<rabbits>\\d+)§7/§.(?<max>\\d+) Rabbits"
+ "§7Your Barn: §.(?<rabbits>\\d+)§7/§.(?<max>\\d+) Rabbits",
)
private val timeTowerAmountPattern by ChocolateFactoryAPI.patternGroup.pattern(
"timetower.amount",
- "§7Charges: §.(?<uses>\\d+)§7/§a(?<max>\\d+)"
+ "§7Charges: §.(?<uses>\\d+)§7/§a(?<max>\\d+)",
)
private val timeTowerStatusPattern by ChocolateFactoryAPI.patternGroup.pattern(
"timetower.status",
- "§7Status: §.§l(?<status>INACTIVE|ACTIVE)(?: §f)?(?<acitveTime>\\w*)"
+ "§7Status: §.§l(?<status>INACTIVE|ACTIVE)(?: §f)?(?<acitveTime>\\w*)",
)
private val timeTowerRechargePattern by ChocolateFactoryAPI.patternGroup.pattern(
"timetower.recharge",
- "§7Next Charge: §a(?<duration>\\w+)"
+ "§7Next Charge: §a(?<duration>\\w+)",
)
- private val clickMeRabbitPattern by ChocolateFactoryAPI.patternGroup.pattern(
+ val clickMeRabbitPattern by ChocolateFactoryAPI.patternGroup.pattern(
"rabbit.clickme",
- "§e§lCLICK ME!"
+ "§e§lCLICK ME!",
)
/**
* REGEX-TEST: §6§lGolden Rabbit §8- §aStampede
*/
- private val clickMeGoldenRabbitPattern by ChocolateFactoryAPI.patternGroup.pattern(
+ val clickMeGoldenRabbitPattern by ChocolateFactoryAPI.patternGroup.pattern(
"rabbit.clickme.golden",
- "§6§lGolden Rabbit §8- §a(?<name>.*)"
+ "§6§lGolden Rabbit §8- §a(?<name>.*)",
)
private val rabbitAmountPattern by ChocolateFactoryAPI.patternGroup.pattern(
"rabbit.amount",
- "Rabbit \\S+ - \\[(?<amount>\\d+)].*"
+ "Rabbit \\S+ - \\[(?<amount>\\d+)].*",
)
private val upgradeTierPattern by ChocolateFactoryAPI.patternGroup.pattern(
"upgradetier",
- ".*\\s(?<tier>[IVXLC]+)"
+ ".*\\s(?<tier>[IVXLC]+)",
)
private val unemployedRabbitPattern by ChocolateFactoryAPI.patternGroup.pattern(
"rabbit.unemployed",
- "Rabbit \\w+ - Unemployed"
+ "Rabbit \\w+ - Unemployed",
)
private val otherUpgradePattern by ChocolateFactoryAPI.patternGroup.pattern(
"other.upgrade",
- "Rabbit Shrine|Coach Jackrabbit"
+ "Rabbit Shrine|Coach Jackrabbit",
)
@SubscribeEvent
@@ -138,7 +138,7 @@ object ChocolateFactoryDataLoader {
event.move(
47,
"inventory.chocolateFactory.rabbitWarning",
- "inventory.chocolateFactory.rabbitWarning.rabbitWarning"
+ "inventory.chocolateFactory.rabbitWarning.rabbitWarning",
)
}
@@ -178,8 +178,7 @@ object ChocolateFactoryDataLoader {
processLeaderboardItem(leaderboardItem)
processBarnItem(barnItem)
- profileStorage.rawChocPerSecond =
- (ChocolateFactoryAPI.chocolatePerSecond / profileStorage.chocolateMultiplier + .01).toInt()
+ profileStorage.rawChocPerSecond = (ChocolateFactoryAPI.chocolatePerSecond / profileStorage.chocolateMultiplier + .01).toInt()
profileStorage.lastDataSave = SimpleTimeMark.now()
ChocolateFactoryStats.updateDisplay()
@@ -226,7 +225,7 @@ object ChocolateFactoryDataLoader {
ChocolateFactoryAPI.prestigeIndex,
ChocolateFactoryAPI.currentPrestige,
prestigeCost,
- isPrestige = true
+ isPrestige = true,
)
list.add(prestigeUpgrade)
}
@@ -417,9 +416,7 @@ object ChocolateFactoryDataLoader {
SoundUtils.playBeepSound()
}
- if (warningConfig.specialRabbitWarning
- && (isGoldenRabbit || item.getSkullTexture() in specialRabbitTextures)
- ) {
+ if (warningConfig.specialRabbitWarning && (isGoldenRabbit || item.getSkullTexture() in specialRabbitTextures)) {
SoundUtils.repeatSound(100, warningConfig.repeatSound, ChocolateFactoryAPI.warningSound)
}
@@ -427,12 +424,13 @@ object ChocolateFactoryDataLoader {
}
}
- private fun findBestUpgrades(list: MutableList<ChocolateFactoryUpgrade>) {
+ private fun findBestUpgrades(list: List<ChocolateFactoryUpgrade>) {
val profileStorage = profileStorage ?: return
// removing time tower here as people like to determine when to buy it themselves
- val notMaxed =
- list.filter { !it.isMaxed && it.slotIndex != ChocolateFactoryAPI.timeTowerIndex && it.effectiveCost != null }
+ val notMaxed = list.filter {
+ !it.isMaxed && it.slotIndex != ChocolateFactoryAPI.timeTowerIndex && it.effectiveCost != null
+ }
val bestUpgrade = notMaxed.minByOrNull { it.effectiveCost ?: Double.MAX_VALUE }
profileStorage.bestUpgradeAvailableAt = bestUpgrade?.canAffordAt ?: SimpleTimeMark.farPast()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryScreenFlash.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryScreenFlash.kt
new file mode 100644
index 000000000..6e833a5cc
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryScreenFlash.kt
@@ -0,0 +1,62 @@
+package at.hannibal2.skyhanni.features.inventory.chocolatefactory
+
+import at.hannibal2.skyhanni.config.features.inventory.chocolatefactory.ChocolateFactoryRabbitWarningConfig.FlashScreenTypeEntry
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.SecondPassedEvent
+import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI.specialRabbitTextures
+import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryDataLoader.clickMeGoldenRabbitPattern
+import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryDataLoader.clickMeRabbitPattern
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColorInt
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.RegexUtils.matches
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.Gui
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraft.inventory.Slot
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.math.sin
+
+@SkyHanniModule
+object ChocolateFactoryScreenFlash {
+
+ private val config get() = ChocolateFactoryAPI.config
+ var flashScreen = false
+
+ @SubscribeEvent
+ fun onTick(event: SecondPassedEvent) {
+ if (!ChocolateFactoryAPI.inChocolateFactory) return
+ flashScreen = InventoryUtils.getItemsInOpenChest().any {
+ when (config.rabbitWarning.flashScreenType) {
+ FlashScreenTypeEntry.SPECIAL -> isSpecial(it)
+
+ FlashScreenTypeEntry.ALL -> {
+ clickMeRabbitPattern.matches(it.stack.name) || isSpecial(it)
+ }
+
+ FlashScreenTypeEntry.NONE -> false
+ }
+ }
+ }
+
+ private fun isSpecial(slot: Slot) =
+ clickMeGoldenRabbitPattern.matches(slot.stack.name) || slot.stack.getSkullTexture() in specialRabbitTextures
+
+ @SubscribeEvent
+ fun onRender(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) {
+ if (!ChocolateFactoryAPI.inChocolateFactory) return
+ if (!flashScreen) return
+ val minecraft = Minecraft.getMinecraft()
+ val alpha = ((2 + sin(System.currentTimeMillis().toDouble() / 1000)) * 255 / 4).toInt().coerceIn(0..255)
+ Gui.drawRect(
+ 0,
+ 0,
+ minecraft.displayWidth,
+ minecraft.displayHeight,
+ (alpha shl 24) or (config.rabbitWarning.flashColor.toChromaColorInt() and 0xFFFFFF),
+ )
+ GlStateManager.color(1F, 1F, 1F, 1F)
+ }
+}