From 3f33928c8fefe4816af9d538fa3fce48d5e76f7c Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Mon, 24 Nov 2025 21:49:16 +0100 Subject: feat(recipe viewer): moulconfig widget --- .../features/items/recipes/MoulConfigWidget.kt | 46 ++++++++++++++++++++++ .../items/recipes/StandaloneRecipeRenderer.kt | 3 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/features/items/recipes/MoulConfigWidget.kt (limited to 'src/main/kotlin/features/items') 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) { -- cgit