Merge branch '1.19.4' into 1.19.3

This commit is contained in:
DBotThePony 2024-01-01 22:44:09 +07:00
commit 8a891e6ffb
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -92,22 +92,33 @@ class MGUIGraphics(val pose: PoseStack) {
val preEvent = ForgeHooksClient.onRenderTooltipPre(itemStack, pose, x, y, width, height, mapped, font, font)
if (preEvent.isCanceled) return
var i = 0
var j = if (lines.size == 1) -2 else 0
var totalWidth = 0
var totalHeight = if (lines.size == 1) -2 else 0
for (line in mapped) {
val k = line.getWidth(preEvent.font)
if (k > i) i = k
j += line.height
if (k > totalWidth) totalWidth = k
totalHeight += line.height
}
@Suppress("NAME_SHADOWING")
var x = x + 12
@Suppress("NAME_SHADOWING")
var y = y - 12
if (x + totalWidth >= minecraft.window.guiScaledWidth)
x = (x - 24 - totalWidth).coerceAtLeast(4)
if (y + totalHeight + 3 >= minecraft.window.guiScaledHeight)
y = minecraft.window.guiScaledHeight - totalHeight - 3
pose.pushPose()
val tesselator = Tesselator.getInstance()
val bufferbuilder = tesselator.builder
RenderSystem.setShader { GameRenderer.getPositionColorShader() }
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR)
val matrix4f = pose.last().pose()
TooltipRenderUtil.renderTooltipBackground(GuiComponent::fillGradient, matrix4f, bufferbuilder, x, y, i, j, 400)
TooltipRenderUtil.renderTooltipBackground(GuiComponent::fillGradient, matrix4f, bufferbuilder, x, y, totalWidth, totalHeight, 400)
RenderSystem.enableDepthTest()
RenderSystem.disableTexture()
RenderSystem.enableBlend()