aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/items/recipes/ComponentWidget.kt
blob: 08a2aa255efdda3203c9723736dfe86b62ad908e (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(override var position: Point, var text: Component) : RecipeWidget(), RecipeLayouter.Updater<Component> {
	override fun update(newValue: Component) {
		this.text = newValue
	}

	override val size: Dimension
		get() = Dimension(MC.font.width(text), MC.font.lineHeight)

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