aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/rei
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-06-03 19:58:34 +0200
committernea <nea@nea.moe>2023-06-03 19:58:34 +0200
commit3c437efa12d536cdc347895b3e37bc3f5acc0193 (patch)
treece674eb1ad15cc2e56d9f194659bed088f5e23b1 /src/main/kotlin/moe/nea/firmament/rei
parentd2d032ba05dd476d7edc0038f8a5f60f98769256 (diff)
downloadFirmament-3c437efa12d536cdc347895b3e37bc3f5acc0193.tar.gz
Firmament-3c437efa12d536cdc347895b3e37bc3f5acc0193.tar.bz2
Firmament-3c437efa12d536cdc347895b3e37bc3f5acc0193.zip
Add pet level data to /firm pv
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/rei')
-rw-r--r--src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt5
-rw-r--r--src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt2
-rw-r--r--src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt52
3 files changed, 47 insertions, 12 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt b/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt
index 87efaac..8b8383a 100644
--- a/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt
+++ b/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt
@@ -35,6 +35,7 @@ import moe.nea.firmament.recipes.SBForgeRecipe
import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.SkyblockId
+import moe.nea.firmament.util.skyblockId
class FirmamentReiPlugin : REIClientPlugin {
@@ -73,7 +74,7 @@ class FirmamentReiPlugin : REIClientPlugin {
registry.group(
SkyblockId(parent).identifier,
Text.literal(RepoManager.getNEUItem(SkyblockId(parent))?.displayName ?: parent),
- (children + parent).map { SBItemEntryDefinition.getEntry(RepoManager.getNEUItem(SkyblockId(it))) })
+ (children + parent).map { SBItemEntryDefinition.getEntry(SkyblockId(it)) })
}
}
@@ -84,7 +85,7 @@ class FirmamentReiPlugin : REIClientPlugin {
override fun registerEntries(registry: EntryRegistry) {
RepoManager.neuRepo.items?.items?.values?.forEach {
if (!it.isVanilla)
- registry.addEntry(SBItemEntryDefinition.getEntry(it))
+ registry.addEntry(SBItemEntryDefinition.getEntry(it.skyblockId))
}
}
}
diff --git a/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt b/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt
index bf59940..7d98558 100644
--- a/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt
+++ b/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntrySerializer.kt
@@ -34,7 +34,7 @@ object NEUItemEntrySerializer : EntrySerializer<SBItemStack> {
override fun read(tag: NbtCompound): SBItemStack {
val id = SkyblockId(tag.getString(SKYBLOCK_ID_ENTRY))
val count = if (tag.contains(SKYBLOCK_ITEM_COUNT)) tag.getInt(SKYBLOCK_ITEM_COUNT) else 1
- return SBItemStack(id, RepoManager.getNEUItem(id), count)
+ return SBItemStack(id, count)
}
override fun save(entry: EntryStack<SBItemStack>, value: SBItemStack): NbtCompound {
diff --git a/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt b/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt
index c38f350..f5f3401 100644
--- a/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt
+++ b/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt
@@ -20,6 +20,7 @@ package moe.nea.firmament.rei
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
@@ -33,28 +34,64 @@ 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.FirmFormatters
import moe.nea.firmament.util.SkyblockId
-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 levelData by lazy { ExpLadders.getExpLadder(petId, rarity).getPetLevel(exp) }
+}
+
data class SBItemStack(
val skyblockId: SkyblockId,
val neuItem: NEUItem?,
val stackSize: Int,
+ val petData: PetData?,
) {
+ constructor(skyblockId: SkyblockId, petData: PetData) : this(
+ skyblockId,
+ RepoManager.getNEUItem(skyblockId),
+ 1,
+ petData
+ )
+
constructor(skyblockId: SkyblockId, stackSize: Int = 1) : this(
skyblockId,
RepoManager.getNEUItem(skyblockId),
- stackSize
+ stackSize,
+ RepoManager.getPotentialStubPetData(skyblockId)
)
- fun asItemStack(): ItemStack {
+ private val itemStack by lazy {
if (skyblockId == SkyblockId.COINS)
- return ItemCache.coinItem(stackSize)
- return neuItem.asItemStack(idHint = skyblockId).copyWithCount(stackSize)
+ 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.toString(it, 0)
+ }
+ stats.statNumbers.forEach { (t, u) ->
+ replacementData[t] = FirmFormatters.toString(u, 0)
+ }
+ }
+ replacementData["LVL"] = petData.levelData.currentLevel.toString()
+ }
+ return@lazy neuItem.asItemStack(idHint = skyblockId, replacementData).copyWithCount(stackSize)
+ }
+
+ fun asItemStack(): ItemStack {
+ return itemStack.copy()
}
}
@@ -112,11 +149,8 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
fun getEntry(sbItemStack: SBItemStack): EntryStack<SBItemStack> =
EntryStack.of(this, sbItemStack)
- fun getEntry(neuItem: NEUItem?, count: Int = 1): EntryStack<SBItemStack> =
- getEntry(SBItemStack(neuItem?.skyblockId ?: SkyblockId.NULL, neuItem, 1))
-
fun getEntry(skyblockId: SkyblockId, count: Int = 1): EntryStack<SBItemStack> =
- getEntry(SBItemStack(skyblockId, RepoManager.getNEUItem(skyblockId), count))
+ getEntry(SBItemStack(skyblockId, count))
fun getEntry(ingredient: NEUIngredient): EntryStack<SBItemStack> =
getEntry(SkyblockId(ingredient.itemId), count = ingredient.amount.toInt())