From 508b8352cfbc066b025943cf1cbf8be5e5edb88a Mon Sep 17 00:00:00 2001 From: nea Date: Thu, 4 May 2023 18:23:54 +0200 Subject: Add somewhat faulty crafting recipes --- .../moe/nea/notenoughupdates/rei/NEUReiPlugin.kt | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt') 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 { + override fun getRecipeFor(entry: EntryStack<*>): Optional> { + if (entry.type != SBItemEntryDefinition.type) return Optional.empty() + val item = entry.castValue() + val recipes = RepoManager.getRecipesFor(item.skyblockId) + val craftingRecipes = recipes.filterIsInstance() + return Optional.of(craftingRecipes.map { SBCraftingRecipe(it) }) + } + + override fun generate(builder: ViewSearchBuilder): Optional> { + if (SBCraftingRecipe.Category.catIdentifier !in builder.categories) return Optional.empty() + return Optional.of( + RepoManager.getAllRecipes().filterIsInstance().map { SBCraftingRecipe(it) } + .toList() + ) + } + + override fun getUsageFor(entry: EntryStack<*>): Optional> { + if (entry.type != SBItemEntryDefinition.type) return Optional.empty() + val item = entry.castValue() + val recipes = RepoManager.getUsagesFor(item.skyblockId) + val craftingRecipes = recipes.filterIsInstance() + return Optional.of(craftingRecipes.map { SBCraftingRecipe(it) }) + + } + }) + } + override fun registerCollapsibleEntries(registry: CollapsibleEntryRegistry) { RepoManager.neuRepo.constants.parents.parents .forEach { (parent, children) -> -- cgit