diff options
author | nea <nea@nea.moe> | 2023-06-11 02:43:14 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-06-11 02:43:14 +0200 |
commit | a36c8f1c0eae969dcee8cf690f12d9121350212d (patch) | |
tree | ea93f19bf5f77f8b5e42a7b56162d9b6492b7fed /src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt | |
parent | 040f7c7275568d783bfa5e4ed20412f72d126549 (diff) | |
download | firmament-a36c8f1c0eae969dcee8cf690f12d9121350212d.tar.gz firmament-a36c8f1c0eae969dcee8cf690f12d9121350212d.tar.bz2 firmament-a36c8f1c0eae969dcee8cf690f12d9121350212d.zip |
Add collection info to skill page
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()) + } + +} |