diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-11-24 21:49:16 +0100 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-11-24 21:49:16 +0100 |
| commit | 3f33928c8fefe4816af9d538fa3fce48d5e76f7c (patch) | |
| tree | 75a01dae80643f0b831a875c10272173130243b7 /src/main/kotlin/features/items/recipes | |
| parent | 20458e27c44ac498950cfaf408c35e7170d2a875 (diff) | |
| download | Firmament-3f33928c8fefe4816af9d538fa3fce48d5e76f7c.tar.gz Firmament-3f33928c8fefe4816af9d538fa3fce48d5e76f7c.tar.bz2 Firmament-3f33928c8fefe4816af9d538fa3fce48d5e76f7c.zip | |
feat(recipe viewer): moulconfig widget
Diffstat (limited to 'src/main/kotlin/features/items/recipes')
| -rw-r--r-- | src/main/kotlin/features/items/recipes/MoulConfigWidget.kt | 46 | ||||
| -rw-r--r-- | src/main/kotlin/features/items/recipes/StandaloneRecipeRenderer.kt | 3 |
2 files changed, 48 insertions, 1 deletions
diff --git a/src/main/kotlin/features/items/recipes/MoulConfigWidget.kt b/src/main/kotlin/features/items/recipes/MoulConfigWidget.kt new file mode 100644 index 0000000..aad3bda --- /dev/null +++ b/src/main/kotlin/features/items/recipes/MoulConfigWidget.kt @@ -0,0 +1,46 @@ +package moe.nea.firmament.features.items.recipes + +import io.github.notenoughupdates.moulconfig.gui.GuiComponent +import io.github.notenoughupdates.moulconfig.gui.MouseEvent +import me.shedaniel.math.Dimension +import me.shedaniel.math.Point +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.input.MouseButtonEvent +import moe.nea.firmament.util.MoulConfigUtils.createAndTranslateFullContext + +class MoulConfigWidget( + val component: GuiComponent, + override var position: Point, + override val size: Dimension, +) : RecipeWidget() { + override fun render( + guiGraphics: GuiGraphics, + mouseX: Int, + mouseY: Int, + partialTick: Float + ) { + createAndTranslateFullContext( + guiGraphics, mouseX, mouseY, rect, + component::render + ) + } + + override fun mouseClicked(event: MouseButtonEvent, isDoubleClick: Boolean): Boolean { + return createAndTranslateFullContext(null, event.x.toInt(), event.y.toInt(), rect) { + component.mouseEvent(MouseEvent.Click(event.button(), true), it) + } + } + + override fun mouseMoved(mouseX: Double, mouseY: Double) { + createAndTranslateFullContext(null, mouseX, mouseY, rect) { + component.mouseEvent(MouseEvent.Move(0F, 0F), it) + } + } + + override fun mouseReleased(event: MouseButtonEvent): Boolean { + return createAndTranslateFullContext(null, event.x, event.y, rect) { + component.mouseEvent(MouseEvent.Click(event.button(), false), it) + } + } + +} diff --git a/src/main/kotlin/features/items/recipes/StandaloneRecipeRenderer.kt b/src/main/kotlin/features/items/recipes/StandaloneRecipeRenderer.kt index fb11592..5a834eb 100644 --- a/src/main/kotlin/features/items/recipes/StandaloneRecipeRenderer.kt +++ b/src/main/kotlin/features/items/recipes/StandaloneRecipeRenderer.kt @@ -1,6 +1,7 @@ package moe.nea.firmament.features.items.recipes import io.github.notenoughupdates.moulconfig.gui.GuiComponent +import me.shedaniel.math.Dimension import me.shedaniel.math.Point import me.shedaniel.math.Rectangle import net.minecraft.client.gui.components.events.AbstractContainerEventHandler @@ -58,7 +59,7 @@ class StandaloneRecipeRenderer(val bounds: Rectangle) : AbstractContainerEventHa h: Int, component: GuiComponent ) { - TODO("Not yet implemented") + addWidget(MoulConfigWidget(component, Point(x, y), Dimension(w, h))) } override fun createFire(point: Point, animationTicks: Int) { |
