Fix pet numbers on repo itemstacks
This commit is contained in:
@@ -6,9 +6,11 @@
|
|||||||
|
|
||||||
package moe.nea.firmament.rei
|
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.NEUIngredient
|
||||||
import io.github.moulberry.repo.data.NEUItem
|
import io.github.moulberry.repo.data.NEUItem
|
||||||
import io.github.moulberry.repo.data.Rarity
|
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.client.entry.renderer.EntryRenderer
|
||||||
import me.shedaniel.rei.api.common.entry.EntrySerializer
|
import me.shedaniel.rei.api.common.entry.EntrySerializer
|
||||||
import me.shedaniel.rei.api.common.entry.EntryStack
|
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.EntryDefinition
|
||||||
import me.shedaniel.rei.api.common.entry.type.EntryType
|
import me.shedaniel.rei.api.common.entry.type.EntryType
|
||||||
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes
|
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.rei.FirmamentReiPlugin.Companion.asItemEntry
|
||||||
import moe.nea.firmament.repo.ExpLadders
|
import moe.nea.firmament.repo.ExpLadders
|
||||||
import moe.nea.firmament.repo.ItemCache
|
import moe.nea.firmament.repo.ItemCache
|
||||||
import moe.nea.firmament.repo.ItemCache.asItemStack
|
import moe.nea.firmament.repo.ItemCache.asItemStack
|
||||||
import moe.nea.firmament.repo.RepoManager
|
import moe.nea.firmament.repo.RepoManager
|
||||||
import moe.nea.firmament.util.*
|
import moe.nea.firmament.util.FirmFormatters
|
||||||
import net.minecraft.item.ItemStack
|
import moe.nea.firmament.util.HypixelPetInfo
|
||||||
import net.minecraft.registry.tag.TagKey
|
import moe.nea.firmament.util.SkyblockId
|
||||||
import net.minecraft.text.Text
|
import moe.nea.firmament.util.petData
|
||||||
import net.minecraft.util.Identifier
|
import moe.nea.firmament.util.skyBlockId
|
||||||
import java.util.stream.Stream
|
|
||||||
|
|
||||||
// TODO: add in extra data like pet info, into this structure
|
// TODO: add in extra data like pet info, into this structure
|
||||||
data class PetData(
|
data class PetData(
|
||||||
val rarity: Rarity,
|
val rarity: Rarity,
|
||||||
val petId: String,
|
val petId: String,
|
||||||
val exp: Double,
|
val exp: Double,
|
||||||
|
val isStub: Boolean = false,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
fun fromHypixel(petInfo: HypixelPetInfo) = PetData(
|
fun fromHypixel(petInfo: HypixelPetInfo) = PetData(
|
||||||
@@ -63,14 +69,12 @@ data class SBItemStack(
|
|||||||
RepoManager.getPotentialStubPetData(skyblockId)
|
RepoManager.getPotentialStubPetData(skyblockId)
|
||||||
)
|
)
|
||||||
|
|
||||||
private val itemStack by lazy(LazyThreadSafetyMode.NONE) {
|
private fun injectReplacementDataForPetLevel(
|
||||||
if (skyblockId == SkyblockId.COINS)
|
petInfo: PetNumbers,
|
||||||
return@lazy ItemCache.coinItem(stackSize)
|
level: Int,
|
||||||
val replacementData = mutableMapOf<String, String>()
|
replacementData: MutableMap<String, String>
|
||||||
if (petData != null) {
|
) {
|
||||||
val stats = RepoManager.neuRepo.constants.petNumbers[petData.petId]?.get(petData.rarity)
|
val stats = petInfo.interpolatedStatsAtLevel(level) ?: return
|
||||||
?.interpolatedStatsAtLevel(petData.levelData.currentLevel)
|
|
||||||
if (stats != null) {
|
|
||||||
stats.otherNumbers.forEachIndexed { index, it ->
|
stats.otherNumbers.forEachIndexed { index, it ->
|
||||||
replacementData[index.toString()] = FirmFormatters.formatCurrency(it, 1)
|
replacementData[index.toString()] = FirmFormatters.formatCurrency(it, 1)
|
||||||
}
|
}
|
||||||
@@ -78,8 +82,31 @@ data class SBItemStack(
|
|||||||
replacementData[t] = FirmFormatters.formatCurrency(u, 1)
|
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()
|
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>()
|
||||||
|
injectReplacementDataForPets(replacementData)
|
||||||
return@lazy neuItem.asItemStack(idHint = skyblockId, replacementData).copyWithCount(stackSize)
|
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 {
|
override fun cheatsAs(entry: EntryStack<SBItemStack>?, value: SBItemStack): ItemStack {
|
||||||
return value.neuItem.asItemStack()
|
return value.asItemStack()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getValueType(): Class<SBItemStack> = SBItemStack::class.java
|
override fun getValueType(): Class<SBItemStack> = SBItemStack::class.java
|
||||||
|
|||||||
@@ -142,9 +142,9 @@ object RepoManager {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
val intIndex = rarityIndex.toInt()
|
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
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user