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: Highlight/Hide croesus chests #441

Merged
merged 2 commits into from
Jan 17, 2024
Merged
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
15 changes: 15 additions & 0 deletions src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ object Config : Vigilant(
)
var dungeonChestProfitIncludesEssence = true

@Property(
type = PropertyType.SWITCH, name = "Highlight Unopened Croesus Chests",
description = "Highlight runs in Croesus based on how many more chests can be opened.",
category = "Dungeons", subcategory = "Miscellaneous"
)
var croesusChestHighlight = false

@Property(
type = PropertyType.SWITCH, name = "Hide Opened Croesus Chests",
description = "Hide runs in Croesus if no more chests can be opened.",
category = "Dungeons", subcategory = "Miscellaneous"
)
var croesusHideOpened = false

@Property(
type = PropertyType.SWITCH, name = "Dungeon Map",
description = "Displays the vanilla map on your screen using vanilla rendering code.",
Expand Down Expand Up @@ -2918,6 +2932,7 @@ object Config : Vigilant(
}

addDependency("dungeonChestProfitIncludesEssence", "dungeonChestProfit")
addDependency("croesusHideOpened", "croesusChestHighlight")
addDependency("kismetRerollThreshold", "dungeonChestProfit")

addDependency("message270Score", "sendMessageOn270Score")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,27 @@ package gg.skytils.skytilsmod.features.impl.dungeons
import gg.essential.api.EssentialAPI
import gg.essential.universal.UResolution
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.core.structure.GuiElement
import gg.skytils.skytilsmod.events.impl.GuiContainerEvent
import gg.skytils.skytilsmod.features.impl.handlers.AuctionData
import gg.skytils.skytilsmod.features.impl.misc.ItemFeatures
import gg.skytils.skytilsmod.utils.*
import gg.skytils.skytilsmod.utils.NumberUtil.romanToDecimal
import gg.skytils.skytilsmod.utils.RenderUtil.highlight
import gg.skytils.skytilsmod.utils.graphics.ScreenRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer
import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment
import gg.skytils.skytilsmod.utils.graphics.colors.CommonColors
import gg.skytils.skytilsmod.utils.graphics.colors.CustomColor
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.init.Items
import net.minecraft.inventory.ContainerChest
import net.minecraft.item.ItemStack
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.awt.Color


/**
Expand Down Expand Up @@ -110,6 +114,30 @@ object ChestProfit {
}
}

@SubscribeEvent
fun onDrawSlot(event: GuiContainerEvent.DrawSlotEvent.Pre) {
if (!Skytils.config.croesusChestHighlight) return
if (SBInfo.mode != SkyblockIsland.DungeonHub.mode) return
if (event.container !is ContainerChest || event.slot.inventory == mc.thePlayer.inventory) return
val stack = event.slot.stack ?: return
if (stack.item == Items.skull) {
val name = stack.displayName
if (!(name == "§cThe Catacombs" || name == "§cMaster Mode Catacombs")) return
val lore = ItemUtil.getItemLore(stack)
event.slot highlight when {
lore.any { line -> line == "§aNo more Chests to open!" } -> {
if (Skytils.config.croesusHideOpened) {
event.isCanceled = true
return
} else Color(255, 0, 0, 100)
}
lore.any { line -> line == "§8No Chests Opened!" } -> Color(0, 255, 0, 100)
lore.any { line -> line.startsWith("§8Opened Chest: ") } -> Color(255, 255, 0, 100)
else -> return
}
}
}

private fun getChestPrice(lore: List<String>): Double {
lore.forEach {
val line = it.stripControlCodes()
Expand All @@ -136,7 +164,7 @@ object ChestProfit {
val enchant = name.substring(name.indexOf("(") + 1, name.indexOf(")"))
return enchantNameToID(enchant)
} else {
val unformatted = name.stripControlCodes()
val unformatted = name.stripControlCodes().replace("Shiny ", "")
Harry282 marked this conversation as resolved.
Show resolved Hide resolved
ItemFeatures.itemIdToNameLookup.entries.find {
it.value == unformatted && !it.value.contains("STARRED")
}?.key
Expand Down