aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-09-17 23:15:41 +0200
committerLinnea Gräf <nea@nea.moe>2025-09-17 23:15:41 +0200
commit2b02a861a6f9a39c766dd4be18f30abefa2d9aec (patch)
tree16ac5250cea13bc45390616ce0b7f3cd1d6346a0
parent21817efdfe62135704571908b9f72ed3ace4bdf1 (diff)
downloadFirmament-2b02a861a6f9a39c766dd4be18f30abefa2d9aec.tar.gz
Firmament-2b02a861a6f9a39c766dd4be18f30abefa2d9aec.tar.bz2
Firmament-2b02a861a6f9a39c766dd4be18f30abefa2d9aec.zip
feat: add skyblock ids into bazaar
-rw-r--r--src/main/java/moe/nea/firmament/repo/EnchantedBookCache.kt16
-rw-r--r--src/main/kotlin/features/debug/PowerUserTools.kt18
-rw-r--r--src/main/kotlin/repo/RepoManager.kt2
-rw-r--r--src/main/kotlin/util/SkyblockId.kt30
-rw-r--r--src/main/kotlin/util/skyblock/ScreenIdentification.kt21
5 files changed, 80 insertions, 7 deletions
diff --git a/src/main/java/moe/nea/firmament/repo/EnchantedBookCache.kt b/src/main/java/moe/nea/firmament/repo/EnchantedBookCache.kt
new file mode 100644
index 0000000..0e276ce
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/repo/EnchantedBookCache.kt
@@ -0,0 +1,16 @@
+package moe.nea.firmament.repo
+
+import io.github.moulberry.repo.IReloadable
+import io.github.moulberry.repo.NEURepository
+import moe.nea.firmament.util.SkyblockId
+import moe.nea.firmament.util.removeColorCodes
+import moe.nea.firmament.util.skyblockId
+
+class EnchantedBookCache : IReloadable {
+ var byName: Map<String, SkyblockId> = mapOf()
+ override fun reload(repo: NEURepository) {
+ byName = repo.items.items.values
+ .filter { it.displayName.endsWith("Enchanted Book") }
+ .associate { it.lore.first().removeColorCodes() to it.skyblockId }
+ }
+}
diff --git a/src/main/kotlin/features/debug/PowerUserTools.kt b/src/main/kotlin/features/debug/PowerUserTools.kt
index 049a0fb..b682813 100644
--- a/src/main/kotlin/features/debug/PowerUserTools.kt
+++ b/src/main/kotlin/features/debug/PowerUserTools.kt
@@ -25,6 +25,7 @@ import moe.nea.firmament.events.CustomItemModelEvent
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
import moe.nea.firmament.events.ItemTooltipEvent
import moe.nea.firmament.events.ScreenChangeEvent
+import moe.nea.firmament.events.SlotRenderEvents
import moe.nea.firmament.events.TickEvent
import moe.nea.firmament.events.WorldKeyboardEvent
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
@@ -43,7 +44,7 @@ import moe.nea.firmament.util.mc.loreAccordingToNbt
import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.tr
-object PowerUserTools {
+object PowerUserTools {
val identifier: String
get() = "power-user"
@@ -63,6 +64,7 @@ object PowerUserTools {
val exportNpcLocation by keyBindingWithDefaultUnbound("export-npc-location")
val highlightNonOverlayItems by toggle("highlight-non-overlay") { false }
val dontHighlightSemicolonItems by toggle("dont-highlight-semicolon-items") { false }
+ val showSlotNumbers by keyBindingWithDefaultUnbound("slot-numbers")
}
var lastCopiedStack: Pair<ItemStack, Text>? = null
@@ -87,6 +89,20 @@ object PowerUserTools {
}
@Subscribe
+ fun onRender(event: SlotRenderEvents.After) {
+ if (TConfig.showSlotNumbers.isPressed()) {
+ event.context.drawText(
+ MC.font,
+ event.slot.id.toString(), event.slot.x, event.slot.y, 0xFF00FF00.toInt(), true
+ )
+ event.context.drawText(
+ MC.font,
+ event.slot.index.toString(), event.slot.x, event.slot.y + MC.font.fontHeight, 0xFFFF0000.toInt(), true
+ )
+ }
+ }
+
+ @Subscribe
fun onEntityInfo(event: WorldKeyboardEvent) {
if (!event.matches(TConfig.copyEntityData)) return
val target = (MC.instance.crosshairTarget as? EntityHitResult)?.entity
diff --git a/src/main/kotlin/repo/RepoManager.kt b/src/main/kotlin/repo/RepoManager.kt
index 43d6db8..3a245b6 100644
--- a/src/main/kotlin/repo/RepoManager.kt
+++ b/src/main/kotlin/repo/RepoManager.kt
@@ -76,6 +76,7 @@ object RepoManager {
val recipeCache = BetterRepoRecipeCache(essenceRecipeProvider, ReforgeStore)
val miningData = MiningRepoData()
val overlayData = ModernOverlaysData()
+ val enchantedBookCache = EnchantedBookCache()
fun makeNEURepository(path: Path): NEURepository {
return NEURepository.of(path).apply {
@@ -88,6 +89,7 @@ object RepoManager {
registerReloadListener(essenceRecipeProvider)
registerReloadListener(recipeCache)
registerReloadListener(miningData)
+ registerReloadListener(enchantedBookCache)
ReloadRegistrationEvent.publish(ReloadRegistrationEvent(this))
registerReloadListener {
if (TestUtil.isInTest) return@registerReloadListener
diff --git a/src/main/kotlin/util/SkyblockId.kt b/src/main/kotlin/util/SkyblockId.kt
index 07d4c30..43a9084 100644
--- a/src/main/kotlin/util/SkyblockId.kt
+++ b/src/main/kotlin/util/SkyblockId.kt
@@ -29,11 +29,14 @@ import net.minecraft.util.Identifier
import moe.nea.firmament.repo.ExpLadders
import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.ItemCache.asItemStack
+import moe.nea.firmament.repo.ItemNameLookup
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.repo.set
import moe.nea.firmament.util.collections.WeakCache
import moe.nea.firmament.util.json.DashlessUUIDSerializer
+import moe.nea.firmament.util.mc.displayNameAccordingToNbt
import moe.nea.firmament.util.mc.loreAccordingToNbt
+import moe.nea.firmament.util.skyblock.isBazaarUi
/**
* A SkyBlock item id, as used by the NEU repo.
@@ -142,7 +145,7 @@ fun ItemStack.modifyExtraAttributes(block: (NbtCompound) -> Unit) {
set(DataComponentTypes.CUSTOM_DATA, NbtComponent.of(baseNbt))
}
-val ItemStack.skyblockUUIDString: String?
+val ItemStack.skyBlockUUIDString: String?
get() = extraAttributes.getString("uuid").getOrNull()?.takeIf { it.isNotBlank() }
private val timestampFormat = //"10/11/21 3:39 PM"
@@ -170,7 +173,7 @@ val ItemStack.timestamp
}
val ItemStack.skyblockUUID: UUID?
- get() = skyblockUUIDString?.let { UUID.fromString(it) }
+ get() = skyBlockUUIDString?.let { UUID.fromString(it) }
private val petDataCache = WeakCache.memoize<ItemStack, Optional<HypixelPetInfo>>("PetInfo") {
val jsonString = it.extraAttributes.getString("petInfo")
@@ -219,16 +222,31 @@ fun ItemStack.getLogicalStackSize(): Long {
} ?: AMOUNT_REGEX.useMatch(string) {
parseShortNumber(group(1)).toLong()
} ?: COMPOST_REGEX.useMatch(string) {
- parseShortNumber(group(1)).toLong()
- }
+ parseShortNumber(group(1)).toLong()
+ }
} ?: count.toLong()
}
+val ItemStack.rawSkyBlockId: String? get() = extraAttributes.getString("id").getOrNull()
+
+fun ItemStack.guessContextualSkyBlockId(): SkyblockId? {
+ if (MC.screen?.isBazaarUi() == true) {
+ val name = displayNameAccordingToNbt.unformattedString
+ .replaceFirst("SELL ", "")
+ .replaceFirst("BUY ", "")
+ if (item == Items.ENCHANTED_BOOK) {
+ return RepoManager.enchantedBookCache.byName[name]
+ }
+ return ItemNameLookup.guessItemByName(name, false)
+ }
+ return null
+}
+
val ItemStack.skyBlockId: SkyblockId?
get() {
- return when (val id = extraAttributes.getString("id").getOrNull()) {
+ return when (val id = rawSkyBlockId) {
"", null -> {
- null
+ guessContextualSkyBlockId()
}
"PET" -> {
diff --git a/src/main/kotlin/util/skyblock/ScreenIdentification.kt b/src/main/kotlin/util/skyblock/ScreenIdentification.kt
new file mode 100644
index 0000000..7370a6f
--- /dev/null
+++ b/src/main/kotlin/util/skyblock/ScreenIdentification.kt
@@ -0,0 +1,21 @@
+package moe.nea.firmament.util.skyblock
+
+import net.minecraft.client.gui.screen.Screen
+import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
+import moe.nea.firmament.util.mc.displayNameAccordingToNbt
+import moe.nea.firmament.util.mc.loreAccordingToNbt
+import moe.nea.firmament.util.unformattedString
+
+
+fun Screen.isBazaarUi(): Boolean {
+ if (this !is GenericContainerScreen) return false
+ return (
+ this.screenHandler.stacks[this.screenHandler.rows * 9 - 4]
+ .displayNameAccordingToNbt
+ .unformattedString == "Manage Orders"
+ || this.screenHandler.stacks[this.screenHandler.rows * 9 - 5]
+ .loreAccordingToNbt
+ .any {
+ it.unformattedString == "To Bazaar"
+ })
+}