diff options
author | nea <nea@nea.moe> | 2023-06-11 04:00:29 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-06-11 04:00:51 +0200 |
commit | 99fcad8360c3ac7755d70e581c6e2d63e8c49282 (patch) | |
tree | 1318d2a54a32d5f7b71442fa37bf788800119237 /src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt | |
parent | db8e3640e8f9c14b7027c9e92b810ed127391ced (diff) | |
download | firmament-99fcad8360c3ac7755d70e581c6e2d63e8c49282.tar.gz firmament-99fcad8360c3ac7755d70e581c6e2d63e8c49282.tar.bz2 firmament-99fcad8360c3ac7755d70e581c6e2d63e8c49282.zip |
Add more info to the pets 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 | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt b/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt index ff9e894..07850fc 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt @@ -1,22 +1,32 @@ package moe.nea.firmament.gui +import com.mojang.blaze3d.systems.RenderSystem 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 io.github.cottonmc.cotton.gui.widget.WWidget +import org.joml.AxisAngle4d +import org.joml.Quaternionf +import org.joml.Vector3f +import kotlin.math.PI 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) { +open class WTitledItem(var stack: ItemStack, val countString: Text = Text.empty()) : WWidget() { + var backgroundPainter:BackgroundPainter = BackgroundPainter.SLOT + override fun canResize(): Boolean = true 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) + backgroundPainter.paintBackground(context, x, y, this) context.matrices.push() + context.matrices.translate(x.toFloat(), y.toFloat(), 0F) + context.matrices.scale(width / 18F, height / 18F, 1F) + RenderSystem.enableDepthTest() + context.drawItemWithoutEntity(stack, 18 / 2 - 8, 18 / 2 - 8) 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() + context.drawText(MC.font, countString, 19 - 2 - MC.font.getWidth(countString), 6 + 3, 0xFFFFFF, true) + context.matrices.pop() } override fun addTooltip(tooltip: TooltipBuilder) { |