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
28
29
30
31
32
33
34
35
36
|
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.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
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.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, 19 - 2 - MC.font.getWidth(countString), 6 + 3, 0xFFFFFF, true)
context.matrices.pop()
}
override fun addTooltip(tooltip: TooltipBuilder) {
tooltip.add(*stack.getTooltip(null, TooltipContext.BASIC).toTypedArray())
}
}
|