diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt b/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt new file mode 100644 index 0000000..ff9e894 --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt @@ -0,0 +1,26 @@ +package moe.nea.firmament.gui + +import io.github.cottonmc.cotton.gui.client.BackgroundPainter +import io.github.cottonmc.cotton.gui.widget.TooltipBuilder +import io.github.cottonmc.cotton.gui.widget.WItem +import net.minecraft.client.gui.DrawContext +import net.minecraft.client.item.TooltipContext +import net.minecraft.item.ItemStack +import net.minecraft.text.Text +import moe.nea.firmament.util.MC + +class WTitledItem(val stack: ItemStack, val countString: Text = Text.empty()) : WItem(stack) { + override fun paint(context: DrawContext, x: Int, y: Int, mouseX: Int, mouseY: Int) { + BackgroundPainter.SLOT.paintBackground(context, x, y, this) + super.paint(context, x, y, mouseX, mouseY) + context.matrices.push() + context.matrices.translate(0F, 0F, 200F) + context.drawText(MC.font, countString, x + 19 - 2 - MC.font.getWidth(countString), y + 6 + 3, 0xFFFFFF, true) + context.matrices.push() + } + + override fun addTooltip(tooltip: TooltipBuilder) { + tooltip.add(*stack.getTooltip(null, TooltipContext.BASIC).toTypedArray()) + } + +} |