aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-04 18:23:54 +0200
committernea <nea@nea.moe>2023-05-04 18:23:54 +0200
commit508b8352cfbc066b025943cf1cbf8be5e5edb88a (patch)
tree6551a7fcdcaa90cd19aa5ce0025837eeedfa948b /src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
parenta9f4aed56bed61f621a3a3faca2b77a085caabb6 (diff)
downloadfirmament-508b8352cfbc066b025943cf1cbf8be5e5edb88a.tar.gz
firmament-508b8352cfbc066b025943cf1cbf8be5e5edb88a.tar.bz2
firmament-508b8352cfbc066b025943cf1cbf8be5e5edb88a.zip
Add somewhat faulty crafting recipes
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
index de515f3..2bf3a5b 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
@@ -1,19 +1,27 @@
package moe.nea.notenoughupdates.rei
+import io.github.moulberry.repo.data.NEUCraftingRecipe
import io.github.moulberry.repo.data.NEUItem
+import java.util.*
import me.shedaniel.rei.api.client.plugins.REIClientPlugin
+import me.shedaniel.rei.api.client.registry.category.CategoryRegistry
+import me.shedaniel.rei.api.client.registry.display.DisplayRegistry
+import me.shedaniel.rei.api.client.registry.display.DynamicDisplayGenerator
import me.shedaniel.rei.api.client.registry.entry.CollapsibleEntryRegistry
import me.shedaniel.rei.api.client.registry.entry.EntryRegistry
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry
+import me.shedaniel.rei.api.client.view.ViewSearchBuilder
import me.shedaniel.rei.api.common.entry.EntryStack
import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes
import net.minecraft.item.ItemStack
import net.minecraft.text.Text
import net.minecraft.util.Identifier
+import moe.nea.notenoughupdates.recipes.SBCraftingRecipe
import moe.nea.notenoughupdates.repo.ItemCache.asItemStack
import moe.nea.notenoughupdates.repo.RepoManager
import moe.nea.notenoughupdates.util.SkyblockId
+import moe.nea.notenoughupdates.util.skyblockId
class NEUReiPlugin : REIClientPlugin {
@@ -30,6 +38,38 @@ class NEUReiPlugin : REIClientPlugin {
registry.register(SKYBLOCK_ITEM_TYPE_ID, SBItemEntryDefinition)
}
+ override fun registerCategories(registry: CategoryRegistry) {
+ registry.add(SBCraftingRecipe.Category)
+ }
+ override fun registerDisplays(registry: DisplayRegistry) {
+ registry.registerGlobalDisplayGenerator(object : DynamicDisplayGenerator<SBCraftingRecipe> {
+ override fun getRecipeFor(entry: EntryStack<*>): Optional<List<SBCraftingRecipe>> {
+ if (entry.type != SBItemEntryDefinition.type) return Optional.empty()
+ val item = entry.castValue<NEUItem>()
+ val recipes = RepoManager.getRecipesFor(item.skyblockId)
+ val craftingRecipes = recipes.filterIsInstance<NEUCraftingRecipe>()
+ return Optional.of(craftingRecipes.map { SBCraftingRecipe(it) })
+ }
+
+ override fun generate(builder: ViewSearchBuilder): Optional<List<SBCraftingRecipe>> {
+ if (SBCraftingRecipe.Category.catIdentifier !in builder.categories) return Optional.empty()
+ return Optional.of(
+ RepoManager.getAllRecipes().filterIsInstance<NEUCraftingRecipe>().map { SBCraftingRecipe(it) }
+ .toList()
+ )
+ }
+
+ override fun getUsageFor(entry: EntryStack<*>): Optional<List<SBCraftingRecipe>> {
+ if (entry.type != SBItemEntryDefinition.type) return Optional.empty()
+ val item = entry.castValue<NEUItem>()
+ val recipes = RepoManager.getUsagesFor(item.skyblockId)
+ val craftingRecipes = recipes.filterIsInstance<NEUCraftingRecipe>()
+ return Optional.of(craftingRecipes.map { SBCraftingRecipe(it) })
+
+ }
+ })
+ }
+
override fun registerCollapsibleEntries(registry: CollapsibleEntryRegistry) {
RepoManager.neuRepo.constants.parents.parents
.forEach { (parent, children) ->