From adc3a19251866d32194c4e706d4735111e836f0a Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Fri, 29 Nov 2024 21:00:14 +0100 Subject: [PATCH 1/9] move next jacob contest Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../features/garden/GardenNextJacobContest.kt | 142 +++++++++--------- 1 file changed, 69 insertions(+), 73 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index 81ad4f2fe1f0..9a4cb7dd38ab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -12,17 +12,19 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent -import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon +import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIconRenderable import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.APIUtils import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -33,6 +35,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.json.toJsonArray +import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.Gson import com.google.gson.JsonPrimitive @@ -58,7 +61,7 @@ import kotlin.time.Duration.Companion.seconds object GardenNextJacobContest { private val dispatcher = Dispatchers.IO - private var display = emptyList() + private var display: Renderable? = null private var simpleDisplay = emptyList() var contests = mutableMapOf() private var inCalendar = false @@ -66,7 +69,7 @@ object GardenNextJacobContest { private val patternGroup = RepoPattern.group("garden.nextcontest") val dayPattern by patternGroup.pattern( "day", - "§aDay (?.*)" + "§aDay (?.*)", ) /** @@ -76,11 +79,11 @@ object GardenNextJacobContest { */ val monthPattern by patternGroup.pattern( "month", - "(?(?:\\w+ )?(?:Summer|Spring|Winter|Autumn)), Year (?\\d+)" + "(?(?:\\w+ )?(?:Summer|Spring|Winter|Autumn)), Year (?\\d+)", ) private val cropPattern by patternGroup.pattern( "crop", - "§(?:e○|6☘) §7(?.*)" + "§(?:e○|6☘) §7(?.*)", ) private const val CLOSE_TO_NEW_YEAR_TEXT = "§7Close to new SB year!" @@ -110,7 +113,7 @@ object GardenNextJacobContest { add("Current time: ${SimpleTimeMark.now()}") add("") - val display = display.filterIsInstance().joinToString("") + // TODO Renderable.toString() add("Display: '$display'") add("") @@ -253,7 +256,7 @@ object GardenNextJacobContest { "§2Click here to submit this year's farming contests. Thank you for helping everyone out!", onClick = { shareContests() }, "§eClick to submit!", - oneTimeClick = true + oneTimeClick = true, ) } } @@ -309,7 +312,7 @@ object GardenNextJacobContest { ChatUtils.chat("§2Enabled automatic sharing of future contests!") }, "§eClick to enable autosharing!", - oneTimeClick = true + oneTimeClick = true, ) } } @@ -327,82 +330,76 @@ object GardenNextJacobContest { } display = if (isFetchingContests) { - listOf("§cFetching this years jacob contests...") + Renderable.string("§cFetching this years jacob contests...") } else { fetchContestsIfAble() // Will only run when needed/enabled drawDisplay() } } - private fun drawDisplay(): List { - val list = mutableListOf() + private fun drawDisplay() = Renderable.horizontalContainer( + buildList { + if (inCalendar) { + val size = contests.size + val percentage = size.toDouble() / MAX_CONTESTS_PER_YEAR + val formatted = LorenzUtils.formatPercentage(percentage) + addString("§eDetected $formatted of farming contests this year") + return@buildList + } - if (inCalendar) { - val size = contests.size - val percentage = size.toDouble() / MAX_CONTESTS_PER_YEAR - val formatted = LorenzUtils.formatPercentage(percentage) - list.add("§eDetected $formatted of farming contests this year") + if (contests.isEmpty()) { + if (isCloseToNewYear()) { + addString(CLOSE_TO_NEW_YEAR_TEXT) + } else { + addString("§cOpen calendar to read Jacob contest times!") + } + return@buildList + } - return list - } + val nextContest = contests.values.filterNot { it.endTime.isInPast() }.minByOrNull { it.endTime } + + // Show next contest + if (nextContest != null) { + addAll(drawNextContest(nextContest)) + return@buildList + } - if (contests.isEmpty()) { if (isCloseToNewYear()) { - list.add(CLOSE_TO_NEW_YEAR_TEXT) + addString(CLOSE_TO_NEW_YEAR_TEXT) } else { - list.add("§cOpen calendar to read Jacob contest times!") + addString("§cOpen calendar to read Jacob contest times!") } - return list - } - val nextContest = - contests.filter { !it.value.endTime.isInPast() }.toSortedMap() - .firstNotNullOfOrNull { it.value } - // Show next contest - if (nextContest != null) return drawNextContest(nextContest, list) - - if (isCloseToNewYear()) { - list.add(CLOSE_TO_NEW_YEAR_TEXT) - } else { - list.add("§cOpen calendar to read Jacob contest times!") - } - - fetchedFromElite = false - contests.clear() + fetchedFromElite = false + contests.clear() + }, + ) - return list - } - private fun drawNextContest( - nextContest: FarmingContest, - list: MutableList, - ): MutableList { + private fun drawNextContest(nextContest: FarmingContest) = buildList { var duration = nextContest.endTime.timeUntil() if (duration > 4.days) { - list.add(CLOSE_TO_NEW_YEAR_TEXT) - return list + addString(CLOSE_TO_NEW_YEAR_TEXT) + return@buildList } val boostedCrop = calculateBoostedCrop(nextContest) val activeContest = duration < contestDuration if (activeContest) { - list.add("§aActive: ") + addString("§aActive: ") } else { - list.add("§eNext: ") + addString("§eNext: ") duration -= contestDuration } for (crop in nextContest.crops) { - list.addCropIcon(crop, 1.0, highlight = (crop == boostedCrop)) + addCropIconRenderable(crop, 1.0, highlight = (crop == boostedCrop)) nextContestCrops.add(crop) } if (!activeContest) { warn(duration, nextContest.crops, boostedCrop) } - val format = duration.format() - list.add("§7(§b$format§7)") - - return list + addString("§7(§b${duration.format()}§7)") } private fun calculateBoostedCrop(nextContest: FarmingContest): CropType? { @@ -438,10 +435,7 @@ object GardenNextJacobContest { } if (config.warnPopup && !Display.isActive()) { SkyHanniMod.coroutineScope.launch { - openPopupWindow( - "Farming Contest soon!
" + - "Crops: $cropTextNoColor" - ) + openPopupWindow("Farming Contest soon!
Crops: $cropTextNoColor") } } } @@ -455,7 +449,7 @@ object GardenNextJacobContest { } catch (e: java.lang.Exception) { ErrorManager.logErrorWithData( e, "Failed to open a popup window", - "message" to message + "message" to message, ) } @@ -467,11 +461,13 @@ object GardenNextJacobContest { val buttons = mutableListOf() val close = JButton("Ok") - close.addMouseListener(object : MouseAdapter() { - override fun mouseClicked(event: MouseEvent) { - frame.isVisible = false - } - }) + close.addMouseListener( + object : MouseAdapter() { + override fun mouseClicked(event: MouseEvent) { + frame.isVisible = false + } + }, + ) buttons.add(close) val allOptions = buttons.toTypedArray() @@ -483,7 +479,7 @@ object GardenNextJacobContest { JOptionPane.INFORMATION_MESSAGE, null, allOptions, - allOptions[0] + allOptions[0], ) } @@ -493,10 +489,10 @@ object GardenNextJacobContest { fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return - if (display.isEmpty()) { + if (display == null) { config.pos.renderStrings(simpleDisplay, posLabel = "Next Jacob Contest") } else { - config.pos.renderSingleLineWithItems(display, posLabel = "Next Jacob Contest") + config.pos.renderRenderable(display, posLabel = "Next Jacob Contest") } } @@ -505,10 +501,10 @@ object GardenNextJacobContest { if (!config.display) return if (!inCalendar) return - if (display.isNotEmpty()) { - SkyHanniMod.feature.misc.inventoryLoadPos.renderSingleLineWithItems( + if (display != null) { + SkyHanniMod.feature.misc.inventoryLoadPos.renderRenderable( display, - posLabel = "Load SkyBlock Calendar" + posLabel = "Load SkyBlock Calendar", ) } } @@ -566,12 +562,12 @@ object GardenNextJacobContest { } else { ChatUtils.chat( "This year's contests aren't available to fetch automatically yet, " + - "please load them from your calendar or wait 10 minutes." + "please load them from your calendar or wait 10 minutes.", ) ChatUtils.clickableChat( "Click here to open your calendar!", onClick = { HypixelCommands.calendar() }, - "§eClick to run /calendar!" + "§eClick to run /calendar!", ) } @@ -588,7 +584,7 @@ object GardenNextJacobContest { } catch (e: Exception) { ErrorManager.logErrorWithData( e, - "Failed to fetch upcoming contests. Please report this error if it continues to occur" + "Failed to fetch upcoming contests. Please report this error if it continues to occur", ) } @@ -624,13 +620,13 @@ object GardenNextJacobContest { } else { ErrorManager.logErrorStateWithData( "Something went wrong submitting upcoming contests!", - "submitContestsToElite not successful" + "submitContestsToElite not successful", ) } } catch (e: Exception) { ErrorManager.logErrorWithData( e, "Failed to submit upcoming contests. Please report this error if it continues to occur.", - "contests" to contests + "contests" to contests, ) null } From a28b574574f02c8ddc062c108717b4f5b67e79da Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Fri, 29 Nov 2024 21:10:47 +0100 Subject: [PATCH 2/9] move garden best crop display Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../skyhanni/features/garden/GardenAPI.kt | 8 - .../garden/farming/GardenBestCropTime.kt | 142 +++++++++--------- .../farming/GardenCropMilestoneDisplay.kt | 20 +-- 3 files changed, 83 insertions(+), 87 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index 460b112540c6..bf8dcdd1ae4a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -172,14 +172,6 @@ object GardenAPI { fun readCounter(itemStack: ItemStack): Long = itemStack.getHoeCounter() ?: itemStack.getCultivatingCounter() ?: -1L - @Deprecated("use renderable list instead", ReplaceWith("")) - fun MutableList.addCropIcon( - crop: CropType, - scale: Double = NEUItems.itemFontSize, - highlight: Boolean = false, - ) = - addItemIcon(crop.icon.copy(), highlight, scale = scale) - // TODO rename to addCropIcon fun MutableList.addCropIconRenderable( crop: CropType, diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt index e8ca52ac8485..84435ef6258e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt @@ -8,22 +8,23 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter import at.hannibal2.skyhanni.data.GardenCropMilestones.isMaxed import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon +import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIconRenderable import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds @SkyHanniModule object GardenBestCropTime { - var display = emptyList>() + var display: Renderable? = null private val config get() = GardenAPI.config.cropMilestones val timeTillNextCrop = mutableMapOf() @@ -56,83 +57,86 @@ object GardenBestCropTime { } } - fun drawBestDisplay(currentCrop: CropType?): List> { - val newList = mutableListOf>() - if (timeTillNextCrop.size < CropType.entries.size) { - updateTimeTillNextCrop() - } - - val gardenExp = config.next.bestType == NextConfig.BestTypeEntry.GARDEN_EXP - val useOverflow = config.overflow.bestCropTime - val sorted = if (gardenExp) { - val helpMap = mutableMapOf() - for ((crop, time) in timeTillNextCrop) { - if (crop.isMaxed(useOverflow)) continue - val currentTier = - GardenCropMilestones.getTierForCropCount(crop.getCounter(), crop, allowOverflow = true) - val gardenExpForTier = getGardenExpForTier(currentTier + 1) - val fakeTime = time / gardenExpForTier - helpMap[crop] = fakeTime + fun drawBestDisplay(currentCrop: CropType?) = Renderable.verticalContainer( + buildList { + if (timeTillNextCrop.size < CropType.entries.size) { + updateTimeTillNextCrop() } - helpMap.sorted() - } else { - timeTillNextCrop.sorted() - } - - if (!config.next.bestHideTitle) { - val title = if (gardenExp) "§2Garden Experience" else "§bSkyBlock Level" - if (config.next.bestCompact) { - newList.addAsSingletonList("§eBest Crop Time") + val gardenExp = config.next.bestType == NextConfig.BestTypeEntry.GARDEN_EXP + val useOverflow = config.overflow.bestCropTime + val sorted = if (gardenExp) { + val helpMap = mutableMapOf() + for ((crop, time) in timeTillNextCrop) { + if (crop.isMaxed(useOverflow)) continue + val currentTier = + GardenCropMilestones.getTierForCropCount(crop.getCounter(), crop, allowOverflow = true) + val gardenExpForTier = getGardenExpForTier(currentTier + 1) + val fakeTime = time / gardenExpForTier + helpMap[crop] = fakeTime + } + helpMap.sorted() } else { - newList.addAsSingletonList("§eBest Crop Time §7($title§7)") + timeTillNextCrop.sorted() } - } - if (!config.progress) { - newList.addAsSingletonList("§cCrop Milestone Progress Display is disabled!") - return newList - } - if (sorted.isEmpty()) { - newList.addAsSingletonList("§cFarm crops to add them to this list!") - return newList - } - - var number = 0 - for (crop in sorted.keys) { - if (crop.isMaxed(useOverflow)) continue - val millis = timeTillNextCrop[crop]?.milliseconds ?: continue - // TODO, change functionality to use enum rather than ordinals - val biggestUnit = TimeUnit.entries[config.highestTimeFormat.get().ordinal] - val duration = millis.format(biggestUnit, maxUnits = 2) - val isCurrent = crop == currentCrop - number++ - if (number > config.next.showOnlyBest && (!config.next.showCurrent || !isCurrent)) continue - - val list = mutableListOf() - if (!config.next.bestCompact) { - list.add("§7$number# ") + if (!config.next.bestHideTitle) { + val title = if (gardenExp) "§2Garden Experience" else "§bSkyBlock Level" + if (config.next.bestCompact) { + addString("§eBest Crop Time") + } else { + addString("§eBest Crop Time §7($title§7)") + } } - list.addCropIcon(crop) - val color = if (isCurrent) "§e" else "§7" - val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" - val currentTier = GardenCropMilestones.getTierForCropCount(crop.getCounter(), crop, allowOverflow = true) - val nextTier = if (config.bestShowMaxedNeeded.get()) 46 else currentTier + 1 + if (!config.progress) { + addString("§cCrop Milestone Progress Display is disabled!") + return@buildList + } - val cropName = if (!config.next.bestCompact) crop.cropName + " " else "" - val tier = if (!config.next.bestCompact) "$currentTier➜$nextTier§r " else "" - list.add("$color$contestFormat$cropName$tier§b$duration") + if (sorted.isEmpty()) { + addString("§cFarm crops to add them to this list!") + return@buildList + } - if (gardenExp && !config.next.bestCompact) { - val gardenExpForTier = getGardenExpForTier(nextTier) - list.add(" §7(§2$gardenExpForTier §7Exp)") + var number = 0 + for (crop in sorted.keys) { + if (crop.isMaxed(useOverflow)) continue + val millis = timeTillNextCrop[crop]?.milliseconds ?: continue + // TODO, change functionality to use enum rather than ordinals + val biggestUnit = TimeUnit.entries[config.highestTimeFormat.get().ordinal] + val duration = millis.format(biggestUnit, maxUnits = 2) + val isCurrent = crop == currentCrop + number++ + if (number > config.next.showOnlyBest && (!config.next.showCurrent || !isCurrent)) continue + + val line = Renderable.horizontalContainer( + buildList { + if (!config.next.bestCompact) { + addString("§7$number# ") + } + addCropIconRenderable(crop) + + val color = if (isCurrent) "§e" else "§7" + val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" + val currentTier = GardenCropMilestones.getTierForCropCount(crop.getCounter(), crop, allowOverflow = true) + val nextTier = if (config.bestShowMaxedNeeded.get()) 46 else currentTier + 1 + + val cropName = if (!config.next.bestCompact) crop.cropName + " " else "" + val tier = if (!config.next.bestCompact) "$currentTier➜$nextTier§r " else "" + addString("$color$contestFormat$cropName$tier§b$duration") + + if (gardenExp && !config.next.bestCompact) { + val gardenExpForTier = getGardenExpForTier(nextTier) + addString(" §7(§2$gardenExpForTier §7Exp)") + } + }, + ) + add(line) } - newList.add(list) - } - return newList - } + }, + ) private fun getGardenExpForTier(gardenLevel: Int) = if (gardenLevel > 30) 300 else gardenLevel * 10 diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index 734df7630c47..18ad37c5bcf3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -29,8 +29,8 @@ import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.roundTo +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUnit @@ -77,17 +77,17 @@ object GardenCropMilestoneDisplay { if (GardenAPI.hideExtraGuis()) return config.progressDisplayPos.renderRenderables( - progressDisplay, posLabel = "Crop Milestone Progress" + progressDisplay, posLabel = "Crop Milestone Progress", ) if (config.mushroomPetPerk.enabled) { config.mushroomPetPerk.pos.renderRenderables( - mushroomCowPerkDisplay, posLabel = "Mushroom Cow Perk" + mushroomCowPerkDisplay, posLabel = "Mushroom Cow Perk", ) } if (config.next.bestDisplay) { - config.next.displayPos.renderStringsAndItems(GardenBestCropTime.display, posLabel = "Best Crop Time") + config.next.displayPos.renderRenderable(GardenBestCropTime.display, posLabel = "Best Crop Time") } } @@ -132,7 +132,7 @@ object GardenCropMilestoneDisplay { fun update() { progressDisplay = emptyList() mushroomCowPerkDisplay = emptyList() - GardenBestCropTime.display = emptyList() + GardenBestCropTime.display = null val currentCrop = GardenAPI.getCurrentlyFarmedCrop() currentCrop?.let { progressDisplay = drawProgressDisplay(it) @@ -165,7 +165,7 @@ object GardenCropMilestoneDisplay { } else { addString("§7" + crop.cropName + " §8$currentTier➜§3$nextTier") } - } + }, ) val allowOverflowOrCustom = overflowDisplay || useCustomGoal @@ -309,7 +309,7 @@ object GardenCropMilestoneDisplay { buildList { addCropIconRenderable(mushroom) addString("§7Mushroom Milestone $nextTier") - } + }, ) lineMap[MushroomTextEntry.NUMBER_OUT_OF_TOTAL] = Renderable.string("§e$haveFormat§8/§e$needFormat") @@ -357,21 +357,21 @@ object GardenCropMilestoneDisplay { event.move( 11, "garden.cropMilestones.highestTimeFormat", - "garden.cropMilestones.highestTimeFormat" + "garden.cropMilestones.highestTimeFormat", ) { element -> ConfigUtils.migrateIntToEnum(element, TimeFormatEntry::class.java) } event.move( 11, "garden.cropMilestones.text", - "garden.cropMilestones.text" + "garden.cropMilestones.text", ) { element -> ConfigUtils.migrateIntArrayListToEnumArrayList(element, MilestoneTextEntry::class.java) } event.move( 11, "garden.cropMilestones.mushroomPetPerk.text", - "garden.cropMilestones.mushroomPetPerk.text" + "garden.cropMilestones.mushroomPetPerk.text", ) { element -> ConfigUtils.migrateIntArrayListToEnumArrayList(element, MushroomTextEntry::class.java) } From d280b48ad4f3967cb215e014d5923205b55afa26 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Fri, 29 Nov 2024 21:11:48 +0100 Subject: [PATCH 3/9] rename method Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt | 3 +-- .../skyhanni/features/garden/GardenNextJacobContest.kt | 5 ++--- .../skyhanni/features/garden/farming/GardenBestCropTime.kt | 4 ++-- .../features/garden/farming/GardenCropMilestoneDisplay.kt | 3 ++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index bf8dcdd1ae4a..22860691d7ab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -172,8 +172,7 @@ object GardenAPI { fun readCounter(itemStack: ItemStack): Long = itemStack.getHoeCounter() ?: itemStack.getCultivatingCounter() ?: -1L - // TODO rename to addCropIcon - fun MutableList.addCropIconRenderable( + fun MutableList.addCropIcon( crop: CropType, scale: Double = NEUItems.itemFontSize, highlight: Boolean = false, diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index 9a4cb7dd38ab..e650cb2ae98f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -12,7 +12,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent -import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIconRenderable +import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.APIUtils @@ -25,7 +25,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable -import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark @@ -393,7 +392,7 @@ object GardenNextJacobContest { duration -= contestDuration } for (crop in nextContest.crops) { - addCropIconRenderable(crop, 1.0, highlight = (crop == boostedCrop)) + addCropIcon(crop, 1.0, highlight = (crop == boostedCrop)) nextContestCrops.add(crop) } if (!activeContest) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt index 84435ef6258e..536b527e8f94 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter import at.hannibal2.skyhanni.data.GardenCropMilestones.isMaxed import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIconRenderable +import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -116,7 +116,7 @@ object GardenBestCropTime { if (!config.next.bestCompact) { addString("§7$number# ") } - addCropIconRenderable(crop) + addCropIcon(crop) val color = if (isCurrent) "§e" else "§7" val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index 18ad37c5bcf3..5107d40de3cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIconRenderable import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.setSpeed @@ -307,7 +308,7 @@ object GardenCropMilestoneDisplay { lineMap[MushroomTextEntry.TITLE] = Renderable.string("§6Mooshroom Cow Perk") lineMap[MushroomTextEntry.MUSHROOM_TIER] = Renderable.horizontalContainer( buildList { - addCropIconRenderable(mushroom) + addCropIcon(mushroom) addString("§7Mushroom Milestone $nextTier") }, ) From 72398cf1f5ae526806102901c15bdce72bbd50db Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Fri, 29 Nov 2024 21:13:05 +0100 Subject: [PATCH 4/9] fix rename method Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../features/garden/farming/GardenCropMilestoneDisplay.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index 5107d40de3cb..9781c51c5413 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -19,7 +19,6 @@ import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon -import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIconRenderable import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.setSpeed import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -160,7 +159,7 @@ object GardenCropMilestoneDisplay { lineMap[MilestoneTextEntry.MILESTONE_TIER] = Renderable.horizontalContainer( buildList { - addCropIconRenderable(crop) + addCropIcon(crop) if (crop.isMaxed(overflowDisplay) && !overflowDisplay) { addString("§7" + crop.cropName + " §eMAXED") } else { From 60a15b4745f0f0af7739e8a043883eb95743f2bf Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Fri, 29 Nov 2024 21:30:40 +0100 Subject: [PATCH 5/9] i love detekt so much Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../skyhanni/features/garden/GardenAPI.kt | 1 - .../garden/farming/GardenBestCropTime.kt | 70 ++++++++++--------- versions/1.8.9/detekt/baseline.xml | 4 +- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index 22860691d7ab..b97a71f261ba 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -41,7 +41,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.RenderUtils.addItemIcon import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getCultivatingCounter import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHoeCounter import at.hannibal2.skyhanni.utils.renderables.Renderable diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt index 536b527e8f94..cf10a266576d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt @@ -100,44 +100,46 @@ object GardenBestCropTime { return@buildList } - var number = 0 - for (crop in sorted.keys) { - if (crop.isMaxed(useOverflow)) continue - val millis = timeTillNextCrop[crop]?.milliseconds ?: continue - // TODO, change functionality to use enum rather than ordinals - val biggestUnit = TimeUnit.entries[config.highestTimeFormat.get().ordinal] - val duration = millis.format(biggestUnit, maxUnits = 2) - val isCurrent = crop == currentCrop - number++ - if (number > config.next.showOnlyBest && (!config.next.showCurrent || !isCurrent)) continue - - val line = Renderable.horizontalContainer( - buildList { - if (!config.next.bestCompact) { - addString("§7$number# ") - } - addCropIcon(crop) - - val color = if (isCurrent) "§e" else "§7" - val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" - val currentTier = GardenCropMilestones.getTierForCropCount(crop.getCounter(), crop, allowOverflow = true) - val nextTier = if (config.bestShowMaxedNeeded.get()) 46 else currentTier + 1 - - val cropName = if (!config.next.bestCompact) crop.cropName + " " else "" - val tier = if (!config.next.bestCompact) "$currentTier➜$nextTier§r " else "" - addString("$color$contestFormat$cropName$tier§b$duration") - - if (gardenExp && !config.next.bestCompact) { - val gardenExpForTier = getGardenExpForTier(nextTier) - addString(" §7(§2$gardenExpForTier §7Exp)") - } - }, - ) - add(line) + sorted.keys.withIndex().forEach { (index, crop) -> + createCropEntry(crop, index, useOverflow, gardenExp, currentCrop)?.let(::add) } }, ) + private fun createCropEntry(crop: CropType, index: Int, useOverflow: Boolean, gardenExp: Boolean, currentCrop: CropType?): Renderable? { + if (crop.isMaxed(useOverflow)) return null + val millis = timeTillNextCrop[crop]?.milliseconds ?: return null + // TODO, change functionality to use enum rather than ordinals + val biggestUnit = TimeUnit.entries[config.highestTimeFormat.get().ordinal] + val duration = millis.format(biggestUnit, maxUnits = 2) + val isCurrent = crop == currentCrop + val index = index + 1 + if (index > config.next.showOnlyBest && (!config.next.showCurrent || !isCurrent)) return null + + return Renderable.horizontalContainer( + buildList { + if (!config.next.bestCompact) { + addString("§7$index# ") + } + addCropIcon(crop) + + val color = if (isCurrent) "§e" else "§7" + val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" + val currentTier = GardenCropMilestones.getTierForCropCount(crop.getCounter(), crop, allowOverflow = true) + val nextTier = if (config.bestShowMaxedNeeded.get()) 46 else currentTier + 1 + + val cropName = if (!config.next.bestCompact) crop.cropName + " " else "" + val tier = if (!config.next.bestCompact) "$currentTier➜$nextTier§r " else "" + addString("$color$contestFormat$cropName$tier§b$duration") + + if (gardenExp && !config.next.bestCompact) { + val gardenExpForTier = getGardenExpForTier(nextTier) + addString(" §7(§2$gardenExpForTier §7Exp)") + } + }, + ) + } + private fun getGardenExpForTier(gardenLevel: Int) = if (gardenLevel > 30) 300 else gardenLevel * 10 @SubscribeEvent diff --git a/versions/1.8.9/detekt/baseline.xml b/versions/1.8.9/detekt/baseline.xml index 7c698661cd00..b803dae7a3bb 100644 --- a/versions/1.8.9/detekt/baseline.xml +++ b/versions/1.8.9/detekt/baseline.xml @@ -174,8 +174,8 @@ RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.name", "Garden (?:Desk|Level (?<currentLevel>.*))" ) RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.nextxp", ".* §e(?<nextLevelExp>.*)§6/.*" ) RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.overflow", ".*§r §6(?<overflow>.*)" ) - RepoPatternRegexTest:GardenNextJacobContest.kt$GardenNextJacobContest$by patternGroup.pattern( "crop", "§(?:e○|6☘) §7(?<crop>.*)" ) - RepoPatternRegexTest:GardenNextJacobContest.kt$GardenNextJacobContest$by patternGroup.pattern( "day", "§aDay (?<day>.*)" ) + RepoPatternRegexTest:GardenNextJacobContest.kt$GardenNextJacobContest$by patternGroup.pattern( "crop", "§(?:e○|6☘) §7(?<crop>.*)", ) + RepoPatternRegexTest:GardenNextJacobContest.kt$GardenNextJacobContest$by patternGroup.pattern( "day", "§aDay (?<day>.*)", ) RepoPatternRegexTest:GardenPlotAPI.kt$GardenPlotAPI$by patternGroup.pattern( "spray.target", "§a§lSPRAYONATOR! §r§7You sprayed §r§aPlot §r§7- §r§b(?<plot>.*) §r§7with §r§a(?<spray>.*)§r§7!" ) RepoPatternRegexTest:GlacitePowderFeatures.kt$GlacitePowderFeatures$by patternGroup.pattern( "glacitepowder", "Glacite Powder x(?<amount>.*)" ) RepoPatternRegexTest:HighlightPlaceableNpcs.kt$HighlightPlaceableNpcs$by patternGroup.pattern( "location", "§7Location: §f\\[§e\\d+§f, §e\\d+§f, §e\\d+§f]", ) From 06f7198a6acaef7e0639c8cd74fa1e437415942a Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Fri, 29 Nov 2024 21:40:37 +0100 Subject: [PATCH 6/9] fuck it get moved aswell Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../features/event/winter/JyrreTimer.kt | 41 ++++++++++--------- .../hannibal2/skyhanni/utils/RenderUtils.kt | 25 +---------- 2 files changed, 23 insertions(+), 43 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt index fdabf8733132..45e3ead1ffbe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt @@ -6,13 +6,15 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.CollectionUtils.addItemStack +import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.RegexUtils.matches -import at.hannibal2.skyhanni.utils.RenderUtils.addItemIcon -import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes @@ -24,9 +26,9 @@ object JyrreTimer { private val config get() = SkyHanniMod.feature.event.winter.jyrreTimer private val drankBottlePattern by RepoPattern.pattern( "event.winter.drank.jyrre", - "§aYou drank a §r§6Refined Bottle of Jyrre §r§aand gained §r§b\\+300✎ Intelligence §r§afor §r§b60 minutes§r§a!" + "§aYou drank a §r§6Refined Bottle of Jyrre §r§aand gained §r§b\\+300✎ Intelligence §r§afor §r§b60 minutes§r§a!", ) - private var display = emptyList() + private var display: Renderable? = null private var duration = 0.seconds @SubscribeEvent @@ -35,8 +37,8 @@ object JyrreTimer { } private fun resetDisplay() { - if (display.isEmpty()) return - display = if (config.showInactive) drawDisplay() else emptyList() + if (display == null) return + display = if (config.showInactive) drawDisplay() else null duration = 0.seconds } @@ -49,14 +51,14 @@ object JyrreTimer { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return - config.pos.renderSingleLineWithItems(display, posLabel = "Refined Jyrre Timer") + config.pos.renderRenderable(display, posLabel = "Refined Jyrre Timer") } @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (display.isNotEmpty() && !config.showInactive && duration <= 0.seconds) { + if (display != null && !config.showInactive && duration <= 0.seconds) { resetDisplay() return } @@ -66,20 +68,21 @@ object JyrreTimer { private val displayIcon by lazy { "REFINED_BOTTLE_OF_JYRRE".toInternalName().getItemStack() } - fun drawDisplay(): MutableList { + fun drawDisplay(): Renderable { duration -= 1.seconds - return mutableListOf().apply { - addItemIcon(displayIcon) - add("§aJyrre Boost: ") + return Renderable.horizontalContainer( + buildList { + addItemStack(displayIcon) + addString("§aJyrre Boost: ") - if (duration <= 0.seconds && config.showInactive) { - add("§cInactive!") - } else { - val format = duration.format() - add("§b$format") - } - } + if (duration <= 0.seconds && config.showInactive) { + addString("§cInactive!") + } else { + addString("§b${duration.format()}") + } + }, + ) } private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 1f13c86f5b65..7c113c0a2a7e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -13,12 +13,11 @@ import at.hannibal2.skyhanni.features.misc.PatcherFixes import at.hannibal2.skyhanni.features.misc.RoundedRectangleOutlineShader import at.hannibal2.skyhanni.features.misc.RoundedRectangleShader import at.hannibal2.skyhanni.features.misc.RoundedTextureShader -import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.zipWithNext3 import at.hannibal2.skyhanni.utils.ColorUtils.getFirstColorCode import at.hannibal2.skyhanni.utils.LorenzColor.Companion.toLorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils.getCorners -import at.hannibal2.skyhanni.utils.compat.EnchantmentsCompat +import at.hannibal2.skyhanni.utils.RenderUtils.drawRoundRect import at.hannibal2.skyhanni.utils.compat.GuiScreenUtils import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned @@ -36,7 +35,6 @@ import net.minecraft.client.renderer.WorldRenderer import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.entity.Entity import net.minecraft.inventory.Slot -import net.minecraft.item.ItemStack import net.minecraft.util.AxisAlignedBB import net.minecraft.util.MathHelper import net.minecraft.util.ResourceLocation @@ -686,27 +684,6 @@ object RenderUtils { return offsetX } - @Deprecated("use renderable item list", ReplaceWith("")) - fun MutableList.addItemIcon( - item: ItemStack, - highlight: Boolean = false, - scale: Double = NEUItems.itemFontSize, - ) { - try { - if (highlight) { - // Hack to add enchant glint, like Hypixel does it - item.addEnchantment(EnchantmentsCompat.PROTECTION.enchantment, 0) - } - add(Renderable.itemStack(item, scale)) - } catch (e: NullPointerException) { - ErrorManager.logErrorWithData( - e, - "Add item icon to renderable list", - "item" to item, - ) - } - } - // totally not modified Autumn Client's TargetStrafe fun drawCircle(entity: Entity, partialTicks: Float, rad: Double, color: Color) { GlStateManager.pushMatrix() From 4145190fa4dc253321e382623c66c343cfa09804 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Fri, 29 Nov 2024 21:41:57 +0100 Subject: [PATCH 7/9] no, index++ doesnt work here Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../skyhanni/features/garden/farming/GardenBestCropTime.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt index cf10a266576d..ef0523a46a16 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt @@ -101,7 +101,7 @@ object GardenBestCropTime { } sorted.keys.withIndex().forEach { (index, crop) -> - createCropEntry(crop, index, useOverflow, gardenExp, currentCrop)?.let(::add) + createCropEntry(crop, index + 1, useOverflow, gardenExp, currentCrop)?.let(::add) } }, ) @@ -113,7 +113,6 @@ object GardenBestCropTime { val biggestUnit = TimeUnit.entries[config.highestTimeFormat.get().ordinal] val duration = millis.format(biggestUnit, maxUnits = 2) val isCurrent = crop == currentCrop - val index = index + 1 if (index > config.next.showOnlyBest && (!config.next.showCurrent || !isCurrent)) return null return Renderable.horizontalContainer( From f99435fe9a4f5fe686d39324d25b4ae53910ef57 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Fri, 29 Nov 2024 21:57:23 +0100 Subject: [PATCH 8/9] move additemstack next to each other Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/utils/CollectionUtils.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt index 3e3b6e394a06..18bc0b7f670f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt @@ -312,15 +312,15 @@ object CollectionUtils { add(Renderable.itemStack(itemStack, scale = scale)) } + fun MutableList.addItemStack(internalName: NEUInternalName) { + addItemStack(internalName.getItemStack()) + } + fun takeColumn(start: Int, end: Int, startColumn: Int, endColumn: Int, rowSize: Int = 9) = generateSequence(start) { it + 1 }.map { (it / (endColumn - startColumn)) * rowSize + (it % (endColumn - startColumn)) + startColumn }.takeWhile { it <= end } - fun MutableList.addItemStack(internalName: NEUInternalName) { - addItemStack(internalName.getItemStack()) - } - // TODO move to RenderableUtils inline fun > MutableList.addSelector( prefix: String, From 1730c279e718593358ec63f7179474a5256cc693 Mon Sep 17 00:00:00 2001 From: appable <16139460+appable0@users.noreply.github.com> Date: Sat, 14 Dec 2024 00:12:19 -0800 Subject: [PATCH 9/9] remove renderSingleLineWithItems --- .../event/anniversary/Year300RaffleEvent.kt | 17 ++++----- .../hannibal2/skyhanni/utils/RenderUtils.kt | 37 ------------------- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt index 134e09d09b21..fe60f02fc771 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SkyBlockTime import at.hannibal2.skyhanni.utils.SoundUtils @@ -29,7 +29,7 @@ object Year300RaffleEvent { private var lastTimerReceived = SimpleTimeMark.farPast() private var lastTimeAlerted = SimpleTimeMark.farPast() - private var overlay: List? = null + private var overlay: Renderable? = null @SubscribeEvent fun onChat(event: LorenzChatEvent) { @@ -43,10 +43,7 @@ object Year300RaffleEvent { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { - config.activeTimerPosition.renderSingleLineWithItems( - overlay ?: return, - posLabel = "300þ Anniversary Active Timer" - ) + config.activeTimerPosition.renderRenderable(overlay, posLabel = "300þ Anniversary Active Timer") } @SubscribeEvent @@ -65,9 +62,11 @@ object Year300RaffleEvent { SoundUtils.centuryActiveTimerAlert.playSound() lastTimeAlerted = SimpleTimeMark.now() } - overlay = listOf( - Renderable.itemStack(displayItem), - Renderable.string("§eTime Left: ${timeLeft.format()}") + overlay = Renderable.verticalContainer( + listOf( + Renderable.itemStack(displayItem), + Renderable.string("§eTime Left: ${timeLeft.format()}") + ) ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index f764d0950bcf..cfefe74581ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -647,43 +647,6 @@ object RenderUtils { this.renderRenderablesDouble(render, extraSpace, posLabel, true) } - /** - * Accepts a single line to print. - * This line is a list of things to print. Can print String or ItemStack objects. - */ - @Deprecated("use List", ReplaceWith("")) - fun Position.renderSingleLineWithItems( - list: List, - posLabel: String, - ) { - if (list.isEmpty()) return - renderRenderable( - Renderable.horizontalContainer( - list.mapNotNull { Renderable.fromAny(it) }, - ), - posLabel = posLabel, - ) - // TODO Future write that better - } - - private fun Position.renderLine(line: List, offsetY: Int, itemScale: Double = NEUItems.itemFontSize): Int { - GlStateManager.pushMatrix() - val (x, y) = transform() - GlStateManager.translate(0f, offsetY.toFloat(), 0F) - var offsetX = 0 - Renderable.withMousePosition(x, y) { - for (any in line) { - val renderable = Renderable.fromAny(any, itemScale = itemScale) - ?: throw RuntimeException("Unknown render object: $any") - renderable.render(offsetX, offsetY) - offsetX += renderable.width - GlStateManager.translate(renderable.width.toFloat(), 0F, 0F) - } - } - GlStateManager.popMatrix() - return offsetX - } - // totally not modified Autumn Client's TargetStrafe fun drawCircle(entity: Entity, partialTicks: Float, rad: Double, color: Color) { GlStateManager.pushMatrix()