feat: Keep old reforges in reforge recipes
This commit is contained in:
@@ -15,12 +15,9 @@ import net.minecraft.registry.tag.TagKey
|
||||
import net.minecraft.text.Text
|
||||
import net.minecraft.util.Identifier
|
||||
import moe.nea.firmament.compat.rei.FirmamentReiPlugin.Companion.asItemEntry
|
||||
import moe.nea.firmament.repo.PetData
|
||||
import moe.nea.firmament.repo.RepoManager
|
||||
import moe.nea.firmament.repo.SBItemStack
|
||||
import moe.nea.firmament.util.SkyblockId
|
||||
import moe.nea.firmament.util.petData
|
||||
import moe.nea.firmament.util.skyBlockId
|
||||
|
||||
object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
|
||||
override fun equals(o1: SBItemStack, o2: SBItemStack, context: ComparisonContext): Boolean {
|
||||
@@ -55,7 +52,7 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
|
||||
|
||||
override fun wildcard(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack {
|
||||
return value.copy(stackSize = 1, petData = RepoManager.getPotentialStubPetData(value.skyblockId),
|
||||
stars = 0, extraLore = listOf())
|
||||
stars = 0, extraLore = listOf(), reforge = null)
|
||||
}
|
||||
|
||||
override fun normalize(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack {
|
||||
@@ -86,12 +83,5 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
|
||||
fun getPassthrough(item: ItemConvertible) = getEntry(SBItemStack.passthrough(ItemStack(item.asItem())))
|
||||
|
||||
fun getEntry(stack: ItemStack): EntryStack<SBItemStack> =
|
||||
getEntry(
|
||||
SBItemStack(
|
||||
stack.skyBlockId ?: SkyblockId.NULL,
|
||||
RepoManager.getNEUItem(stack.skyBlockId ?: SkyblockId.NULL),
|
||||
stack.count,
|
||||
petData = stack.petData?.let { PetData.fromHypixel(it) }
|
||||
)
|
||||
)
|
||||
getEntry(SBItemStack(stack))
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ object SkyblockItemIdFocusedStackProvider : FocusedStackProvider {
|
||||
screen as AccessorHandledScreen
|
||||
val focusedSlot = screen.focusedSlot_Firmament ?: return CompoundEventResult.pass()
|
||||
val item = focusedSlot.stack ?: return CompoundEventResult.pass()
|
||||
val skyblockId = item.skyBlockId ?: return CompoundEventResult.pass()
|
||||
return CompoundEventResult.interruptTrue(SBItemEntryDefinition.getEntry(skyblockId))
|
||||
return CompoundEventResult.interruptTrue(SBItemEntryDefinition.getEntry(item))
|
||||
}
|
||||
|
||||
override fun getPriority(): Double = 1_000_000.0
|
||||
|
||||
@@ -44,7 +44,7 @@ import moe.nea.firmament.util.tr
|
||||
|
||||
class SBReforgeRecipe(
|
||||
val reforge: Reforge,
|
||||
val limitToItem: SkyblockId?,
|
||||
val limitToItem: SBItemStack?,
|
||||
) : Display {
|
||||
companion object {
|
||||
val catIdentifier = CategoryIdentifier.of<SBReforgeRecipe>(Firmament.MOD_ID, "reforge_recipe")
|
||||
@@ -132,10 +132,10 @@ class SBReforgeRecipe(
|
||||
fun getRecipesForSBItemStack(item: SBItemStack): Optional<List<SBReforgeRecipe>> {
|
||||
val reforgeRecipes = mutableListOf<SBReforgeRecipe>()
|
||||
for (reforge in ReforgeStore.findEligibleForInternalName(item.skyblockId)) {
|
||||
reforgeRecipes.add(SBReforgeRecipe(reforge, item.skyblockId))
|
||||
reforgeRecipes.add(SBReforgeRecipe(reforge, item))
|
||||
}
|
||||
for (reforge in ReforgeStore.findEligibleForItem(item.itemType ?: ItemType.NIL)) {
|
||||
reforgeRecipes.add(SBReforgeRecipe(reforge, item.skyblockId))
|
||||
reforgeRecipes.add(SBReforgeRecipe(reforge, item))
|
||||
}
|
||||
if (reforgeRecipes.isEmpty()) return Optional.empty()
|
||||
return Optional.of(reforgeRecipes)
|
||||
@@ -162,26 +162,27 @@ class SBReforgeRecipe(
|
||||
}
|
||||
}
|
||||
|
||||
private val eligibleItems =
|
||||
if (limitToItem != null) listOfNotNull(RepoManager.getNEUItem(limitToItem))
|
||||
else reforge.eligibleItems.flatMap {
|
||||
private val inputItems = run {
|
||||
if (limitToItem != null) return@run listOf(SBItemEntryDefinition.getEntry(limitToItem))
|
||||
val eligibleItems = reforge.eligibleItems.flatMap {
|
||||
when (it) {
|
||||
is Reforge.ReforgeEligibilityFilter.AllowsInternalName ->
|
||||
listOfNotNull(RepoManager.getNEUItem(it.internalName))
|
||||
is Reforge.ReforgeEligibilityFilter.AllowsInternalName ->
|
||||
listOfNotNull(RepoManager.getNEUItem(it.internalName))
|
||||
|
||||
is Reforge.ReforgeEligibilityFilter.AllowsItemType ->
|
||||
ReforgeStore.resolveItemType(it.itemType)
|
||||
.flatMapTo(mutableSetOf()) {
|
||||
(RepoItemTypeCache.byItemType[it] ?: listOf()) +
|
||||
(RepoItemTypeCache.byItemType[it.dungeonVariant] ?: listOf())
|
||||
}.toList()
|
||||
is Reforge.ReforgeEligibilityFilter.AllowsItemType ->
|
||||
ReforgeStore.resolveItemType(it.itemType)
|
||||
.flatMapTo(mutableSetOf()) {
|
||||
(RepoItemTypeCache.byItemType[it] ?: listOf()) +
|
||||
(RepoItemTypeCache.byItemType[it.dungeonVariant] ?: listOf())
|
||||
}.toList()
|
||||
|
||||
is Reforge.ReforgeEligibilityFilter.AllowsVanillaItemType -> {
|
||||
listOf() // TODO: add filter support for this and potentially rework this to search for the declared item type in repo, instead of remapped item type
|
||||
is Reforge.ReforgeEligibilityFilter.AllowsVanillaItemType -> {
|
||||
listOf() // TODO: add filter support for this and potentially rework this to search for the declared item type in repo, instead of remapped item type
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private val inputItems = eligibleItems.map { SBItemEntryDefinition.getEntry(it.skyblockId) }
|
||||
eligibleItems.map { SBItemEntryDefinition.getEntry(it.skyblockId) }
|
||||
}
|
||||
private val outputItems =
|
||||
inputItems.map { SBItemEntryDefinition.getEntry(it.value.copy(reforge = reforge.reforgeId)) }
|
||||
private val reforgeStone = reforge.reforgeStone?.let(SBItemEntryDefinition::getEntry)
|
||||
|
||||
Reference in New Issue
Block a user