feat: allow disabling REI integration

This commit is contained in:
Linnea Gräf
2025-07-07 12:20:04 +02:00
parent 4d2876fb6c
commit 965bf944ba
4 changed files with 29 additions and 7 deletions

View File

@@ -2,9 +2,11 @@ package moe.nea.firmament.compat.rei
import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry
import me.shedaniel.rei.api.common.plugins.REICommonPlugin
import moe.nea.firmament.repo.RepoManager
class FirmamentReiCommonPlugin : REICommonPlugin {
override fun registerEntryTypes(registry: EntryTypeRegistry) {
if (!RepoManager.shouldLoadREI()) return
registry.register(FirmamentReiPlugin.SKYBLOCK_ITEM_TYPE_ID, SBItemEntryDefinition)
}
}

View File

@@ -55,6 +55,7 @@ class FirmamentReiPlugin : REIClientPlugin {
@OptIn(ExpensiveItemCacheApi::class)
override fun registerTransferHandlers(registry: TransferHandlerRegistry) {
if (!RepoManager.shouldLoadREI()) return
registry.register(TransferHandler { context ->
val screen = context.containerScreen
val display = context.display
@@ -64,8 +65,11 @@ class FirmamentReiPlugin : REIClientPlugin {
val neuItem = RepoManager.getNEUItem(SkyblockId(recipe.output.itemId))
?: error("Could not find neu item ${recipe.output.itemId} which is used in a recipe output")
val useSuperCraft = context.isStackedCrafting || RepoManager.Config.alwaysSuperCraft
if (neuItem.isVanilla && useSuperCraft) return@TransferHandler TransferHandler.Result.createFailed(Text.translatable(
"firmament.recipe.novanilla"))
if (neuItem.isVanilla && useSuperCraft) return@TransferHandler TransferHandler.Result.createFailed(
Text.translatable(
"firmament.recipe.novanilla"
)
)
var shouldReturn = true
if (context.isActuallyCrafting && !useSuperCraft) {
val craftingScreen = (screen as? GenericContainerScreen)
@@ -85,13 +89,16 @@ class FirmamentReiPlugin : REIClientPlugin {
}
val generics = listOf<GenericREIRecipeCategory<*>>( // Order matters: The order in here is the order in which they show up in REI
val generics = listOf<GenericREIRecipeCategory<*>>(
// Order matters: The order in here is the order in which they show up in REI
GenericREIRecipeCategory(SBCraftingRecipeRenderer),
GenericREIRecipeCategory(SBForgeRecipeRenderer),
GenericREIRecipeCategory(SBEssenceUpgradeRecipeRenderer),
)
override fun registerCategories(registry: CategoryRegistry) {
if (!RepoManager.shouldLoadREI()) return
registry.add(generics)
registry.add(SBMobDropRecipe.Category)
registry.add(SBKatRecipe.Category)
@@ -105,6 +112,8 @@ class FirmamentReiPlugin : REIClientPlugin {
}
override fun registerDisplays(registry: DisplayRegistry) {
if (!RepoManager.shouldLoadREI()) return
generics.forEach {
it.registerDynamicGenerator(registry)
}
@@ -114,16 +123,21 @@ class FirmamentReiPlugin : REIClientPlugin {
)
registry.registerDisplayGenerator(
SBMobDropRecipe.Category.categoryIdentifier,
SkyblockMobDropRecipeDynamicGenerator)
SkyblockMobDropRecipeDynamicGenerator
)
registry.registerDisplayGenerator(
SBShopRecipe.Category.categoryIdentifier,
SkyblockShopRecipeDynamicGenerator)
SkyblockShopRecipeDynamicGenerator
)
registry.registerDisplayGenerator(
SBKatRecipe.Category.categoryIdentifier,
SkyblockKatRecipeDynamicGenerator)
SkyblockKatRecipeDynamicGenerator
)
}
override fun registerCollapsibleEntries(registry: CollapsibleEntryRegistry) {
if (!RepoManager.shouldLoadREI()) return
if (!RepoManager.Config.disableItemGroups)
RepoManager.neuRepo.constants.parents.parents
.forEach { (parent, children) ->
@@ -148,6 +162,8 @@ class FirmamentReiPlugin : REIClientPlugin {
}
override fun registerEntries(registry: EntryRegistry) {
if (!RepoManager.shouldLoadREI()) return
registry.removeEntryIf { true }
RepoManager.neuRepo.items?.items?.values?.forEach { neuItem ->
registry.addEntry(SBItemEntryDefinition.getEntry(neuItem.skyblockId))

View File

@@ -35,7 +35,7 @@ object RepoManager {
branch = "master"
save()
}
val enableREI by toggle("enable-rei") { true }
val disableItemGroups by toggle("disable-item-groups") { true }
val reload by button("reload") {
save()
@@ -196,4 +196,6 @@ object RepoManager {
fun getRepoRef(): String {
return "${Config.username}/${Config.reponame}#${Config.branch}"
}
fun shouldLoadREI(): Boolean = Config.enableREI
}

View File

@@ -306,6 +306,8 @@
"firmament.config.repo.branch.hint": "dangerous",
"firmament.config.repo.disable-item-groups": "Disable Item Groups",
"firmament.config.repo.disable-item-groups.description": "Disabling item groups can increase performance, but will no longer collect similar items (like minions, enchantments) together.",
"firmament.config.repo.enable-rei": "Enable REI",
"firmament.config.repo.enable-rei.description": "REI is required for viewing Firmaments item list. If you want to use another item list provider like SkyBlockers, you can turn it off here. Without other mods this will make you revert back to the vanilla item list.",
"firmament.config.repo.enable-super-craft": "Always use Super Craft",
"firmament.config.repo.enable-super-craft.description": "Always use super craft when clicking the craft button in REI, instead of just when holding shift.",
"firmament.config.repo.perfect-renders": "Perfect Render",