refactor: Make use of generic crafting recipe

This commit is contained in:
Linnea Gräf
2025-05-09 19:03:27 +02:00
parent 44c24712b7
commit f925bd2a8d
6 changed files with 88 additions and 74 deletions

View File

@@ -16,4 +16,5 @@ interface GenericRecipeRenderer<T : NEURecipe> {
val title: Text
val identifier: Identifier
fun findAllRecipes(neuRepository: NEURepository): Iterable<T>
val typ: Class<T>
}

View File

@@ -12,7 +12,7 @@ import moe.nea.firmament.Firmament
import moe.nea.firmament.repo.SBItemStack
import moe.nea.firmament.util.tr
class SBCraftingRecipeRenderer : GenericRecipeRenderer<NEUCraftingRecipe> {
object SBCraftingRecipeRenderer : GenericRecipeRenderer<NEUCraftingRecipe> {
override fun render(recipe: NEUCraftingRecipe, bounds: Rectangle, layouter: RecipeLayouter) {
val point = Point(bounds.centerX - 58, bounds.centerY - 27)
layouter.createArrow(point.x + 60, point.y + 18)
@@ -32,6 +32,9 @@ class SBCraftingRecipeRenderer : GenericRecipeRenderer<NEUCraftingRecipe> {
)
}
override val typ: Class<NEUCraftingRecipe>
get() = NEUCraftingRecipe::class.java
override fun getInputs(recipe: NEUCraftingRecipe): Collection<SBItemStack> {
return recipe.allInputs.mapNotNull { SBItemStack(it) }
}