Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

LiquidBounce Forum

  1. Home
  2. Kotlin/Java
  3. A Simple HealthBar TargetHUD

A Simple HealthBar TargetHUD

Scheduled Pinned Locked Moved Kotlin/Java
1 Posts 1 Posters 660 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • LarissaL Offline
    LarissaL Offline
    Larissa
    wrote on last edited by Larissa
    #1

    main codes

    
    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.render.RenderUtils
    import net.ccbluex.liquidbounce.value.FloatValue
    import net.minecraft.entity.Entity
    import net.minecraft.entity.player.EntityPlayer
    import java.awt.Color
    import kotlin.math.abs
    import kotlin.math.pow
    
    @ElementInfo(name = "Target")
    class Target : Element() {
    
        private var Health: Float = 0F
        private var EndingTarget: Entity? = null
        private val BarAnimationSpeed = FloatValue("BarAnimationSpeed", 2F, 1F, 9F)
    
        override fun drawElement(): Border {
            val target = (LiquidBounce.moduleManager[KillAura::class.java] as KillAura).target
    
            if (target is EntityPlayer) {
                if (target != EndingTarget || Health < 0 || Health > target.maxHealth ||
                        abs(Health - target.health) < 0.01) {
                    Health = target.health
                }
    
                val width = (38 + Fonts.font40.getStringWidth(target.name))
                        .coerceAtLeast(119)
                        .toFloat()
    
                RenderUtils.drawBorderedRect(3F, 37F, 115F, 42F, 4.2F, Color(16, 16, 16, 255).rgb, Color(10, 10, 10, 100).rgb)
                RenderUtils.drawBorderedRect(3F, 37F, 115F, 42F, 1.2F, Color(255, 255, 255, 180).rgb, Color(255, 180, 255, 0).rgb)
                if (Health > target.health)
                    RenderUtils.drawRect(3F, 37F, (Health / target.maxHealth) * width - 4F,
                            42F, Color(250, 0, 0, 120).rgb)
                RenderUtils.drawRect(3.2F, 37F, (target.health / target.maxHealth) * width - 4F,
                        42F, Color(220, 0, 0, 220).rgb)
                if (Health < target.health)
                    RenderUtils.drawRect((Health / target.maxHealth) * width, 37F,
                            (target.health / target.maxHealth) * width, 42F, Color(44, 201, 144).rgb)
                RenderUtils.drawBorderedRect(3F, 37F, 115F, 42F, 1.2F, Color(255, 255, 255, 180).rgb, Color(255, 180, 255, 0).rgb)
    
    
                Health += ((target.health - Health) / 2.0F.pow(10.0F - BarAnimationSpeed.get())) * RenderUtils.deltaTime
    
                mc.fontRendererObj.drawStringWithShadow("" + target.name, 36F, 22F, 0xFFFFFF)
            }
            EndingTarget = target
            return Border(0F, 0F, 120F, 36F)
        }
    }
    
    

    This is the final effect. He also has the animation of blood deduction and blood recovery. Welcome to use it

    96FF4575-8B60-4EC8-BF98-C1AF4FF433B5.jpeg 2CFC1094-008E-46D9-BD5C-8478C476FA53.jpeg

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    About
    • Terms of Service
    • Privacy Policy
    • Status
    • Contact Us
    Downloads
    • Releases
    • Source code
    • License
    Docs
    • Tutorials
    • CustomHUD
    • AutoSettings
    • ScriptAPI
    Community
    • Forum
    • Guilded
    • YouTube
    • Twitter
    • D.Tube
    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups