CCBlueX Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    [Kotlin] KeyStrokes

    Kotlin/Java
    12
    20
    923
    Loading More Posts
    • 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.
    • qwq Liulihaocai
      qwq Liulihaocai last edited by qwq Liulihaocai

      a simple keystrokes
      animation like skidma
      pic
      keys.png

      package net.ccbluex.liquidbounce.ui.client.hud.element.elements
      
      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.client.hud.element.Side
      import net.ccbluex.liquidbounce.ui.font.Fonts
      import net.ccbluex.liquidbounce.utils.render.ColorUtils
      import net.ccbluex.liquidbounce.utils.render.RenderUtils
      import net.ccbluex.liquidbounce.value.BoolValue
      import net.ccbluex.liquidbounce.value.FloatValue
      import net.ccbluex.liquidbounce.value.FontValue
      import net.ccbluex.liquidbounce.value.IntegerValue
      import net.minecraft.client.gui.FontRenderer
      import net.minecraft.client.settings.KeyBinding
      import org.lwjgl.input.Keyboard
      import java.awt.Color
      
      @ElementInfo(name = "KeyStrokes")
      class KeyStrokes : Element(5.0,25.0,1.25F, Side.default()) {
          private val keys=ArrayList<KeyStroke>()
      
          private val backGroundRedValue = IntegerValue("BackGroundRed", 0, 0, 255)
          private val backGroundGreenValue = IntegerValue("BackGroundGreen", 0, 0, 255)
          private val backGroundBlueValue = IntegerValue("BackGroundBlue", 0, 0, 255)
          private val backGroundAlphaValue = IntegerValue("BackGroundAlpha", 170, 0, 255)
          private val textRedValue = IntegerValue("TextRed", 255, 0, 255)
          private val textGreenValue = IntegerValue("TextGreen", 255, 0, 255)
          private val textBlueValue = IntegerValue("TextBlue", 255, 0, 255)
          private val textAlphaValue = IntegerValue("TextAlpha", 255, 0, 255)
          private val highLightPercent = FloatValue("HighLightPercent",0.5F,0F,1F)
          private val animSpeedValue = IntegerValue("AnimationSpeed", 300, 0, 700)
          private val outline = BoolValue("Outline", false)
          private val outlineBoldValue = IntegerValue("OutlineBold", 1,0,5)
          private val outlineRainbow = BoolValue("OutLineRainbow", false)
          private val fontValue = FontValue("Font", Fonts.font35)
      
          init {
              keys.add(KeyStroke(mc.gameSettings.keyBindForward,16,0,15,15).initKeyName())
              keys.add(KeyStroke(mc.gameSettings.keyBindLeft,0,16,15,15).initKeyName())
              keys.add(KeyStroke(mc.gameSettings.keyBindBack,16,16,15,15).initKeyName())
              keys.add(KeyStroke(mc.gameSettings.keyBindRight,32,16,15,15).initKeyName())
              keys.add(KeyStroke(mc.gameSettings.keyBindAttack,0,32,23,15).initKeyName("L"))
              keys.add(KeyStroke(mc.gameSettings.keyBindUseItem,24,32,23,15).initKeyName("R"))
          }
      
          override fun drawElement(partialTicks: Float): Border {
              val backGroundColor=Color(backGroundRedValue.get(),backGroundGreenValue.get(),backGroundBlueValue.get(),backGroundAlphaValue.get())
              val textColor=if(outlineRainbow.get()){
                  ColorUtils.rainbow(textAlphaValue.get())
              }else{
                  Color(textRedValue.get(),textGreenValue.get(),textBlueValue.get(),textAlphaValue.get())
              }
      
              for(keyStroke in keys){
                  keyStroke.render(animSpeedValue.get(), backGroundColor, textColor, highLightPercent.get(), outline.get(), outlineBoldValue.get(), fontValue.get())
              }
      
              return Border(0F,0F,47F,47F)
          }
      }
      
      class KeyStroke(val key:KeyBinding,val posX:Int,val posY:Int, val width:Int, val height:Int){
          var keyName="KEY"
      
          private var lastClick=false
          private val animations=ArrayList<Long>()
      
          fun render(speed: Int, bgColor: Color, textColor: Color, highLightPct: Float, outline: Boolean, outlineBold: Int, font: FontRenderer){
              val highLightColor=Color(255-((255-bgColor.red)*highLightPct).toInt(),255-((255-bgColor.blue)*highLightPct).toInt(),255-((255-bgColor.green)*highLightPct).toInt())
              val clickAlpha=255-(255-bgColor.alpha)*highLightPct
              val centerX=posX+(width/2)
              val centerY=posY+(height/2)
              val nowTime=System.currentTimeMillis()
      
              val rectColor=if(lastClick&&animations.isEmpty()){ ColorUtils.reAlpha(highLightColor,clickAlpha.toInt()) }else{ bgColor }
              RenderUtils.drawRect(posX.toFloat(),posY.toFloat(),(posX+width).toFloat(),(posY+height).toFloat()
                  ,rectColor)
      
              val removeAble=ArrayList<Long>()
              for(time in animations){
                  val pct=(nowTime-time)/(speed.toFloat())
                  if(pct>1){
                      removeAble.add(time)
                      continue
                  }
                  RenderUtils.drawLimitedCircle(posX.toFloat(),posY.toFloat(),(posX+width).toFloat(),(posY+height).toFloat(),
                      centerX,centerY,(width*0.7F)*pct
                      ,Color(255-((255-highLightColor.red)*pct).toInt(),255-((255-highLightColor.green)*pct).toInt(),255-((255-highLightColor.blue)*pct).toInt(),255-((255-clickAlpha)*pct).toInt()))
              }
              for(time in removeAble){
                  animations.remove(time)
              }
              if(!lastClick && key.isKeyDown){
                  animations.add(nowTime)
              }
              lastClick=key.isKeyDown
      
              font.drawString(keyName,centerX-(font.getStringWidth(keyName)/2),centerY-(font.FONT_HEIGHT/2)
                  ,textColor.rgb)
              if(outline){
                  RenderUtils.drawRect(posX.toFloat(),posY.toFloat(),(posX+outlineBold).toFloat(),(posY+height).toFloat(),textColor.rgb)
                  RenderUtils.drawRect((posX+width-outlineBold).toFloat(),posY.toFloat(),(posX+width).toFloat(),(posY+height).toFloat(),textColor.rgb)
                  RenderUtils.drawRect((posX+outlineBold).toFloat(),posY.toFloat(),(posX+width-outlineBold).toFloat(),(posY+outlineBold).toFloat(),textColor.rgb)
                  RenderUtils.drawRect((posX+outlineBold).toFloat(),(posY+height-outlineBold).toFloat(),(posX+width-outlineBold).toFloat(),(posY+height).toFloat(),textColor.rgb)
              }
          }
      
          fun initKeyName():KeyStroke{
              keyName=Keyboard.getKeyName(key.keyCode)
              return this
          }
      
          fun initKeyName(name:String):KeyStroke{
              keyName=name
              return this
          }
      }
      

      depends
      ColorUtils

          @JvmStatic
          fun reAlpha(color: Color,alpha: Int): Color{
              return Color(color.red,color.green,color.blue,alpha)
          }
      

      RenderUtils

          public static void drawLimitedCircle(final float lx, final float ly, final float x2, final float y2,final int xx, final int yy, final float radius, final Color color) {
              int sections = 50;
              double dAngle = 2 * Math.PI / sections;
              float x, y;
      
              glPushAttrib(GL_ENABLE_BIT);
      
              glEnable(GL_BLEND);
              glDisable(GL_TEXTURE_2D);
              glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
              glEnable(GL_LINE_SMOOTH);
              glBegin(GL_TRIANGLE_FAN);
      
              for (int i = 0; i < sections; i++) {
                  x = (float) (radius * Math.sin((i * dAngle)));
                  y = (float) (radius * Math.cos((i * dAngle)));
      
                  glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F);
                  glVertex2f(Math.min(x2,Math.max(xx + x,lx)), Math.min(y2,Math.max(yy + y,ly)));
              }
      
              GlStateManager.color(0, 0, 0);
      
              glEnd();
      
              glPopAttrib();
          }
      
      DreamWasFucked 1 Reply Last reply Reply Quote 0
      • Litely
        Litely last edited by

        owo

        sigma momento

        1 Reply Last reply Reply Quote 0
        • Litely
          Litely last edited by

          fb1de634-2bc4-4136-9591-6fe9fb522eef-image.png

          c809b143-ffc7-4965-aa62-4def4e393d53-image.png

          what

          qwq Liulihaocai 2 Replies Last reply Reply Quote 0
          • qwq Liulihaocai
            qwq Liulihaocai @Litely last edited by

            @idkmyname sorry i forget to send my funcs in my custom liquidbounce

            1 Reply Last reply Reply Quote 0
            • qwq Liulihaocai
              qwq Liulihaocai @Litely last edited by

              @idkmyname look new stuff in my post xd

              Litely 1 Reply Last reply Reply Quote 0
              • Litely
                Litely @qwq Liulihaocai last edited by

                @qwq-liulihaocai ok tysm

                1 Reply Last reply Reply Quote 0
                • mateusz
                  mateusz last edited by mateusz

                  how to
                  add the kotlin keystrokes?

                  skiddermaster412 qwq Liulihaocai 2 Replies Last reply Reply Quote 0
                  • TheApplePro
                    TheApplePro last edited by

                    sigma hatar

                    1 Reply Last reply Reply Quote 0
                    • skiddermaster412
                      skiddermaster412 Banned @mateusz last edited by

                      @mateusz sell your soul to the demon

                      mateusz 1 Reply Last reply Reply Quote 0
                      • qwq Liulihaocai
                        qwq Liulihaocai @mateusz last edited by

                        @mateusz modify liquidbounce code

                        1 Reply Last reply Reply Quote 0
                        • mateusz
                          mateusz @skiddermaster412 last edited by

                          @skiddermaster412 lol

                          1 Reply Last reply Reply Quote 0
                          • melih_gmc2
                            melih_gmc2 last edited by

                            wtf sigma hator

                            1 Reply Last reply Reply Quote 0
                            • Gking
                              Gking last edited by

                              好ooooooooooo

                              1 Reply Last reply Reply Quote 0
                              • DreamWasFucked
                                DreamWasFucked Banned @qwq Liulihaocai last edited by

                                @qwq-liulihaocai said in [Kotlin] KeyStrokes:

                                skidma

                                sigma hatar...

                                Righted 1 Reply Last reply Reply Quote 0
                                • Righted
                                  Righted @DreamWasFucked last edited by

                                  @skidma sigma niggar

                                  1 Reply Last reply Reply Quote 0
                                  • B
                                    BRBB last edited by

                                    does it register the clicks when autoclicking?

                                    natalka 1 Reply Last reply Reply Quote 0
                                    • natalka
                                      natalka @BRBB last edited by

                                      @brbb It's not about keystrokes mod, but whether the autoclicker supports it or not. If your autoclicker doesn't support clicking through keystrokes, that's the fault of autoclicker not the keystrokes.

                                      skiddermaster412 B 2 Replies Last reply Reply Quote 0
                                      • skiddermaster412
                                        skiddermaster412 Banned @natalka last edited by

                                        @natalka when the me the explain today download the when in the moment the online server me minecraft r

                                        1 Reply Last reply Reply Quote 0
                                        • B
                                          BRBB @natalka last edited by

                                          @natalka oh ok, but i dont use any autoclickers i just use the built in autoclicker in liquid bounce so i thought it would work with this script.

                                          C 1 Reply Last reply Reply Quote 0
                                          • C
                                            Co丶Dynamic @BRBB last edited by Co丶Dynamic

                                            @brbb it only detects your keyboard and mouse changes
                                            anyway it works with Physical Autoclicker

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            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