Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Stereo Harmony Display #1324

Merged
merged 22 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -803,6 +804,7 @@ class SkyHanniMod {
loadModule(PestSpawnTimer)
loadModule(PestFinder())
loadModule(PestParticleWaypoint())
loadModule(StereoHarmonyDisplay())
loadModule(SprayFeatures())
loadModule(DojoRankDisplay())
loadModule(SprayDisplay())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Original file line number Diff line number Diff line change
@@ -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 = "Always show the display."
)
@ConfigEditorBoolean
public boolean alwaysShow = false;
ItsEmpa marked this conversation as resolved.
Show resolved Hide resolved

@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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand Down Expand Up @@ -290,6 +291,9 @@ public static class FarmingWeightConfig {

@Expose
public PestProfitTracker.Data pestProfitTracker = new PestProfitTracker.Data();

@Expose
public VinylType activeVinyl = null;
}

@Expose
Expand Down
102 changes: 91 additions & 11 deletions src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestType.kt
Original file line number Diff line number Diff line change
@@ -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
),
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Loading