aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/WTitledItem.kt22
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) {