diff options
7 files changed, 293 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 02db25131..ce729c24d 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -218,6 +218,7 @@ import at.hannibal2.skyhanni.features.garden.pests.PestSpawn import at.hannibal2.skyhanni.features.garden.pests.PestSpawnTimer import at.hannibal2.skyhanni.features.garden.pests.SprayDisplay import at.hannibal2.skyhanni.features.garden.pests.SprayFeatures +import at.hannibal2.skyhanni.features.garden.pests.StereoHarmonyDisplay import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorDropStatistics import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures @@ -805,6 +806,7 @@ class SkyHanniMod { loadModule(PestSpawnTimer) loadModule(PestFinder()) loadModule(PestParticleWaypoint()) + loadModule(StereoHarmonyDisplay()) loadModule(SprayFeatures()) loadModule(DojoRankDisplay()) loadModule(SprayDisplay()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestsConfig.java index 05fa9de37..c90b9b598 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestsConfig.java @@ -35,4 +35,9 @@ public class PestsConfig { @ConfigOption(name = "Spray", desc = "") @Accordion public SprayConfig spray = new SprayConfig(); + + @ConfigOption(name = "Stereo Harmony", desc = "") + @Accordion + @Expose + public StereoHarmonyConfig stereoHarmony = new StereoHarmonyConfig(); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/StereoHarmonyConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/StereoHarmonyConfig.java new file mode 100644 index 000000000..3ff82a246 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/StereoHarmonyConfig.java @@ -0,0 +1,53 @@ +package at.hannibal2.skyhanni.config.features.garden.pests; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.core.config.Position; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; + +public class StereoHarmonyConfig { + + @Expose + @ConfigOption( + name = "Enabled", + desc = "Shows a display of what pest is being boosted by your vinyl." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean displayEnabled = true; + + @Expose + @ConfigOption( + name = "Always Show", + desc = "Shows the display even while not farming." + ) + @ConfigEditorBoolean + public boolean alwaysShow = false; + + @Expose + @ConfigOption(name = "Show Pest Head", desc = "Show the head of the pest being boosted.") + @ConfigEditorBoolean + public Property<Boolean> showHead = Property.of(true); + + @Expose + @ConfigOption( + name = "Show Crop Icon", + desc = "Show the icon of the crops dropped by the pests\n" + + "being boosted." + ) + @ConfigEditorBoolean + public Property<Boolean> showCrop = Property.of(true); + + @Expose + @ConfigOption( + name = "Hide when None", + desc = "Hide when no vinyl selected." + ) + @ConfigEditorBoolean + public boolean hideWhenNone = false; + + @Expose + public Position position = new Position(205, 55, 1f); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index fd1d87206..1a2d98223 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.features.garden.farming.ArmorDropTracker; import at.hannibal2.skyhanni.features.garden.farming.DicerRngDropTracker; import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLane; import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; +import at.hannibal2.skyhanni.features.garden.pests.VinylType; import at.hannibal2.skyhanni.features.garden.pests.PestProfitTracker; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker; @@ -290,6 +291,9 @@ public class ProfileSpecificStorage { @Expose public PestProfitTracker.Data pestProfitTracker = new PestProfitTracker.Data(); + + @Expose + public VinylType activeVinyl = null; } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestType.kt index 946a37c4a..831ce71a7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestType.kt @@ -1,16 +1,96 @@ package at.hannibal2.skyhanni.features.garden.pests import at.hannibal2.skyhanni.features.combat.damageindicator.BossType +import at.hannibal2.skyhanni.features.garden.CropType +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName -enum class PestType(val displayName: String, val damageIndicatorBoss: BossType, val spray: SprayType) { - BEETLE("Beetle", BossType.GARDEN_PEST_BEETLE, SprayType.DUNG), - CRICKET("Cricket", BossType.GARDEN_PEST_CRICKET, SprayType.HONEY_JAR), - EARTHWORM("Earthworm", BossType.GARDEN_PEST_EARTHWORM, SprayType.COMPOST), - FLY("Fly", BossType.GARDEN_PEST_FLY, SprayType.DUNG), - LOCUST("Locust", BossType.GARDEN_PEST_LOCUST, SprayType.PLANT_MATTER), - MITE("Mite", BossType.GARDEN_PEST_MITE, SprayType.TASTY_CHEESE), - MOSQUITO("Mosquito", BossType.GARDEN_PEST_MOSQUITO, SprayType.COMPOST), - MOTH("Moth", BossType.GARDEN_PEST_MOTH, SprayType.HONEY_JAR), - RAT("Rat", BossType.GARDEN_PEST_RAT, SprayType.TASTY_CHEESE), - SLUG("Slug", BossType.GARDEN_PEST_SLUG, SprayType.PLANT_MATTER), +enum class PestType( + val displayName: String, + val damageIndicatorBoss: BossType, + val spray: SprayType, + val vinyl: VinylType, + val internalName: NEUInternalName, + val crop: CropType, +) { + BEETLE( + "Beetle", + BossType.GARDEN_PEST_BEETLE, + SprayType.DUNG, + VinylType.NOT_JUST_A_PEST, + "PEST_BEETLE_MONSTER".asInternalName(), + CropType.NETHER_WART, + ), + CRICKET( + "Cricket", + BossType.GARDEN_PEST_CRICKET, + SprayType.HONEY_JAR, + VinylType.CRICKET_CHOIR, + "PEST_CRICKET_MONSTER".asInternalName(), + CropType.CARROT, + ), + EARTHWORM( + "Earthworm", + BossType.GARDEN_PEST_EARTHWORM, + SprayType.COMPOST, + VinylType.EARTHWORM_ENSEMBLE, + "PEST_EARTHWORM_MONSTER".asInternalName(), + CropType.MELON, + ), + FLY( + "Fly", + BossType.GARDEN_PEST_FLY, + SprayType.DUNG, + VinylType.PRETTY_FLY, + "PEST_FLY_MONSTER".asInternalName(), + CropType.WHEAT, + ), + LOCUST( + "Locust", + BossType.GARDEN_PEST_LOCUST, + SprayType.PLANT_MATTER, + VinylType.CICADA_SYMPHONY, + "PEST_LOCUST_MONSTER".asInternalName(), + CropType.POTATO, + ), + MITE( + "Mite", + BossType.GARDEN_PEST_MITE, + SprayType.TASTY_CHEESE, + VinylType.DYNAMITES, + "PEST_MITE_MONSTER".asInternalName(), + CropType.CACTUS, + ), + MOSQUITO( + "Mosquito", + BossType.GARDEN_PEST_MOSQUITO, + SprayType.COMPOST, + VinylType.BUZZIN_BEATS, + "PEST_MOSQUITO_MONSTER".asInternalName(), + CropType.SUGAR_CANE, + ), + MOTH( + "Moth", + BossType.GARDEN_PEST_MOTH, + SprayType.HONEY_JAR, + VinylType.WINGS_OF_HARMONY, + "PEST_MOTH_MONSTER".asInternalName(), + CropType.COCOA_BEANS, + ), + RAT( + "Rat", + BossType.GARDEN_PEST_RAT, + SprayType.TASTY_CHEESE, + VinylType.RODENT_REVOLUTION, + "PEST_RAT_MONSTER".asInternalName(), + CropType.COCOA_BEANS, + ), + SLUG( + "Slug", + BossType.GARDEN_PEST_SLUG, + SprayType.PLANT_MATTER, + VinylType.SLOW_AND_GROOVY, + "PEST_SLUG_MONSTER".asInternalName(), + CropType.MUSHROOM, + ), } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/StereoHarmonyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/StereoHarmonyDisplay.kt new file mode 100644 index 000000000..9bf615828 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/StereoHarmonyDisplay.kt @@ -0,0 +1,116 @@ +package at.hannibal2.skyhanni.features.garden.pests + +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.utils.ConditionalUtils +import at.hannibal2.skyhanni.utils.ItemUtils +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack +import at.hannibal2.skyhanni.utils.RenderUtils +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class StereoHarmonyDisplay { + + private val config get() = PestAPI.config.stereoHarmony + + private var activeVinyl: VinylType? + get() = ProfileStorageData.profileSpecific?.garden?.activeVinyl + private set(type) { + ProfileStorageData.profileSpecific?.garden?.activeVinyl = type + } + + private fun VinylType.getPest() = PestType.entries.find { it.vinyl == this } + + private val vinylTypeGroup = RepoPattern.group("garden.vinyl") + + /** + * REGEX-TEST: §aYou are now playing §r§eNot Just a Pest§r§a! + */ + private val selectVinylPattern by vinylTypeGroup.pattern( + "select", + "§aYou are now playing §r§e(?<type>.*)§r§a!" + ) + /** + * REGEX-TEST: §aYou are no longer playing §r§eNot Just a Pest§r§a! + */ + private val unselectVinylPattern by vinylTypeGroup.pattern( + "unselect", + "§aYou are no longer playing §r§e.*§r§a!" + ) + + private var display = emptyList<Renderable>() + + private val questionMarkSkull = ItemUtils.createSkull( + "§c?", + "28aa984a-2077-40cc-8de7-e641adf2c497", + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDZiY"+ + "TYzMzQ0ZjQ5ZGQxYzRmNTQ4OGU5MjZiZjNkOWUyYjI5OTE2YTZjNTBkNjEwYmI0MGE1MjczZGM4YzgyIn19fQ==" + ) + + private fun update() { + display = drawDisplay() + } + + private fun drawDisplay() = buildList { + val vinyl = activeVinyl ?: return@buildList + val pest = vinyl.getPest() + + val itemStack = pest?.internalName?.getItemStack() ?: questionMarkSkull + if (config.showHead.get()) add(Renderable.itemStack(itemStack, 1.67)) + val list = mutableListOf<Renderable>() + val vinylName = vinyl.displayName + val pestName = pest?.displayName ?: "None" + list.add(Renderable.string("§ePlaying: §a$vinylName")) + val pestLine = mutableListOf<Renderable>() + pestLine.add(Renderable.string("§ePest: §c$pestName ")) + if (pest?.crop != null && config.showCrop.get()) pestLine.add(Renderable.itemStack(pest.crop.icon)) + list.add(Renderable.horizontalContainer(pestLine)) + add(Renderable.verticalContainer(list, verticalAlign = RenderUtils.VerticalAlignment.CENTER)) + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!GardenAPI.inGarden()) return + selectVinylPattern.matchMatcher(event.message) { + activeVinyl = VinylType.getByName(group("type")) + update() + } + if (unselectVinylPattern.matches(event.message)) { + activeVinyl = VinylType.NONE + update() + } + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { + if (!isEnabled()) return + if (!GardenAPI.isCurrentlyFarming() && !config.alwaysShow) return + + if (activeVinyl == VinylType.NONE && config.hideWhenNone) return + else if (display.isEmpty()) update() + if (display.isEmpty()) return + val content = Renderable.horizontalContainer(display, 1, verticalAlign = RenderUtils.VerticalAlignment.CENTER) + val renderables = listOf(content) + config.position.renderRenderables(renderables, posLabel = "Stereo Harmony Display") + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + display = emptyList() + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + ConditionalUtils.onToggle(config.showHead, config.showCrop) { update() } + } + + fun isEnabled() = GardenAPI.inGarden() && config.displayEnabled +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/VinylType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/VinylType.kt new file mode 100644 index 000000000..c3c568cc1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/VinylType.kt @@ -0,0 +1,22 @@ +package at.hannibal2.skyhanni.features.garden.pests + +enum class VinylType(val displayName: String) { + PRETTY_FLY("Pretty Fly"), + CRICKET_CHOIR("Cricket Choir"), + CICADA_SYMPHONY("Cicada Symphony"), + RODENT_REVOLUTION("Rodent Revolution"), + BUZZIN_BEATS("Buzzin' Beats"), + EARTHWORM_ENSEMBLE("Earthworm Ensemble"), + DYNAMITES("DynaMITES"), + WINGS_OF_HARMONY("Wings of Harmony"), + SLOW_AND_GROOVY("Slow and Groovy"), + NOT_JUST_A_PEST("Not Just a Pest"), + NONE("Nothing") + + ; + + companion object { + + fun getByName(name: String) = VinylType.entries.firstOrNull { it.displayName == name } ?: NONE + } +} |