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

Improvement: Discrite Held Time #3101

Open
wants to merge 4 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 @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {

val logger = LorenzLogger("ConfigMigration")
const val CONFIG_VERSION = 69
const val CONFIG_VERSION = 70
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ public enum ItemNumberEntry implements HasLegacyId {
LARVA_HOOK("§bLarva Hook", 12),
DUNGEON_POTION_LEVEL("§bDungeon Potion Level", 13),
VACUUM_GARDEN("§bVacuum (Garden)", 14),
BOTTLE_OF_JYRRE("§bBottle Of Jyrre", 15),
DARK_CACAO_TRUFFLE("§bDark Cacao Truffle"),
TIME_POCKET_ITEMS("§bTime Pocket Items (Jyrre, Truffle, Discrite)", 15),
EDITION_NUMBER("§bEdition Number", 16),
ENCHANTING_EXP("§bEnchanting EXP (Superpairs)"),
BINGO_GOAL_RANK("§bBingo Goal Rank"),
Expand Down Expand Up @@ -291,7 +290,7 @@ public String toString() {
public boolean shiftClickBrewing = false;

@Expose
@ConfigOption(name = "Time Held in Lore", desc = "Show time held for Bottle of Jyrre and Dark Cacao Truffle in the lore.")
@ConfigOption(name = "Time Held in Lore", desc = "Show time held for Time Pocket items (Bottle of Jyrre, Dark Cacao Truffle, Discrite) in the lore.")
@ConfigEditorBoolean
@FeatureToggle
public boolean timeHeldInLore = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,24 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrInsert
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getBottleOfJyrreSeconds
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getSecondsHeld
import at.hannibal2.skyhanni.utils.TimeUtils.format
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds

@SkyHanniModule
object HeldTimeInLore {
private val config get() = SkyHanniMod.feature.inventory

private val jyrreBottle by lazy { "NEW_BOTTLE_OF_JYRRE".toInternalName() }
private val cacaoTruffle by lazy { "DARK_CACAO_TRUFFLE".toInternalName() }

@SubscribeEvent
fun onTooltip(event: LorenzToolTipEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!config.timeHeldInLore) return

val seconds = event.itemStack.getSeconds() ?: return
val seconds = event.itemStack.getSecondsHeld() ?: return
val formatted = seconds.seconds.format()

event.toolTip.addOrInsert(10, "§7Time Held: §b$formatted")
}

private fun ItemStack.getSeconds(): Int? = when (getInternalName()) {
jyrreBottle -> getBottleOfJyrreSeconds()
cacaoTruffle -> getSecondsHeld()
else -> null
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BESTIARY_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BINGO_GOAL_RANK
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BOTTLE_OF_JYRRE
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.COLLECTION_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DARK_CACAO_TRUFFLE
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DUNGEON_HEAD_FLOOR_NUMBER
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DUNGEON_POTION_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.EDITION_NUMBER
Expand All @@ -25,6 +23,7 @@ import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumbe
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.RANCHERS_BOOTS_SPEED
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.SKILL_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.SKYBLOCK_LEVEL
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.TIME_POCKET_ITEMS
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.VACUUM_GARDEN
import at.hannibal2.skyhanni.data.PetAPI
import at.hannibal2.skyhanni.events.RenderItemTipEvent
Expand All @@ -49,7 +48,6 @@ import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getBottleOfJyrreSeconds
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEdition
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getNewYearCake
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetLevel
Expand All @@ -59,6 +57,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonPrimitive
import net.minecraft.item.ItemStack

@SkyHanniModule
Expand Down Expand Up @@ -282,14 +281,10 @@ object ItemDisplayOverlayFeatures {
}
}

if (BOTTLE_OF_JYRRE.isSelected() && internalName == "NEW_BOTTLE_OF_JYRRE".toInternalName()) {
val seconds = item.getBottleOfJyrreSeconds() ?: 0
return "§a${(seconds / 3600)}"
}

if (DARK_CACAO_TRUFFLE.isSelected() && internalName == "DARK_CACAO_TRUFFLE".toInternalName()) {
val seconds = item.getSecondsHeld() ?: 0
return "§a${(seconds / 3600)}"
if (TIME_POCKET_ITEMS.isSelected()) {
item.getSecondsHeld()?.let { seconds ->
return "§a${(seconds / 3600)}"
}
}

if (EDITION_NUMBER.isSelected()) {
Expand Down Expand Up @@ -367,6 +362,9 @@ object ItemDisplayOverlayFeatures {
event.transform(29, "inventory.itemNumberAsStackSize") { element ->
fixRemovedConfigElement(element)
}
event.transform(70, "inventory.itemNumberAsStackSize") { element ->
migrateTimePocketItems(element)
}
}

private fun fixRemovedConfigElement(data: JsonElement): JsonElement {
Expand All @@ -379,5 +377,21 @@ object ItemDisplayOverlayFeatures {
return newList
}

private fun migrateTimePocketItems(data: JsonElement): JsonElement {
if (!data.isJsonArray) return data
val newList = JsonArray()
val timePocketItems by lazy { JsonPrimitive("TIME_POCKET_ITEMS") }
for (element in data.asJsonArray) {
if (element.asString in setOf("BOTTLE_OF_JYRRE", "DARK_CACAO_TRUFFLE")) {
if (timePocketItems !in newList) {
newList.add(timePocketItems)
}
continue
}
newList.add(element)
}
return newList
}

fun ItemNumberEntry.isSelected() = config.itemNumberAsStackSize.contains(this)
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,12 @@ object SkyBlockItemModifierUtils {

fun ItemStack.getLivingMetalProgress() = getAttributeInt("lm_evo")

fun ItemStack.getSecondsHeld() = getAttributeInt("seconds_held")

fun ItemStack.getBottleOfJyrreSeconds() = getAttributeInt("bottle_of_jyrre_seconds")
fun ItemStack.getSecondsHeld() = when (getItemId()) {
"NEW_BOTTLE_OF_JYRRE" -> getAttributeInt("bottle_of_jyrre_seconds")
"DARK_CACAO_TRUFFLE" -> getAttributeInt("seconds_held")
"DISCRITE" -> getAttributeInt("rift_discrite_seconds")
else -> null
}

fun ItemStack.getEdition() = getAttributeInt("edition")

Expand Down
Loading