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

Fix + Feature: Chocolate Factory Party Time 🥳️‍🌈 #3054

Open
wants to merge 22 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
import io.github.notenoughupdates.moulconfig.observer.Property;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -228,4 +229,13 @@ public class ChocolateFactoryConfig {
@Expose
@ConfigLink(owner = ChocolateFactoryConfig.class, field = "hitmanCosts")
public Position hitmanCostsPosition = new Position(300, 300, false, true);

@Expose
@ConfigOption(
name = "§6CF §zParty Mode",
desc = "Don't turn this on."
)
@ConfigEditorBoolean
@FeatureToggle
public Property<Boolean> partyMode = Property.of(false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ object HoppityAPI {
it.value.getLore().isNotEmpty() // All processable strays have lore.
}


private fun Slot.isMiscProcessable() =
// All misc items are skulls or panes, with a display name, and lore.
stack != null && stack.item != null && stack.item in miscProcessableItemTypes &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import at.hannibal2.skyhanni.features.event.hoppity.HoppityAPI.getEventEndMark
import at.hannibal2.skyhanni.features.event.hoppity.HoppityAPI.getEventStartMark
import at.hannibal2.skyhanni.features.event.hoppity.HoppityRabbitTheFishChecker.mealEggInventoryPattern
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI.partyModeReplace
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateShopPrice.menuNamePattern
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
Expand Down Expand Up @@ -151,7 +152,11 @@ object HoppityEventSummary {
isInventoryEnabled
}

private data class StatString(val string: String, val headed: Boolean = true)
private fun MutableList<StatString>.chromafyLiveDisplay(): MutableList<StatString> =
if (ChocolateFactoryAPI.config.partyMode.get()) map { it.copy(string = it.string.partyModeReplace()) }.toMutableList()
else this

private data class StatString(var string: String, val headed: Boolean = true)

private fun MutableList<StatString>.addStr(string: String, headed: Boolean = true) = this.add(StatString(string, headed))

Expand Down Expand Up @@ -253,6 +258,9 @@ object HoppityEventSummary {
config.eventSummary.statDisplayList.afterChange {
lastKnownStatHash = 0
}
ChocolateFactoryAPI.config.partyMode.afterChange {
lastKnownStatHash = 0
}
}

@SubscribeEvent
Expand Down Expand Up @@ -381,7 +389,7 @@ object HoppityEventSummary {
private fun buildTitle(statYear: Int) = Renderable.verticalContainer(
buildList {
addString(
"§dHoppity's Hunt #${getHoppityEventNumber(statYear)} Stats",
"§dHoppity's Hunt #${getHoppityEventNumber(statYear)} Stats".partyModeReplace(),
horizontalAlign = RenderUtils.HorizontalAlignment.CENTER,
)
val eventEnd = getEventEndMark(statYear)
Expand Down Expand Up @@ -414,7 +422,7 @@ object HoppityEventSummary {
isCurrentEvent -> "§7$grammarFormat §f$timeMarkFormat"
isPastEvent -> "§7Ended §f$timeMarkFormat$grammarFormat"
else -> "§7$grammarFormat §f$timeMarkFormat"
},
}.partyModeReplace(),
)
},
horizontalAlign = RenderUtils.HorizontalAlignment.CENTER,
Expand All @@ -435,13 +443,13 @@ object HoppityEventSummary {
return listOfNotNull(
predecessorYear?.let {
Renderable.optionalLink(
"§d[ §r§f§l<- §r§7Hunt #${getHoppityEventNumber(it)} §r§d]",
"§d[ §r§f§l<- §r§7Hunt #${getHoppityEventNumber(it)} §r§d]".partyModeReplace(),
onClick = { statYear = it },
)
},
successorYear?.let {
Renderable.optionalLink(
"§d[ §7Hunt #${getHoppityEventNumber(it)} §r§f§l-> §r§d]",
"§d[ §7Hunt #${getHoppityEventNumber(it)} §r§f§l-> §r§d]".partyModeReplace(),
onClick = { statYear = it },
)
} ?: if (isNextEventEnabled && !isAlreadyNextEvent) {
Expand Down Expand Up @@ -694,7 +702,7 @@ object HoppityEventSummary {
statList.addStr("§c§oFind some eggs $timeFormat!")
}

return statList
return statList.chromafyLiveDisplay()
}

private fun sendStatsMessage(stats: HoppityEventStats, eventYear: Int?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,8 @@ object ChocolateFactoryAPI {
fun isMax(): Boolean = profileStorage?.let {
it.maxChocolate == it.currentChocolate
} ?: false

fun String.partyModeReplace(): String =
if (config.partyMode.get() && inChocolateFactory) replace(Regex("§[a-fA-F0-9]"), "§z")
else this
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.features.fame.ReminderUtils
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI.partyModeReplace
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
Expand Down Expand Up @@ -182,7 +183,7 @@ object ChocolateFactoryCustomReminder {
return "§aGoal Reached! §eBuy §f$targetName"
}
val format = duration.format(maxUnits = 2)
return "§f$targetName §ein §b$format"
return "§f$targetName §ein §b$format".partyModeReplace()
}

private fun warn() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.features.event.hoppity.HoppityAPI
import at.hannibal2.skyhanni.features.event.hoppity.HoppityEventSummary
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI.partyModeReplace
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.hitman.HitmanAPI.getHitmanTimeToAll
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.hitman.HitmanAPI.getHitmanTimeToFull
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.hitman.HitmanAPI.getOpenSlots
Expand Down Expand Up @@ -86,7 +87,11 @@ object ChocolateFactoryStats {

addHitman()
}
val text = config.statsDisplayList.filter { it.shouldDisplay() }.flatMap { map[it]?.split("\n").orEmpty() }
val text = config.statsDisplayList.filter {
it.shouldDisplay()
}.flatMap {
map[it]?.partyModeReplace()?.split("\n").orEmpty()
}
display = createDisplay(text)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.hoppity.EggFoundEvent
import at.hannibal2.skyhanni.features.event.hoppity.HoppityAPI
import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType
import at.hannibal2.skyhanni.features.event.hoppity.HoppityEventSummary
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI.partyModeReplace
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc
Expand Down Expand Up @@ -174,8 +175,8 @@ object ChocolateFactoryStrayTracker {

add(
Renderable.hoverTips(
"§6§lStray Tracker",
tips = listOf("§a+§b$formattedExtraTime §afrom strays§7"),
"§6§lStray Tracker".partyModeReplace(),
tips = listOf("§a+§b$formattedExtraTime §afrom strays§7".partyModeReplace()),
).toSearchable(),
)
HoppityAPI.hoppityRarities.forEach { rarity ->
Expand All @@ -192,12 +193,12 @@ object ChocolateFactoryStrayTracker {

val colorCode = rarity.chatColorCode
val lineHeader = "$colorCode${rarity.toString().lowercase().replaceFirstChar { it.uppercase() }}§7: §r$colorCode"
val lineFormat = "$lineHeader$caughtString"
val lineFormat = "$lineHeader$caughtString".partyModeReplace()

val renderable = rarityExtraChocMs?.let {
var tip = "§a+§b$extraChocFormat §afrom $colorCode${rarity.toString().lowercase()} strays§7"
if (rarity == LEGENDARY) tip += extractGoldenTypesCaught(data)
Renderable.hoverTips(Renderable.string(lineFormat), tips = tip.split("\n"))
Renderable.hoverTips(Renderable.string(lineFormat), tips = tip.partyModeReplace().split("\n"))
} ?: Renderable.string(lineFormat)
return renderable.toSearchable(rarity.toString())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactor
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.InventoryUtils
import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems
import at.hannibal2.skyhanni.utils.ItemUtils.getSingleLineLore
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.ItemUtils.name
Expand All @@ -28,7 +28,9 @@ import at.hannibal2.skyhanni.utils.SpecialColor.toSpecialColorInt
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.Gui
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.inventory.ContainerChest
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.sin

Expand All @@ -37,6 +39,9 @@ object ChocolateFactoryStrayWarning {

private val config get() = ChocolateFactoryAPI.config
private val warningConfig get() = config.rabbitWarning
private const val CHROMA_COLOR = "249:255:255:85:85"
private const val CHROMA_COLOR_ALT = "246:255:255:85:85"
private const val CHROMA_COLOR_ALT2 = "243:255:255:85:85"

private var flashScreen = false
private var activeStraySlots: Set<Int> = setOf()
Expand Down Expand Up @@ -85,7 +90,23 @@ object ChocolateFactoryStrayWarning {

@SubscribeEvent
fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
InventoryUtils.getItemsInOpenChest().filter {
if (!ChocolateFactoryAPI.inChocolateFactory) return
if (config.partyMode.get()) event.partyModeHighlight()
else event.strayHighlight()
}

private fun GuiContainerEvent.BackgroundDrawnEvent.partyModeHighlight() {
val eventChest = (gui.inventorySlots as ContainerChest)
eventChest.getUpperItems().keys.forEach { it highlight CHROMA_COLOR_ALT.toSpecialColor() }
eventChest.inventorySlots.filter {
it.slotNumber != it.slotIndex
}.forEach {
it highlight CHROMA_COLOR_ALT2.toSpecialColor()
}
}

private fun GuiContainerEvent.BackgroundDrawnEvent.strayHighlight() {
(gui.inventorySlots as ContainerChest).getUpperItems().keys.filter {
it.slotNumber in activeStraySlots
}.forEach {
it highlight warningConfig.inventoryHighlightColor.toSpecialColor()
Expand Down Expand Up @@ -132,13 +153,14 @@ object ChocolateFactoryStrayWarning {
flashScreen = false
}

@SubscribeEvent
@SubscribeEvent(priority = EventPriority.HIGHEST)
fun onRender(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) {
if (!ChocolateFactoryAPI.inChocolateFactory) return
if (!flashScreen) return
if (!flashScreen && !config.partyMode.get()) return
val minecraft = Minecraft.getMinecraft()
val alpha = ((2 + sin(System.currentTimeMillis().toDouble() / 1000)) * 255 / 4).toInt().coerceIn(0..255)
val color = (alpha shl 24) or (config.rabbitWarning.flashColor.toSpecialColorInt() and 0xFFFFFF)
val toUse = if (config.partyMode.get()) CHROMA_COLOR else warningConfig.flashColor
val color = (alpha shl 24) or (toUse.toSpecialColorInt() and 0xFFFFFF)
Gui.drawRect(0, 0, minecraft.displayWidth, minecraft.displayHeight, color)
GlStateManager.color(1F, 1F, 1F, 1F)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI.partyModeReplace
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.getOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
Expand All @@ -28,7 +29,7 @@ object ChocolateFactoryTooltipCompact {
if (config.tooltipMove) {
if (event.slot.slotNumber <= 44) {
lastHover = SimpleTimeMark.now()
tooltipToHover = event.toolTip.toList()
tooltipToHover = event.toolTip.toList().map { it.partyModeReplace() }
event.cancel()
} else {
lastHover = SimpleTimeMark.farPast()
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ object InventoryUtils {
}
}

fun ContainerChest.getAllSlots(): Map<Slot, ItemStack?> = buildMap {
for (slot in inventorySlots) {
if (slot == null) continue
this[slot] = slot.stack
}
}

fun getItemAtSlotIndex(slotIndex: Int): ItemStack? = getSlotAtIndex(slotIndex)?.stack

fun getSlotAtIndex(slotIndex: Int): Slot? = getItemsInOpenChest().find { it.slotIndex == slotIndex }
Expand Down
Loading