[Kotlin] TargetHUD
-
This TargetHUD is changed from Target.kt
/* * LiquidBounce Hacked Client * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge. * https://github.com/CCBlueX/LiquidBounce/ */ package net.ccbluex.liquidbounce.ui.client.hud.element.elements import net.ccbluex.liquidbounce.LiquidBounce import net.ccbluex.liquidbounce.features.module.modules.combat.KillAura import net.ccbluex.liquidbounce.ui.client.hud.element.Border import net.ccbluex.liquidbounce.ui.client.hud.element.Element import net.ccbluex.liquidbounce.ui.client.hud.element.ElementInfo import net.ccbluex.liquidbounce.ui.font.Fonts import net.ccbluex.liquidbounce.utils.extensions.getDistanceToEntityBox import net.ccbluex.liquidbounce.utils.render.RenderUtils import net.ccbluex.liquidbounce.value.FloatValue import net.minecraft.client.gui.Gui import net.minecraft.entity.Entity import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemArmor import net.minecraft.item.ItemStack import net.minecraft.item.ItemTool import net.minecraft.util.ResourceLocation import org.lwjgl.opengl.GL11 import java.awt.Color import java.text.DecimalFormat import java.text.DecimalFormatSymbols import java.util.* import kotlin.math.abs import kotlin.math.pow /** * A target hud */ @ElementInfo(name = "Target2") class Target2 : Element() { private val decimalFormat = DecimalFormat("##0.00", DecimalFormatSymbols(Locale.ENGLISH)) private val fadeSpeed = FloatValue("FadeSpeed", 2F, 1F, 9F) private var easingHealth: Float = 0F private var lastTarget: Entity? = null override fun drawElement(): Border { val target = (LiquidBounce.moduleManager[KillAura::class.java] as KillAura).target if (target is EntityPlayer) { if (target != lastTarget || easingHealth < 0 || easingHealth > target.maxHealth || abs(easingHealth - target.health) < 0.01) { easingHealth = target.health } val width = (38 + Fonts.font40.getStringWidth(target.name)) .coerceAtLeast(118) .toFloat() // Draw rect box RenderUtils.drawBorderedRect(0F, 0F, width, 36F, 3F, Color.BLACK.rgb, Color.BLACK.rgb) // Damage animation if (easingHealth > target.health) RenderUtils.drawRect(0F, 34F, (easingHealth / target.maxHealth) * width, 36F, Color(138, 60, 65).rgb) // Health bar if(target.hurtTime > 9){ RenderUtils.drawRect(0F, 34F, (target.health / target.maxHealth) * width, 36F, Color(149, 9, 17).rgb) } else { RenderUtils.drawRect(0F, 34F, (target.health / target.maxHealth) * width, 36F, Color(33, 239, 0).rgb) } RenderUtils.drawRect(0F, 38F, (target.totalArmorValue / 20.0F) * width, 38F, Color(10, 130, 229).rgb) // Heal animation if (easingHealth < target.health) RenderUtils.drawRect((easingHealth / target.maxHealth) * width, 34F, (target.health / target.maxHealth) * width, 36F, Color(44, 201, 144).rgb) easingHealth += ((target.health - easingHealth) / 2.0F.pow(10.0F - fadeSpeed.get())) * RenderUtils.deltaTime // Draw info val playerInfo = mc.netHandler.getPlayerInfo(target.uniqueID) if (playerInfo != null) { Fonts.font40.drawString(target.name, 36, 4, 0xffffff) // GlStateManager.scale(0.5,0.5,0.5); renderArmor((target as EntityPlayer?)!!) // Draw head val locationSkin = playerInfo.locationSkin drawHead(locationSkin, 30, 30) } } lastTarget = target return Border(0F, 0F, 120F, 36F) } private fun renderArmor(player: EntityPlayer) { var armourStack: ItemStack? var renderStack = player.inventory.armorInventory val length = renderStack.size var xOffset = 36 for (aRenderStack in renderStack) { armourStack = aRenderStack } if (player.heldItem != null) { val stock = player.heldItem.copy() if (stock.hasEffect() && (stock.item is ItemTool || stock.item is ItemArmor)) { stock.stackSize = 1 } this.renderItemStack(stock, xOffset, 10) xOffset += 16 } renderStack = player.inventory.armorInventory for (index in 3 downTo 0) { armourStack = renderStack[index] if (armourStack == null) continue this.renderItemStack(armourStack, xOffset, 10) xOffset += 16 } } private fun renderItemStack(stack: ItemStack, x: Int, y: Int) { mc.renderItem.zLevel = -150.0f mc.renderItem.renderItemAndEffectIntoGUI(stack, x, y) mc.renderItem.renderItemOverlays(mc.fontRendererObj, stack, x, y) } private fun drawHead(skin: ResourceLocation, width: Int, height: Int) { GL11.glColor4f(1F, 1F, 1F, 1F) mc.textureManager.bindTexture(skin) Gui.drawScaledCustomSizeModalRect(2, 2, 8F, 8F, 8, 8, width, height, 64F, 64F) } }
Create A new Kt in net.ccbluex.liquidbounce.ui.client.hud.element.elements
And AddElment in net.ccbluex.liquidbounce.ui.client.hud.HUD
![IY}478OUQEC%2PD7L{NNQM.png
Like This