feat: allow disabling REI integration
This commit is contained in:
@@ -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.entry.type.EntryTypeRegistry
|
||||||
import me.shedaniel.rei.api.common.plugins.REICommonPlugin
|
import me.shedaniel.rei.api.common.plugins.REICommonPlugin
|
||||||
|
import moe.nea.firmament.repo.RepoManager
|
||||||
|
|
||||||
class FirmamentReiCommonPlugin : REICommonPlugin {
|
class FirmamentReiCommonPlugin : REICommonPlugin {
|
||||||
override fun registerEntryTypes(registry: EntryTypeRegistry) {
|
override fun registerEntryTypes(registry: EntryTypeRegistry) {
|
||||||
|
if (!RepoManager.shouldLoadREI()) return
|
||||||
registry.register(FirmamentReiPlugin.SKYBLOCK_ITEM_TYPE_ID, SBItemEntryDefinition)
|
registry.register(FirmamentReiPlugin.SKYBLOCK_ITEM_TYPE_ID, SBItemEntryDefinition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class FirmamentReiPlugin : REIClientPlugin {
|
|||||||
|
|
||||||
@OptIn(ExpensiveItemCacheApi::class)
|
@OptIn(ExpensiveItemCacheApi::class)
|
||||||
override fun registerTransferHandlers(registry: TransferHandlerRegistry) {
|
override fun registerTransferHandlers(registry: TransferHandlerRegistry) {
|
||||||
|
if (!RepoManager.shouldLoadREI()) return
|
||||||
registry.register(TransferHandler { context ->
|
registry.register(TransferHandler { context ->
|
||||||
val screen = context.containerScreen
|
val screen = context.containerScreen
|
||||||
val display = context.display
|
val display = context.display
|
||||||
@@ -64,8 +65,11 @@ class FirmamentReiPlugin : REIClientPlugin {
|
|||||||
val neuItem = RepoManager.getNEUItem(SkyblockId(recipe.output.itemId))
|
val neuItem = RepoManager.getNEUItem(SkyblockId(recipe.output.itemId))
|
||||||
?: error("Could not find neu item ${recipe.output.itemId} which is used in a recipe output")
|
?: error("Could not find neu item ${recipe.output.itemId} which is used in a recipe output")
|
||||||
val useSuperCraft = context.isStackedCrafting || RepoManager.Config.alwaysSuperCraft
|
val useSuperCraft = context.isStackedCrafting || RepoManager.Config.alwaysSuperCraft
|
||||||
if (neuItem.isVanilla && useSuperCraft) return@TransferHandler TransferHandler.Result.createFailed(Text.translatable(
|
if (neuItem.isVanilla && useSuperCraft) return@TransferHandler TransferHandler.Result.createFailed(
|
||||||
"firmament.recipe.novanilla"))
|
Text.translatable(
|
||||||
|
"firmament.recipe.novanilla"
|
||||||
|
)
|
||||||
|
)
|
||||||
var shouldReturn = true
|
var shouldReturn = true
|
||||||
if (context.isActuallyCrafting && !useSuperCraft) {
|
if (context.isActuallyCrafting && !useSuperCraft) {
|
||||||
val craftingScreen = (screen as? GenericContainerScreen)
|
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(SBCraftingRecipeRenderer),
|
||||||
GenericREIRecipeCategory(SBForgeRecipeRenderer),
|
GenericREIRecipeCategory(SBForgeRecipeRenderer),
|
||||||
GenericREIRecipeCategory(SBEssenceUpgradeRecipeRenderer),
|
GenericREIRecipeCategory(SBEssenceUpgradeRecipeRenderer),
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun registerCategories(registry: CategoryRegistry) {
|
override fun registerCategories(registry: CategoryRegistry) {
|
||||||
|
if (!RepoManager.shouldLoadREI()) return
|
||||||
|
|
||||||
registry.add(generics)
|
registry.add(generics)
|
||||||
registry.add(SBMobDropRecipe.Category)
|
registry.add(SBMobDropRecipe.Category)
|
||||||
registry.add(SBKatRecipe.Category)
|
registry.add(SBKatRecipe.Category)
|
||||||
@@ -105,6 +112,8 @@ class FirmamentReiPlugin : REIClientPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun registerDisplays(registry: DisplayRegistry) {
|
override fun registerDisplays(registry: DisplayRegistry) {
|
||||||
|
if (!RepoManager.shouldLoadREI()) return
|
||||||
|
|
||||||
generics.forEach {
|
generics.forEach {
|
||||||
it.registerDynamicGenerator(registry)
|
it.registerDynamicGenerator(registry)
|
||||||
}
|
}
|
||||||
@@ -114,16 +123,21 @@ class FirmamentReiPlugin : REIClientPlugin {
|
|||||||
)
|
)
|
||||||
registry.registerDisplayGenerator(
|
registry.registerDisplayGenerator(
|
||||||
SBMobDropRecipe.Category.categoryIdentifier,
|
SBMobDropRecipe.Category.categoryIdentifier,
|
||||||
SkyblockMobDropRecipeDynamicGenerator)
|
SkyblockMobDropRecipeDynamicGenerator
|
||||||
|
)
|
||||||
registry.registerDisplayGenerator(
|
registry.registerDisplayGenerator(
|
||||||
SBShopRecipe.Category.categoryIdentifier,
|
SBShopRecipe.Category.categoryIdentifier,
|
||||||
SkyblockShopRecipeDynamicGenerator)
|
SkyblockShopRecipeDynamicGenerator
|
||||||
|
)
|
||||||
registry.registerDisplayGenerator(
|
registry.registerDisplayGenerator(
|
||||||
SBKatRecipe.Category.categoryIdentifier,
|
SBKatRecipe.Category.categoryIdentifier,
|
||||||
SkyblockKatRecipeDynamicGenerator)
|
SkyblockKatRecipeDynamicGenerator
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun registerCollapsibleEntries(registry: CollapsibleEntryRegistry) {
|
override fun registerCollapsibleEntries(registry: CollapsibleEntryRegistry) {
|
||||||
|
if (!RepoManager.shouldLoadREI()) return
|
||||||
|
|
||||||
if (!RepoManager.Config.disableItemGroups)
|
if (!RepoManager.Config.disableItemGroups)
|
||||||
RepoManager.neuRepo.constants.parents.parents
|
RepoManager.neuRepo.constants.parents.parents
|
||||||
.forEach { (parent, children) ->
|
.forEach { (parent, children) ->
|
||||||
@@ -148,6 +162,8 @@ class FirmamentReiPlugin : REIClientPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun registerEntries(registry: EntryRegistry) {
|
override fun registerEntries(registry: EntryRegistry) {
|
||||||
|
if (!RepoManager.shouldLoadREI()) return
|
||||||
|
|
||||||
registry.removeEntryIf { true }
|
registry.removeEntryIf { true }
|
||||||
RepoManager.neuRepo.items?.items?.values?.forEach { neuItem ->
|
RepoManager.neuRepo.items?.items?.values?.forEach { neuItem ->
|
||||||
registry.addEntry(SBItemEntryDefinition.getEntry(neuItem.skyblockId))
|
registry.addEntry(SBItemEntryDefinition.getEntry(neuItem.skyblockId))
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ object RepoManager {
|
|||||||
branch = "master"
|
branch = "master"
|
||||||
save()
|
save()
|
||||||
}
|
}
|
||||||
|
val enableREI by toggle("enable-rei") { true }
|
||||||
val disableItemGroups by toggle("disable-item-groups") { true }
|
val disableItemGroups by toggle("disable-item-groups") { true }
|
||||||
val reload by button("reload") {
|
val reload by button("reload") {
|
||||||
save()
|
save()
|
||||||
@@ -196,4 +196,6 @@ object RepoManager {
|
|||||||
fun getRepoRef(): String {
|
fun getRepoRef(): String {
|
||||||
return "${Config.username}/${Config.reponame}#${Config.branch}"
|
return "${Config.username}/${Config.reponame}#${Config.branch}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun shouldLoadREI(): Boolean = Config.enableREI
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -306,6 +306,8 @@
|
|||||||
"firmament.config.repo.branch.hint": "dangerous",
|
"firmament.config.repo.branch.hint": "dangerous",
|
||||||
"firmament.config.repo.disable-item-groups": "Disable Item Groups",
|
"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.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": "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.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",
|
"firmament.config.repo.perfect-renders": "Perfect Render",
|
||||||
|
|||||||
Reference in New Issue
Block a user