diff options
author | nea <nea@nea.moe> | 2023-05-04 18:23:54 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-05-04 18:23:54 +0200 |
commit | 508b8352cfbc066b025943cf1cbf8be5e5edb88a (patch) | |
tree | 6551a7fcdcaa90cd19aa5ce0025837eeedfa948b /src/main/kotlin/moe/nea/notenoughupdates/rei | |
parent | a9f4aed56bed61f621a3a3faca2b77a085caabb6 (diff) | |
download | Firmament-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')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt | 40 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt | 4 |
2 files changed, 44 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) -> diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt index 90d5931..b449848 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt @@ -16,7 +16,10 @@ import net.minecraft.util.Identifier import moe.nea.notenoughupdates.rei.NEUReiPlugin.Companion.asItemEntry import moe.nea.notenoughupdates.repo.ItemCache.asItemStack import moe.nea.notenoughupdates.repo.ItemCache.getIdentifier +import moe.nea.notenoughupdates.repo.RepoManager +import moe.nea.notenoughupdates.util.SkyblockId +// TODO: allow stackable entries object SBItemEntryDefinition : EntryDefinition<NEUItem> { override fun equals(o1: NEUItem?, o2: NEUItem?, context: ComparisonContext?): Boolean { return o1 === o2 @@ -69,6 +72,7 @@ object SBItemEntryDefinition : EntryDefinition<NEUItem> { } fun getEntry(neuItem: NEUItem?) = EntryStack.of(this, neuItem) + fun getEntry(skyblockId: SkyblockId?) = EntryStack.of(this, skyblockId?.let { RepoManager.getNEUItem(it) }) } |