aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/items/recipes/ComponentWidget.kt
blob: b5c4211742023fd2d70982d29213b44728d6622c (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
package moe.nea.firmament.features.items.recipes

import me.shedaniel.math.Dimension
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component
import moe.nea.firmament.repo.recipes.RecipeLayouter
import moe.nea.firmament.util.MC

class ComponentWidget(val point: Point, var text: Component) : RecipeWidget(), RecipeLayouter.Updater<Component> {
	override fun update(newValue: Component) {
		this.text = newValue
	}

	override val rect: Rectangle
		get() = Rectangle(point, Dimension(MC.font.width(text), MC.font.lineHeight))

	override fun render(
		guiGraphics: GuiGraphics,
		mouseX: Int,
		mouseY: Int,
		partialTick: Float
	) {
		guiGraphics.drawString(MC.font, text, point.x, point.y, -1)
	}
}