diff options
| author | Twarug <patryk@twardosz.dev> | 2025-08-04 00:30:00 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-08-24 15:18:01 +0200 |
| commit | 40d7e4f7ad2a5ee2a829f51d6c3b6eebe545b795 (patch) | |
| tree | e0d08eb26692397e5b8584054d08ca7db5c65508 | |
| parent | 2c6a0d8bd7ca9063027d5156beb0d9d313ee04f2 (diff) | |
| download | Firmament-40d7e4f7ad2a5ee2a829f51d6c3b6eebe545b795.tar.gz Firmament-40d7e4f7ad2a5ee2a829f51d6c3b6eebe545b795.tar.bz2 Firmament-40d7e4f7ad2a5ee2a829f51d6c3b6eebe545b795.zip | |
feat: add recipe requirements tooltips
| -rw-r--r-- | src/main/kotlin/repo/recipes/SBCraftingRecipeRenderer.kt | 19 | ||||
| -rw-r--r-- | src/main/kotlin/repo/recipes/SBForgeRecipeRenderer.kt | 28 | ||||
| -rw-r--r-- | translations/en_us.json | 1 |
3 files changed, 40 insertions, 8 deletions
diff --git a/src/main/kotlin/repo/recipes/SBCraftingRecipeRenderer.kt b/src/main/kotlin/repo/recipes/SBCraftingRecipeRenderer.kt index e38380c..01d9b7c 100644 --- a/src/main/kotlin/repo/recipes/SBCraftingRecipeRenderer.kt +++ b/src/main/kotlin/repo/recipes/SBCraftingRecipeRenderer.kt @@ -20,7 +20,24 @@ object SBCraftingRecipeRenderer : GenericRecipeRenderer<NEUCraftingRecipe> { mainItem: SBItemStack?, ) { val point = Point(bounds.centerX - 58, bounds.centerY - 27) - layouter.createArrow(point.x + 60, point.y + 18) + val arrow = layouter.createArrow(point.x + 60, point.y + 18) + + if (recipe.extraText != null && recipe.extraText!!.isNotBlank()) { + val parts = recipe.extraText!!.split(' ') + + if (parts.size >= 3) { + val requirement = parts.drop(1).joinToString(separator = " ") + + layouter.createTooltip( + arrow, + Text.stringifiedTranslatable( + "firmament.recipe.requirement", + requirement + ) + ) + } + } + for (i in 0 until 3) { for (j in 0 until 3) { val item = recipe.inputs[i + j * 3] diff --git a/src/main/kotlin/repo/recipes/SBForgeRecipeRenderer.kt b/src/main/kotlin/repo/recipes/SBForgeRecipeRenderer.kt index 9fdb756..c4fce04 100644 --- a/src/main/kotlin/repo/recipes/SBForgeRecipeRenderer.kt +++ b/src/main/kotlin/repo/recipes/SBForgeRecipeRenderer.kt @@ -1,7 +1,6 @@ package moe.nea.firmament.repo.recipes import io.github.moulberry.repo.NEURepository -import io.github.moulberry.repo.data.NEUCraftingRecipe import io.github.moulberry.repo.data.NEUForgeRecipe import me.shedaniel.math.Point import me.shedaniel.math.Rectangle @@ -24,13 +23,28 @@ object SBForgeRecipeRenderer : GenericRecipeRenderer<NEUForgeRecipe> { mainItem: SBItemStack?, ) { val arrow = layouter.createArrow(bounds.minX + 90, bounds.minY + 54 - 18 / 2) - layouter.createTooltip( - arrow, - Text.stringifiedTranslatable( + val tooltip = Text.empty() + .append(Text.stringifiedTranslatable( "firmament.recipe.forge.time", - recipe.duration.seconds - ) - ) + recipe.duration.seconds, + )) + + if (recipe.extraText != null && recipe.extraText!!.isNotBlank()) { + val parts = recipe.extraText!!.split(' ') + + if (parts.size >= 3) { + val requirement = parts.drop(1).joinToString(separator = " ") + + tooltip + .append(Text.of("\n")) + .append(Text.stringifiedTranslatable( + "firmament.recipe.requirement", + requirement, + )) + } + } + + layouter.createTooltip(arrow, tooltip) val ingredientsCenter = Point(bounds.minX + 49 - 8, bounds.minY + 54 - 8) layouter.createFire(ingredientsCenter, 25) diff --git a/translations/en_us.json b/translations/en_us.json index f9ec850..2dbcc3a 100644 --- a/translations/en_us.json +++ b/translations/en_us.json @@ -503,6 +503,7 @@ "firmament.quick-commands.join.unknown": "Could not find instance for %s", "firmament.quick-commands.join.unknown-catacombs": "Unknown catacombs floor %s", "firmament.quick-commands.join.unknown-kuudra": "Unknown kuudra floor %s", + "firmament.recipe.requirement": "Requires: %s", "firmament.recipe.forge.time": "Forging Time: %s", "firmament.recipe.mobs.coins": "§eCoins: %s", "firmament.recipe.mobs.combat": "§bCombat Experience: %s", |
