diff options
Diffstat (limited to 'src/main/java/at')
4 files changed, 122 insertions, 30 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryRabbitWarningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryRabbitWarningConfig.java index 1377648d4..ce0ef8ed4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryRabbitWarningConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryRabbitWarningConfig.java @@ -4,10 +4,13 @@ import at.hannibal2.skyhanni.utils.OSUtils; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; import io.github.notenoughupdates.moulconfig.observer.Property; +import org.jetbrains.annotations.NotNull; public class ChocolateFactoryRabbitWarningConfig { @@ -34,6 +37,34 @@ public class ChocolateFactoryRabbitWarningConfig { @ConfigEditorSlider(minValue = 1, maxValue = 20, minStep = 1) public int repeatSound = 20; + @Expose + @ConfigOption(name = "Flash Screen", desc = "Choose the stray rabbit type to flash the screen for.") + @ConfigEditorDropdown + @NotNull + public FlashScreenTypeEntry flashScreenType = FlashScreenTypeEntry.SPECIAL; + + public enum FlashScreenTypeEntry { + SPECIAL("Special"), + ALL("All"), + NONE("None"), + ; + private final String str; + + FlashScreenTypeEntry(String str) { + this.str = str; + } + + @Override + public String toString() { + return str; + } + } + + @Expose + @ConfigOption(name = "Flash Color", desc = "Color of the screen when flashing") + @ConfigEditorColour + public String flashColor = "0:127:0:238:255"; + @ConfigOption(name = "Sounds", desc = "Click to open the list of available sounds.") @ConfigEditorButton(buttonText = "OPEN") public Runnable sounds = () -> OSUtils.openBrowser("https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/mapping-and-modding-tutorials/2213619-1-8-all-playsound-sound-arguments"); 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) + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt index 2a5f7e0e0..423747b79 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt @@ -86,6 +86,7 @@ object SoundUtils { errorSound.playSound() } + // TODO use duration for delay fun repeatSound(delay: Long, repeat: Int, sound: ISound) { SkyHanniMod.coroutineScope.launch { repeat(repeat) { |