aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/rei
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-05 00:02:13 +0200
committernea <nea@nea.moe>2023-05-05 00:02:13 +0200
commitdc4866fe01abf7b33829bbfcd9d266c381c6c6af (patch)
tree89e8709a8781e943bd4eb6459564608b8cf4c4c6 /src/main/kotlin/moe/nea/notenoughupdates/rei
parent57885f1f71774a79ee08af024b872b73cadc05bd (diff)
downloadFirmament-dc4866fe01abf7b33829bbfcd9d266c381c6c6af.tar.gz
Firmament-dc4866fe01abf7b33829bbfcd9d266c381c6c6af.tar.bz2
Firmament-dc4866fe01abf7b33829bbfcd9d266c381c6c6af.zip
Add very bad forge recipes
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/rei')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt13
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt15
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockCraftingRecipeDynamicGenerator.kt52
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockRecipeDynamicGenerator.kt38
4 files changed, 74 insertions, 44 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
index 647862e..34d98fa 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
@@ -14,6 +14,7 @@ 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.recipes.SBForgeRecipe
import moe.nea.notenoughupdates.repo.ItemCache.asItemStack
import moe.nea.notenoughupdates.repo.RepoManager
import moe.nea.notenoughupdates.util.SkyblockId
@@ -23,7 +24,7 @@ class NEUReiPlugin : REIClientPlugin {
companion object {
fun EntryStack<NEUItem>.asItemEntry(): EntryStack<ItemStack> {
- return EntryStack.of(VanillaEntryTypes.ITEM, value?.asItemStack())
+ return EntryStack.of(VanillaEntryTypes.ITEM, value.asItemStack())
}
val SKYBLOCK_ITEM_TYPE_ID = Identifier("notenoughupdates", "skyblockitems")
@@ -35,10 +36,18 @@ class NEUReiPlugin : REIClientPlugin {
override fun registerCategories(registry: CategoryRegistry) {
registry.add(SBCraftingRecipe.Category)
+ registry.add(SBForgeRecipe.Category)
}
override fun registerDisplays(registry: DisplayRegistry) {
- registry.registerDisplayGenerator(SBCraftingRecipe.Category.catIdentifier, SkyblockRecipeDynamicGenerator)
+ registry.registerDisplayGenerator(
+ SBCraftingRecipe.Category.catIdentifier,
+ SkyblockCraftingRecipeDynamicGenerator
+ )
+ registry.registerDisplayGenerator(
+ SBForgeRecipe.Category.categoryIdentifier,
+ SkyblockForgeRecipeDynamicGenerator
+ )
}
override fun registerCollapsibleEntries(registry: CollapsibleEntryRegistry) {
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt
index b449848..0b43407 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt
@@ -1,5 +1,6 @@
package moe.nea.notenoughupdates.rei
+import io.github.moulberry.repo.data.NEUIngredient
import io.github.moulberry.repo.data.NEUItem
import java.util.stream.Stream
import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer
@@ -25,8 +26,8 @@ object SBItemEntryDefinition : EntryDefinition<NEUItem> {
return o1 === o2
}
- override fun cheatsAs(entry: EntryStack<NEUItem>?, value: NEUItem?): ItemStack? {
- return value?.asItemStack()
+ override fun cheatsAs(entry: EntryStack<NEUItem>?, value: NEUItem?): ItemStack {
+ return value.asItemStack()
}
override fun getValueType(): Class<NEUItem> = NEUItem::class.java
@@ -71,8 +72,14 @@ object SBItemEntryDefinition : EntryDefinition<NEUItem> {
return value?.getIdentifier() ?: Identifier.of("skyblockitem", "null")!!
}
- fun getEntry(neuItem: NEUItem?) = EntryStack.of(this, neuItem)
- fun getEntry(skyblockId: SkyblockId?) = EntryStack.of(this, skyblockId?.let { RepoManager.getNEUItem(it) })
+ fun getEntry(neuItem: NEUItem?): EntryStack<NEUItem> =
+ EntryStack.of(this, neuItem)
+
+ fun getEntry(skyblockId: SkyblockId?): EntryStack<NEUItem> =
+ EntryStack.of(this, skyblockId?.let { RepoManager.getNEUItem(it) })
+
+ fun getEntry(ingredient: NEUIngredient?): EntryStack<NEUItem> =
+ getEntry(ingredient?.itemId?.let { SkyblockId(it) })
}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockCraftingRecipeDynamicGenerator.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockCraftingRecipeDynamicGenerator.kt
new file mode 100644
index 0000000..cc31427
--- /dev/null
+++ b/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockCraftingRecipeDynamicGenerator.kt
@@ -0,0 +1,52 @@
+package moe.nea.notenoughupdates.rei
+
+import io.github.moulberry.repo.data.NEUCraftingRecipe
+import io.github.moulberry.repo.data.NEUForgeRecipe
+import io.github.moulberry.repo.data.NEUItem
+import io.github.moulberry.repo.data.NEURecipe
+import java.util.*
+import me.shedaniel.rei.api.client.registry.display.DynamicDisplayGenerator
+import me.shedaniel.rei.api.client.view.ViewSearchBuilder
+import me.shedaniel.rei.api.common.display.Display
+import me.shedaniel.rei.api.common.entry.EntryStack
+import moe.nea.notenoughupdates.recipes.SBCraftingRecipe
+import moe.nea.notenoughupdates.recipes.SBForgeRecipe
+import moe.nea.notenoughupdates.repo.RepoManager
+import moe.nea.notenoughupdates.util.skyblockId
+
+
+val SkyblockCraftingRecipeDynamicGenerator = neuDisplayGenerator<SBCraftingRecipe, NEUCraftingRecipe> {
+ SBCraftingRecipe(it)
+}
+
+val SkyblockForgeRecipeDynamicGenerator = neuDisplayGenerator<SBForgeRecipe, NEUForgeRecipe> {
+ SBForgeRecipe(it)
+}
+
+inline fun <D : Display, reified T : NEURecipe> neuDisplayGenerator(noinline mapper: (T) -> D) =
+ object : DynamicDisplayGenerator<D> {
+ override fun getRecipeFor(entry: EntryStack<*>): Optional<List<D>> {
+ if (entry.type != SBItemEntryDefinition.type) return Optional.empty()
+ val item = entry.castValue<NEUItem>()
+ val recipes = RepoManager.getRecipesFor(item.skyblockId)
+ val craftingRecipes = recipes.filterIsInstance<T>()
+ return Optional.of(craftingRecipes.map(mapper))
+ }
+
+ override fun generate(builder: ViewSearchBuilder): Optional<List<D>> {
+ if (SBCraftingRecipe.Category.catIdentifier !in builder.categories) return Optional.empty()
+ return Optional.of(
+ RepoManager.getAllRecipes().filterIsInstance<T>().map(mapper)
+ .toList()
+ )
+ }
+
+ override fun getUsageFor(entry: EntryStack<*>): Optional<List<D>> {
+ if (entry.type != SBItemEntryDefinition.type) return Optional.empty()
+ val item = entry.castValue<NEUItem>()
+ val recipes = RepoManager.getUsagesFor(item.skyblockId)
+ val craftingRecipes = recipes.filterIsInstance<T>()
+ return Optional.of(craftingRecipes.map(mapper))
+
+ }
+ }
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockRecipeDynamicGenerator.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockRecipeDynamicGenerator.kt
deleted file mode 100644
index 931e45c..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockRecipeDynamicGenerator.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-package moe.nea.notenoughupdates.rei
-
-import io.github.moulberry.repo.data.NEUCraftingRecipe
-import io.github.moulberry.repo.data.NEUItem
-import me.shedaniel.rei.api.client.registry.display.DynamicDisplayGenerator
-import me.shedaniel.rei.api.client.view.ViewSearchBuilder
-import me.shedaniel.rei.api.common.entry.EntryStack
-import moe.nea.notenoughupdates.recipes.SBCraftingRecipe
-import moe.nea.notenoughupdates.repo.RepoManager
-import moe.nea.notenoughupdates.util.skyblockId
-import java.util.*
-
-object SkyblockRecipeDynamicGenerator: 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) })
-
- }
-}