@@ -17,13 +17,20 @@ import net.ccbluex.liquidbounce.ui.client.clickgui.style.styles.nlclickgui.anima
1717import net.ccbluex.liquidbounce.ui.client.clickgui.style.styles.nlclickgui.round.RoundedUtil
1818import net.ccbluex.liquidbounce.ui.font.Fonts
1919import net.ccbluex.liquidbounce.utils.client.MinecraftInstance
20+ import net.ccbluex.liquidbounce.utils.inventory.ItemUtils
2021import net.ccbluex.liquidbounce.utils.render.ColorUtils
22+ import net.ccbluex.liquidbounce.utils.render.ColorUtils.stripColor
2123import net.ccbluex.liquidbounce.utils.render.RenderUtils.newDrawRect
24+ import net.minecraft.client.gui.FontRenderer
2225import net.minecraft.client.gui.inventory.GuiInventory.drawEntityOnScreen
2326import net.minecraft.client.renderer.GlStateManager
27+ import net.minecraft.client.renderer.RenderHelper
28+ import net.minecraft.item.ItemStack
29+ import net.minecraft.potion.Potion
2430import org.lwjgl.input.Mouse
2531import org.lwjgl.opengl.GL11
2632import java.awt.Color
33+ import java.text.DecimalFormat
2734import kotlin.math.abs
2835import net.ccbluex.liquidbounce.config.BoolValue
2936
@@ -54,6 +61,7 @@ class EspPreviewComponent(private val gui: NeverloseGui) : MinecraftInstance {
5461 private val modeNames = listOf (" Rotation" , " Zoom" , " Box Pos" , " Box Scale" , " Health" , " Armor" , " Tags Pos" , " Tags Scale" )
5562
5663 private val openAnimation: Animation = EaseInOutQuad (250 , 1.0 , Direction .BACKWARDS )
64+ private val dFormat = DecimalFormat (" 0.0" )
5765
5866 fun draw (mouseX : Int , mouseY : Int ) {
5967 if (dragging) {
@@ -364,66 +372,144 @@ class EspPreviewComponent(private val gui: NeverloseGui) : MinecraftInstance {
364372
365373 val offset = 8.0 * scaleFactor
366374 val barWidth = 2.0
367- newDrawRect(minX - offset, maxY, minX - (offset - barWidth), maxY - barHeight, healthCol)
375+
376+ if (ESP2D .hpBarMode.equals(" Dot" , ignoreCase = true ) && fullHeight >= 10 ) {
377+ val segment = (fullHeight + 0.5 ) / 10.0
378+ val unit = 20.0 / 10.0
379+ for (k in 0 until 10 ) {
380+ val segmentHP = ((20.0 - k * unit).coerceIn(0.0 , unit)) / unit
381+ val segHei = (fullHeight / 10.0 - 0.5 ) * segmentHP
382+ newDrawRect(minX - offset, maxY - segment * k, minX - (offset - barWidth), maxY - segment * k - segHei, healthCol)
383+ }
384+ } else {
385+ newDrawRect(minX - offset, maxY, minX - (offset - barWidth), maxY - barHeight, healthCol)
386+ if (ESP2D .absorption) {
387+ val abHei = fullHeight / 6.0 * 4.0 / 2.0
388+ newDrawRect(minX - offset, maxY, minX - (offset - barWidth), maxY - abHei, Color (Potion .absorption.liquidColor).rgb)
389+ }
390+ }
368391
369392 if (ESP2D .healthNumber) {
370393 val hpDisp = if (ESP2D .hpMode.equals(" Health" , true )) " 20.0 ❤" else " 100%"
371- val fr = Fonts .minecraftFont
372394 val scale = ESP2D .fontScale
373-
374- GL11 .glPushMatrix()
375- val strWidth = fr.getStringWidth(hpDisp).toDouble()
376- val fontHeight = fr.FONT_HEIGHT .toDouble()
377- val scaleD = scale.toDouble()
378-
379- GL11 .glTranslated(minX - (offset + 2.0 ) - strWidth * scaleD, (maxY - barHeight) - fontHeight / 2.0 * scaleD, 0.0 )
380- GL11 .glScalef(scale, scale, scale)
381- fr.drawStringWithShadow(hpDisp, 0f , 0f , - 1 )
382- GL11 .glPopMatrix()
395+ val fontRenderer = mc.fontRendererObj
396+ drawScaledString(hpDisp, minX - (offset + 2.0 ) - fontRenderer.getStringWidth(hpDisp) * scale, (maxY - barHeight) - fontRenderer.FONT_HEIGHT / 2f * scale, scale.toDouble(), - 1 )
383397 }
384398 }
385399
386- if (ESP2D .armorBar) {
400+ if (ESP2D .armorBar || ( ESP2D .armorItems && mc.thePlayer.inventory.armorInventory.isNotEmpty()) ) {
387401 val maxX = baseMaxX + armorOffX
388402 val minY = baseMinY + armorOffY
389403 val maxY = baseMaxY + armorOffY
390404
391- if (ESP2D .armorBarMode.equals(" Total" , ignoreCase = true )) {
392- val armorHeight = (maxY - minY)
393- val offset = 6.5 * scaleFactor
405+ if (ESP2D .armorBar) {
406+ if (ESP2D .armorBarMode.equals(" Items" , ignoreCase = true )) {
407+ val slotHeight = (maxY - minY) / 4.0
408+ for (slot in 0 .. 3 ) {
409+ newDrawRect(maxX + 1.5 , maxY - slotHeight * (slot + 1 ), maxX + 3.5 , maxY - slotHeight * slot, backgroundColor.rgb)
410+ newDrawRect(maxX + 2.0 , maxY - slotHeight * (slot + 1 ) + 0.5 , maxX + 3.0 , maxY - slotHeight * slot - 0.5 , Color (0 , 255 , 255 ).rgb)
411+ }
412+ } else {
413+ val armorHeight = (maxY - minY)
414+ newDrawRect(maxX + 1.5 , minY - 0.5 , maxX + 3.5 , maxY + 0.5 , backgroundColor.rgb)
415+ newDrawRect(maxX + 2.0 , maxY, maxX + 3.0 , maxY - armorHeight, Color (0 , 255 , 255 ).rgb)
416+ }
417+ }
394418
395- newDrawRect(maxX + offset, minY - 0.5 , maxX + offset + 2.0 , maxY + 0.5 , backgroundColor.rgb)
396- newDrawRect(maxX + offset + 0.5 , maxY, maxX + offset + 1.5 , maxY - armorHeight, Color (0 , 255 , 255 ).rgb)
419+ if (ESP2D .armorItems) {
420+ val yDist = (maxY - minY) / 4.0
421+ for (slot in 3 downTo 0 ) {
422+ val stack = mc.thePlayer.inventory.armorInventory[slot]
423+ if (stack != null ) {
424+ val renderY = minY + yDist * (3 - slot) + yDist / 2.0 - 8.0
425+ renderItemStack(stack, maxX + 4.0 , renderY)
426+ if (ESP2D .armorDur) {
427+ val dur = ItemUtils .getItemDurability(stack).toString()
428+ val scale = ESP2D .fontScale
429+ val fontRenderer = mc.fontRendererObj
430+ drawScaledCenteredString(dur, maxX + 4.0 + 8.0 , renderY + 12.0 , scale.toDouble(), - 1 )
431+ }
432+ }
433+ }
397434 }
398435 }
399436
400437 if (ESP2D .tags) {
401438 val textXCenter = baseX + tagsOffX
402439 val textYBase = baseMinY + tagsOffY
403440
404- val name = mc.thePlayer.name
405- val fr = Fonts .minecraftFont
441+ val name = if (ESP2D .clearName) stripColor(mc.thePlayer.name) else mc.thePlayer.displayName.formattedText
406442 val scale = ESP2D .fontScale * tagsScale
407- val textWidth = fr.getStringWidth(name).toDouble() * scale.toDouble()
443+ val fontRenderer = mc.fontRendererObj
444+ val textWidth = fontRenderer.getStringWidth(name).toDouble() * scale.toDouble()
408445
409- val textY = textYBase - (10.0 * scaleFactor) - fr .FONT_HEIGHT * scale
446+ val textY = textYBase - (10.0 * scaleFactor) - fontRenderer .FONT_HEIGHT * scale
410447
411448 if (ESP2D .tagsBG) {
412- newDrawRect(
413- textXCenter - textWidth / 2.0 - 2.0 ,
414- textY - 2.0 ,
415- textXCenter + textWidth / 2.0 + 2.0 ,
416- textY + fr.FONT_HEIGHT * scale,
417- - 0x60000000
418- )
449+ newDrawRect(textXCenter - textWidth / 2.0 - 2.0 , textY - 2.0 , textXCenter + textWidth / 2.0 + 2.0 , textY + fontRenderer.FONT_HEIGHT * scale, - 0x60000000 )
419450 }
451+ drawScaledCenteredString(name, textXCenter, textY, scale.toDouble(), - 1 )
452+ }
453+
454+ if (ESP2D .itemTags) {
455+ val stack = mc.thePlayer.heldItem
456+ if (stack != null ) {
457+ val textXCenter = baseX + tagsOffX
458+ val textYBase = baseMaxY + (boxOffY * 0.1 )
459+
460+ val itemName = stack.displayName
461+ val scale = ESP2D .fontScale * tagsScale
462+ val fontRenderer = mc.fontRendererObj
463+ val textWidth = fontRenderer.getStringWidth(itemName).toDouble() * scale.toDouble()
464+ val textY = textYBase + (4.0 * scaleFactor)
465+
466+ if (ESP2D .tagsBG) {
467+ newDrawRect(textXCenter - textWidth / 2.0 - 2.0 , textY - 2.0 , textXCenter + textWidth / 2.0 + 2.0 , textY + fontRenderer.FONT_HEIGHT * scale, - 0x60000000 )
468+ }
469+ drawScaledCenteredString(itemName, textXCenter, textY, scale.toDouble(), - 1 )
470+ }
471+ }
472+ }
420473
421- GL11 .glPushMatrix()
422- GL11 .glTranslated(textXCenter - textWidth / 2.0 , textY, 0.0 )
423- GL11 .glScalef(scale, scale, scale)
424- fr.drawStringWithShadow(name, 0f , 0f , - 1 )
425- GL11 .glPopMatrix()
474+ private fun drawOutlineStringWithoutGL (s : String , x : Float , y : Float , color : Int , fontRenderer : FontRenderer ) {
475+ fontRenderer.drawString(stripColor(s), (x * 2 - 1 ).toInt(), (y * 2 ).toInt(), Color .BLACK .rgb)
476+ fontRenderer.drawString(stripColor(s), (x * 2 + 1 ).toInt(), (y * 2 ).toInt(), Color .BLACK .rgb)
477+ fontRenderer.drawString(stripColor(s), (x * 2 ).toInt(), (y * 2 - 1 ).toInt(), Color .BLACK .rgb)
478+ fontRenderer.drawString(stripColor(s), (x * 2 ).toInt(), (y * 2 + 1 ).toInt(), Color .BLACK .rgb)
479+ fontRenderer.drawString(s, (x * 2 ).toInt(), (y * 2 ).toInt(), color)
480+ }
481+
482+ private fun drawScaledString (text : String , x : Double , y : Double , scale : Double , color : Int ) {
483+ GL11 .glPushMatrix()
484+ GL11 .glTranslated(x, y, 0.0 )
485+ GL11 .glScaled(scale, scale, scale)
486+ if (ESP2D .outlineFont) {
487+ drawOutlineStringWithoutGL(text, 0f , 0f , color, mc.fontRendererObj)
488+ } else {
489+ mc.fontRendererObj.drawStringWithShadow(text, 0f , 0f , color)
426490 }
491+ GL11 .glPopMatrix()
492+ }
493+
494+ private fun drawScaledCenteredString (text : String , x : Double , y : Double , scale : Double , color : Int ) {
495+ val width = mc.fontRendererObj.getStringWidth(text) * scale
496+ drawScaledString(text, x - width / 2.0 , y, scale, color)
497+ }
498+
499+ private fun renderItemStack (stack : ItemStack , x : Double , y : Double ) {
500+ GL11 .glPushMatrix()
501+ GL11 .glTranslated(x, y, 0.0 )
502+ GL11 .glScalef(0.5f , 0.5f , 0.5f )
503+ GlStateManager .enableRescaleNormal()
504+ GlStateManager .enableBlend()
505+ GlStateManager .tryBlendFuncSeparate(770 , 771 , 1 , 0 )
506+ RenderHelper .enableStandardItemLighting()
507+ mc.renderItem.renderItemAndEffectIntoGUI(stack, 0 , 0 )
508+ mc.renderItem.renderItemOverlays(mc.fontRendererObj, stack, 0 , 0 )
509+ RenderHelper .disableStandardItemLighting()
510+ GlStateManager .disableRescaleNormal()
511+ GlStateManager .disableBlend()
512+ GL11 .glPopMatrix()
427513 }
428514
429515 private fun drawManagerHeader (mouseX : Int , mouseY : Int , previewX : Int , previewWidth : Float , panelY : Float , textColor : Color ) {
0 commit comments