aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2023-12-29 18:47:47 +0100
committerLinnea Gräf <nea@nea.moe>2023-12-29 18:47:47 +0100
commit745688773823d79c6033ccd6b008c690abf7d131 (patch)
treec8e9b2b086d8b374be92904493944c9815fbcabd /src
parent51c9df52fca0332d34706d06f09847ddb1ac2dd5 (diff)
downloadfirmament-745688773823d79c6033ccd6b008c690abf7d131.tar.gz
firmament-745688773823d79c6033ccd6b008c690abf7d131.tar.bz2
firmament-745688773823d79c6033ccd6b008c690abf7d131.zip
Fix pet numbers on repo itemstacks
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt67
-rw-r--r--src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt4
2 files changed, 49 insertions, 22 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt b/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt
index 25c450a..77e329e 100644
--- a/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt
+++ b/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt
@@ -6,9 +6,11 @@
package moe.nea.firmament.rei
+import io.github.moulberry.repo.constants.PetNumbers
import io.github.moulberry.repo.data.NEUIngredient
import io.github.moulberry.repo.data.NEUItem
import io.github.moulberry.repo.data.Rarity
+import java.util.stream.Stream
import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer
import me.shedaniel.rei.api.common.entry.EntrySerializer
import me.shedaniel.rei.api.common.entry.EntryStack
@@ -16,23 +18,27 @@ import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext
import me.shedaniel.rei.api.common.entry.type.EntryDefinition
import me.shedaniel.rei.api.common.entry.type.EntryType
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes
+import net.minecraft.item.ItemStack
+import net.minecraft.registry.tag.TagKey
+import net.minecraft.text.Text
+import net.minecraft.util.Identifier
import moe.nea.firmament.rei.FirmamentReiPlugin.Companion.asItemEntry
import moe.nea.firmament.repo.ExpLadders
import moe.nea.firmament.repo.ItemCache
import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.RepoManager
-import moe.nea.firmament.util.*
-import net.minecraft.item.ItemStack
-import net.minecraft.registry.tag.TagKey
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
-import java.util.stream.Stream
+import moe.nea.firmament.util.FirmFormatters
+import moe.nea.firmament.util.HypixelPetInfo
+import moe.nea.firmament.util.SkyblockId
+import moe.nea.firmament.util.petData
+import moe.nea.firmament.util.skyBlockId
// TODO: add in extra data like pet info, into this structure
data class PetData(
val rarity: Rarity,
val petId: String,
val exp: Double,
+ val isStub: Boolean = false,
) {
companion object {
fun fromHypixel(petInfo: HypixelPetInfo) = PetData(
@@ -63,23 +69,44 @@ data class SBItemStack(
RepoManager.getPotentialStubPetData(skyblockId)
)
+ private fun injectReplacementDataForPetLevel(
+ petInfo: PetNumbers,
+ level: Int,
+ replacementData: MutableMap<String, String>
+ ) {
+ val stats = petInfo.interpolatedStatsAtLevel(level) ?: return
+ stats.otherNumbers.forEachIndexed { index, it ->
+ replacementData[index.toString()] = FirmFormatters.formatCurrency(it, 1)
+ }
+ stats.statNumbers.forEach { (t, u) ->
+ replacementData[t] = FirmFormatters.formatCurrency(u, 1)
+ }
+ }
+
+ private fun injectReplacementDataForPets(replacementData: MutableMap<String, String>) {
+ if (petData == null) return
+ val petInfo = RepoManager.neuRepo.constants.petNumbers[petData.petId]?.get(petData.rarity) ?: return
+ if (petData.isStub) {
+ val mapLow = mutableMapOf<String, String>()
+ injectReplacementDataForPetLevel(petInfo, petInfo.lowLevel, mapLow)
+ val mapHigh = mutableMapOf<String, String>()
+ injectReplacementDataForPetLevel(petInfo, petInfo.highLevel, mapHigh)
+ mapHigh.forEach { (key, highValue) ->
+ mapLow.merge(key, highValue) { a, b -> "$a → $b" }
+ }
+ replacementData.putAll(mapLow)
+ replacementData["LVL"] = "${petInfo.lowLevel} → ${petInfo.highLevel}"
+ } else {
+ injectReplacementDataForPetLevel(petInfo, petData.levelData.currentLevel, replacementData)
+ replacementData["LVL"] = petData.levelData.currentLevel.toString()
+ }
+ }
+
private val itemStack by lazy(LazyThreadSafetyMode.NONE) {
if (skyblockId == SkyblockId.COINS)
return@lazy ItemCache.coinItem(stackSize)
val replacementData = mutableMapOf<String, String>()
- if (petData != null) {
- val stats = RepoManager.neuRepo.constants.petNumbers[petData.petId]?.get(petData.rarity)
- ?.interpolatedStatsAtLevel(petData.levelData.currentLevel)
- if (stats != null) {
- stats.otherNumbers.forEachIndexed { index, it ->
- replacementData[index.toString()] = FirmFormatters.formatCurrency(it, 1)
- }
- stats.statNumbers.forEach { (t, u) ->
- replacementData[t] = FirmFormatters.formatCurrency(u, 1)
- }
- }
- replacementData["LVL"] = petData.levelData.currentLevel.toString()
- }
+ injectReplacementDataForPets(replacementData)
return@lazy neuItem.asItemStack(idHint = skyblockId, replacementData).copyWithCount(stackSize)
}
@@ -98,7 +125,7 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
}
override fun cheatsAs(entry: EntryStack<SBItemStack>?, value: SBItemStack): ItemStack {
- return value.neuItem.asItemStack()
+ return value.asItemStack()
}
override fun getValueType(): Class<SBItemStack> = SBItemStack::class.java
diff --git a/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt b/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt
index cad1a0f..e6f4755 100644
--- a/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt
+++ b/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt
@@ -142,9 +142,9 @@ object RepoManager {
return null
}
val intIndex = rarityIndex.toInt()
- if (intIndex !in rarityIndex.indices) return null
+ if (intIndex !in Rarity.values().indices) return null
if (petId !in neuRepo.constants.petNumbers) return null
- return PetData(Rarity.values()[intIndex], petId, 0.0)
+ return PetData(Rarity.values()[intIndex], petId, 0.0, true)
}
}