diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
3 files changed, 229 insertions, 11 deletions
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 + } +} |