Add essence upgrade recipes
This commit is contained in:
@@ -31,6 +31,7 @@ import moe.nea.firmament.events.HandledScreenPushREIEvent
|
||||
import moe.nea.firmament.features.inventory.CraftingOverlay
|
||||
import moe.nea.firmament.features.inventory.storageoverlay.StorageOverlayScreen
|
||||
import moe.nea.firmament.rei.recipes.SBCraftingRecipe
|
||||
import moe.nea.firmament.rei.recipes.SBEssenceUpgradeRecipe
|
||||
import moe.nea.firmament.rei.recipes.SBForgeRecipe
|
||||
import moe.nea.firmament.rei.recipes.SBKatRecipe
|
||||
import moe.nea.firmament.rei.recipes.SBMobDropRecipe
|
||||
@@ -72,6 +73,7 @@ class FirmamentReiPlugin : REIClientPlugin {
|
||||
registry.add(SBForgeRecipe.Category)
|
||||
registry.add(SBMobDropRecipe.Category)
|
||||
registry.add(SBKatRecipe.Category)
|
||||
registry.add(SBEssenceUpgradeRecipe.Category)
|
||||
}
|
||||
|
||||
override fun registerExclusionZones(zones: ExclusionZones) {
|
||||
@@ -92,6 +94,10 @@ class FirmamentReiPlugin : REIClientPlugin {
|
||||
registry.registerDisplayGenerator(
|
||||
SBKatRecipe.Category.categoryIdentifier,
|
||||
SkyblockKatRecipeDynamicGenerator)
|
||||
registry.registerDisplayGenerator(
|
||||
SBEssenceUpgradeRecipe.Category.categoryIdentifier,
|
||||
SkyblockEssenceRecipeDynamicGenerator
|
||||
)
|
||||
}
|
||||
|
||||
override fun registerCollapsibleEntries(registry: CollapsibleEntryRegistry) {
|
||||
|
||||
@@ -22,6 +22,7 @@ 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.Formatting
|
||||
import net.minecraft.util.Identifier
|
||||
import moe.nea.firmament.rei.FirmamentReiPlugin.Companion.asItemEntry
|
||||
import moe.nea.firmament.repo.ExpLadders
|
||||
@@ -30,10 +31,13 @@ import moe.nea.firmament.repo.ItemCache.asItemStack
|
||||
import moe.nea.firmament.repo.RepoManager
|
||||
import moe.nea.firmament.util.FirmFormatters
|
||||
import moe.nea.firmament.util.HypixelPetInfo
|
||||
import moe.nea.firmament.util.LegacyFormattingCode
|
||||
import moe.nea.firmament.util.SkyblockId
|
||||
import moe.nea.firmament.util.appendLore
|
||||
import moe.nea.firmament.util.item.displayNameAccordingToNbt
|
||||
import moe.nea.firmament.util.petData
|
||||
import moe.nea.firmament.util.skyBlockId
|
||||
import moe.nea.firmament.util.withColor
|
||||
|
||||
// TODO: add in extra data like pet info, into this structure
|
||||
data class PetData(
|
||||
@@ -46,6 +50,7 @@ data class PetData(
|
||||
fun fromHypixel(petInfo: HypixelPetInfo) = PetData(
|
||||
petInfo.tier, petInfo.type, petInfo.exp,
|
||||
)
|
||||
|
||||
fun forLevel(petId: String, rarity: Rarity, level: Int) = PetData(
|
||||
rarity, petId, ExpLadders.getExpLadder(petId, rarity).getPetExpForLevel(level).toDouble()
|
||||
)
|
||||
@@ -60,6 +65,8 @@ data class SBItemStack(
|
||||
private var stackSize: Int,
|
||||
private var petData: PetData?,
|
||||
val extraLore: List<Text> = emptyList(),
|
||||
// TODO: grab this star data from nbt if possible
|
||||
val stars: Int = 0,
|
||||
) {
|
||||
|
||||
fun getStackSize() = stackSize
|
||||
@@ -67,6 +74,7 @@ data class SBItemStack(
|
||||
this.stackSize = stackSize
|
||||
this.itemStack_ = null
|
||||
}
|
||||
|
||||
fun getPetData() = petData
|
||||
fun setPetData(petData: PetData?) {
|
||||
this.petData = petData
|
||||
@@ -132,12 +140,42 @@ data class SBItemStack(
|
||||
injectReplacementDataForPets(replacementData)
|
||||
return@run neuItem.asItemStack(idHint = skyblockId, replacementData).copyWithCount(stackSize)
|
||||
.also { it.appendLore(extraLore) }
|
||||
.also { enhanceStatsByStars(it, stars) }
|
||||
}
|
||||
if (itemStack_ == null)
|
||||
itemStack_ = itemStack
|
||||
return itemStack
|
||||
}
|
||||
|
||||
|
||||
private fun starString(stars: Int): Text {
|
||||
if (stars <= 0) return Text.empty()
|
||||
val tiers = listOf(
|
||||
LegacyFormattingCode.GOLD,
|
||||
LegacyFormattingCode.LIGHT_PURPLE,
|
||||
LegacyFormattingCode.AQUA,
|
||||
)
|
||||
val maxStars = 5
|
||||
if (stars > tiers.size * maxStars) return Text.literal(" ${stars}✪").withColor(Formatting.RED)
|
||||
val starBaseTier = (stars - 1) / maxStars
|
||||
val starBaseColor = tiers[starBaseTier]
|
||||
val starsInCurrentTier = stars - starBaseTier * maxStars
|
||||
val starString = Text.literal(" " + "✪".repeat(starsInCurrentTier)).withColor(starBaseColor.modern)
|
||||
if (starBaseTier > 0) {
|
||||
val starLastTier = tiers[starBaseTier - 1]
|
||||
val starsInLastTier = 5 - starsInCurrentTier
|
||||
starString.append(Text.literal("✪".repeat(starsInLastTier)).withColor(starLastTier.modern))
|
||||
}
|
||||
return starString
|
||||
}
|
||||
|
||||
private fun enhanceStatsByStars(itemStack: ItemStack, stars: Int) {
|
||||
if (stars == 0) return
|
||||
// TODO: increase stats and add the star level into the nbt data so star displays work
|
||||
itemStack.displayNameAccordingToNbt = itemStack.displayNameAccordingToNbt.copy()
|
||||
.append(starString(stars))
|
||||
}
|
||||
|
||||
fun asImmutableItemStack(): ItemStack {
|
||||
return itemStack
|
||||
}
|
||||
@@ -179,11 +217,11 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
|
||||
}
|
||||
|
||||
override fun wildcard(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack {
|
||||
return value.copy(stackSize = 1)
|
||||
return value.copy(stackSize = 1, petData = null, stars = 0, extraLore = listOf())
|
||||
}
|
||||
|
||||
override fun normalize(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack {
|
||||
return value.copy(stackSize = 1)
|
||||
return wildcard(entry, value)
|
||||
}
|
||||
|
||||
override fun copy(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack {
|
||||
|
||||
@@ -18,9 +18,11 @@ import me.shedaniel.rei.api.client.view.ViewSearchBuilder
|
||||
import me.shedaniel.rei.api.common.display.Display
|
||||
import me.shedaniel.rei.api.common.entry.EntryStack
|
||||
import moe.nea.firmament.rei.recipes.SBCraftingRecipe
|
||||
import moe.nea.firmament.rei.recipes.SBEssenceUpgradeRecipe
|
||||
import moe.nea.firmament.rei.recipes.SBForgeRecipe
|
||||
import moe.nea.firmament.rei.recipes.SBKatRecipe
|
||||
import moe.nea.firmament.rei.recipes.SBMobDropRecipe
|
||||
import moe.nea.firmament.repo.EssenceRecipeProvider
|
||||
import moe.nea.firmament.repo.RepoManager
|
||||
|
||||
|
||||
@@ -35,6 +37,8 @@ val SkyblockMobDropRecipeDynamicGenerator =
|
||||
|
||||
val SkyblockKatRecipeDynamicGenerator =
|
||||
neuDisplayGenerator<SBKatRecipe, NEUKatUpgradeRecipe> { SBKatRecipe(it) }
|
||||
val SkyblockEssenceRecipeDynamicGenerator =
|
||||
neuDisplayGenerator<SBEssenceUpgradeRecipe, EssenceRecipeProvider.EssenceUpgradeRecipe> { SBEssenceUpgradeRecipe(it) }
|
||||
|
||||
inline fun <D : Display, reified T : NEURecipe> neuDisplayGenerator(crossinline mapper: (T) -> D) =
|
||||
object : DynamicDisplayGenerator<D> {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package moe.nea.firmament.rei.recipes
|
||||
|
||||
import me.shedaniel.math.Point
|
||||
import me.shedaniel.math.Rectangle
|
||||
import me.shedaniel.rei.api.client.gui.Renderer
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Widget
|
||||
import me.shedaniel.rei.api.client.gui.widgets.Widgets
|
||||
import me.shedaniel.rei.api.client.registry.display.DisplayCategory
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier
|
||||
import net.minecraft.text.Text
|
||||
import moe.nea.firmament.Firmament
|
||||
import moe.nea.firmament.rei.SBItemEntryDefinition
|
||||
import moe.nea.firmament.rei.SBItemStack
|
||||
import moe.nea.firmament.repo.EssenceRecipeProvider
|
||||
import moe.nea.firmament.util.SkyblockId
|
||||
|
||||
class SBEssenceUpgradeRecipe(override val neuRecipe: EssenceRecipeProvider.EssenceUpgradeRecipe) : SBRecipe() {
|
||||
object Category : DisplayCategory<SBEssenceUpgradeRecipe> {
|
||||
override fun getCategoryIdentifier(): CategoryIdentifier<SBEssenceUpgradeRecipe> =
|
||||
CategoryIdentifier.of(Firmament.MOD_ID, "essence_upgrade")
|
||||
|
||||
override fun getTitle(): Text {
|
||||
return Text.literal("Essence Upgrades")
|
||||
}
|
||||
|
||||
override fun getIcon(): Renderer {
|
||||
return SBItemEntryDefinition.getEntry(SkyblockId("ESSENCE_WITHER"))
|
||||
}
|
||||
|
||||
override fun setupDisplay(display: SBEssenceUpgradeRecipe, bounds: Rectangle): List<Widget> {
|
||||
val recipe = display.neuRecipe
|
||||
val list = mutableListOf<Widget>()
|
||||
list.add(Widgets.createRecipeBase(bounds))
|
||||
list.add(Widgets.createSlot(Point(bounds.minX + 12, bounds.centerY - 8 - 18 / 2))
|
||||
.markInput()
|
||||
.entry(SBItemEntryDefinition.getEntry(SBItemStack(recipe.itemId).copy(stars = recipe.starCountAfter - 1))))
|
||||
list.add(Widgets.createSlot(Point(bounds.minX + 12, bounds.centerY - 8 + 18 / 2))
|
||||
.markInput()
|
||||
.entry(SBItemEntryDefinition.getEntry(recipe.essenceIngredient)))
|
||||
list.add(Widgets.createSlot(Point(bounds.maxX - 12 - 16, bounds.centerY - 8))
|
||||
.markOutput()
|
||||
.entry(SBItemEntryDefinition.getEntry(SBItemStack(recipe.itemId).copy(stars = recipe.starCountAfter))))
|
||||
val extraItems = recipe.extraItems
|
||||
list.add(Widgets.createArrow(Point(bounds.centerX - 24 / 2,
|
||||
if (extraItems.isEmpty()) bounds.centerY - 17 / 2
|
||||
else bounds.centerY + 18 / 2)))
|
||||
for ((index, item) in extraItems.withIndex()) {
|
||||
list.add(Widgets.createSlot(
|
||||
Point(bounds.centerX - extraItems.size * 16 / 2 - 2 / 2 + index * 18,
|
||||
bounds.centerY - 18 / 2))
|
||||
.markInput()
|
||||
.entry(SBItemEntryDefinition.getEntry(item)))
|
||||
}
|
||||
return list
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCategoryIdentifier(): CategoryIdentifier<*> {
|
||||
return Category.categoryIdentifier
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user