aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/repo/recipes/SBEssenceUpgradeRecipeRenderer.kt
blob: 0f5271f7e0ac85359a333f3149338b6892e0e835 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package moe.nea.firmament.repo.recipes

import io.github.moulberry.repo.NEURepository
import io.github.moulberry.repo.data.NEUForgeRecipe
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
import net.minecraft.item.ItemStack
import net.minecraft.text.Text
import net.minecraft.util.Identifier
import moe.nea.firmament.Firmament
import moe.nea.firmament.repo.EssenceRecipeProvider
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.repo.SBItemStack
import moe.nea.firmament.util.SkyblockId
import moe.nea.firmament.util.tr

object SBEssenceUpgradeRecipeRenderer : GenericRecipeRenderer<EssenceRecipeProvider.EssenceUpgradeRecipe> {
	override fun render(
		recipe: EssenceRecipeProvider.EssenceUpgradeRecipe,
		bounds: Rectangle,
		layouter: RecipeLayouter,
		mainItem: SBItemStack?
	) {
		val sourceItem = mainItem ?: SBItemStack(recipe.itemId)
		layouter.createItemSlot(
			bounds.minX + 12,
			bounds.centerY - 8 - 18 / 2,
			sourceItem.copy(stars = recipe.starCountAfter - 1),
			RecipeLayouter.SlotKind.SMALL_INPUT
			)
		layouter.createItemSlot(
			bounds.minX + 12, bounds.centerY - 8 + 18 / 2,
			SBItemStack(recipe.essenceIngredient),
			RecipeLayouter.SlotKind.SMALL_INPUT
		)
		layouter.createItemSlot(
			bounds.maxX - 12 - 16, bounds.centerY - 8,
			sourceItem.copy(stars = recipe.starCountAfter),
			RecipeLayouter.SlotKind.SMALL_OUTPUT
		)
		val extraItems = recipe.extraItems
		layouter.createArrow(
			bounds.centerX - 24 / 2,
			if (extraItems.isEmpty()) bounds.centerY - 17 / 2
			else bounds.centerY + 18 / 2
		)
		for ((index, item) in extraItems.withIndex()) {
			layouter.createItemSlot(
				bounds.centerX - extraItems.size * 16 / 2 - 2 / 2 + index * 18,
				bounds.centerY - 18 / 2,
				SBItemStack(item),
				RecipeLayouter.SlotKind.SMALL_INPUT,
			)
		}
	}

	override fun getInputs(recipe: EssenceRecipeProvider.EssenceUpgradeRecipe): Collection<SBItemStack> {
		return recipe.allInputs.mapNotNull { SBItemStack(it) }
	}

	override fun getOutputs(recipe: EssenceRecipeProvider.EssenceUpgradeRecipe): Collection<SBItemStack> {
		return listOfNotNull(SBItemStack(recipe.itemId))
	}

	override val icon: ItemStack get() = SBItemStack(SkyblockId("ESSENCE_WITHER")).asImmutableItemStack()
	override val title: Text = tr("firmament.category.essence", "Essence Upgrades")
	override val identifier: Identifier = Firmament.identifier("essence_upgrade")
	override fun findAllRecipes(neuRepository: NEURepository): Iterable<EssenceRecipeProvider.EssenceUpgradeRecipe> {
		return RepoManager.essenceRecipeProvider.recipes
	}

	override val typ: Class<EssenceRecipeProvider.EssenceUpgradeRecipe>
		get() = EssenceRecipeProvider.EssenceUpgradeRecipe::class.java
}