CCBlueX Forum

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

    A Notification Theme like IntelliJ IDEA.

    Kotlin/Java
    6
    7
    612
    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.
    • Larissa
      Larissa last edited by Larissa

      this is a notification like idea.i will give you icons and codes.

      
      import net.ccbluex.liquidbounce.LiquidBounce
      import net.ccbluex.liquidbounce.utils.timer.MSTimer
      import net.ccbluex.liquidbounce.LiquidBounce.hud
      import net.ccbluex.liquidbounce.value.BoolValue
      import net.ccbluex.liquidbounce.value.FloatValue
      import net.ccbluex.liquidbounce.value.ListValue
      import net.ccbluex.liquidbounce.value.IntegerValue
      import net.ccbluex.liquidbounce.ui.client.hud.designer.GuiHudDesigner
      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.utils.render.AnimationUtils
      import net.ccbluex.liquidbounce.utils.render.BlurUtils
      import net.ccbluex.liquidbounce.utils.render.Stencil
      import net.minecraft.client.gui.Gui
      import net.minecraft.client.renderer.GlStateManager
      import net.ccbluex.liquidbounce.ui.font.Fonts
      import net.ccbluex.liquidbounce.utils.ClientUtils
      import net.ccbluex.liquidbounce.utils.render.RenderUtils
      import net.minecraft.util.ResourceLocation
      import java.awt.Color
      
      import org.lwjgl.opengl.GL11
      
      @ElementInfo(name = "Notifications", single = true)
      class Notifications(x: Double = 0.0, y: Double = 30.0, scale: Float = 1F,
                          side: Side = Side(Side.Horizontal.RIGHT, Side.Vertical.DOWN)) : Element(x, y, scale, side) {
      
          private val smoothYTransition = BoolValue("Smooth-YTransition", true)
          private val blurValue = BoolValue("Blur", false)
          private val blurStrength = FloatValue("Blur-Strength", 0F, 0F, 30F)
          private val styleValue = ListValue("Style", arrayOf("Compact", "New", "IntelliJ IDEA LOL"), "Compact")
          private val newAnimValue = BoolValue("UseNewAnim", true)
          private val animationSpeed = FloatValue("Anim-Speed", 0.5F, 0.01F, 1F, { newAnimValue.get() })
          private val bgRedValue = IntegerValue("Background-Red", 0, 0, 255)
          private val bgGreenValue = IntegerValue("Background-Red", 0, 0, 255)
          private val bgBlueValue = IntegerValue("Background-Red", 0, 0, 255)
          private val bgAlphaValue = IntegerValue("Background-Alpha", 190, 0, 255)
      
          /**
           * Example notification for CustomHUD designer
           */
          private val exampleNotification = Notification("Example Notification", Notification.Type.INFO)
      
          /**
           * Draw element
           */
          override fun drawElement(): Border? {
              val bgColor = Color(bgRedValue.get(), bgGreenValue.get(), bgBlueValue.get(), bgAlphaValue.get())
              var animationY = 30F
              val notifications = mutableListOf()
      
              for (i in hud.notifications)
                  notifications.add(i)
              
              if (mc.currentScreen !is GuiHudDesigner || !notifications.isEmpty()) 
                  for(i in notifications)
                      i.drawNotification(
                      animationY, 
                      smoothYTransition.get(), 
                      newAnimValue.get(), 
                      animationSpeed.get(), 
                      bgColor, side, 
                      styleValue.get(), 
                      blurValue.get(), 
                      blurStrength.get(), 
                      renderX.toFloat(), 
                      renderY.toFloat())
                          .also { animationY += when (styleValue.get().toLowerCase()) {
                              "compact" -> 20
                              "full" -> 30
                              else -> 30
                          } * if (side.vertical == Side.Vertical.DOWN) 1F else -1F}
              else
                  exampleNotification.drawNotification(
                      animationY, 
                      smoothYTransition.get(), 
                      newAnimValue.get(), 
                      animationSpeed.get(), 
                      bgColor, side, 
                      styleValue.get(), 
                      blurValue.get(), 
                      blurStrength.get(), 
                      renderX.toFloat(), 
                      renderY.toFloat())
      
              if (mc.currentScreen is GuiHudDesigner) {
                  exampleNotification.fadeState = Notification.FadeState.STAY
                  //exampleNotification.stayTimer.reset()
                  exampleNotification.x = exampleNotification.textLength + 8F
                  if (exampleNotification.stayTimer.hasTimePassed(exampleNotification.displayTime)) 
                      exampleNotification.stayTimer.reset()
      
                  return if (styleValue.get().equals("compact", true)) Border(-102F, -48F, 0F, -30F) else Border(-130F, -58F, 0F, -30F)
              }
      
              return null
          }
      
      }
      class Notification(message : String, type : Type, displayLength: Long) {
          private val notifyDir = "liquidbounce+/notif/"
          private val imgSuccess = ResourceLocation("${notifyDir}checkmark.png")
          private val imgError = ResourceLocation("${notifyDir}error.png")
          private val imgWarning = ResourceLocation("${notifyDir}warning.png")
          private val imgInfo = ResourceLocation("${notifyDir}info.png")
      
          var x = 0f
          var textLength = 0
          private var stay = 0f
          private var fadeStep = 0f
          var fadeState = FadeState.IN
          var displayTime : Long = 0L
          var stayTimer = MSTimer()
          private var firstY = 0f
          private var message: String = ""
          private var type: Type
          init {
              this.message = message
              this.type = type
              this.displayTime = displayLength
              this.firstY = 19190F
              this.stayTimer.reset()
              this.textLength = Fonts.minecraftFont.getStringWidth(message)
          }
      
          constructor(message: String, type: Type) : this(message, type, 2000L)
      
          constructor(message: String) : this(message, Type.INFO, 500L)
      
          constructor(message: String, displayLength: Long) : this(message, Type.INFO, displayLength)
      
          enum class Type {
              SUCCESS,
              INFO,
              WARNING,
              ERROR
          }
      
          enum class FadeState {
              IN,STAY,OUT,END
          }
      
          fun drawNotification(animationY: Float, smooth: Boolean, newAnim: Boolean, animSpeed: Float, backgroundColor: Color, side: Side, style: String, blur: Boolean, strength: Float, originalX: Float, originalY: Float) {
              val delta = RenderUtils.deltaTime
              val width = textLength.toFloat() + 8.0f
              
              if (smooth) {
                  if (firstY == 19190.0F) {
                      firstY = animationY
                  }
                  firstY += (animationY - firstY) * 0.25F
              } else {
                  firstY = animationY
              }
      
              var y = firstY
      
              when (style.toLowerCase()) {
                  "compact" -> {
                      GlStateManager.resetColor()
                      if (blur) {
                          GL11.glTranslatef(-originalX, -originalY, 0F)
                          GL11.glPushMatrix()
                          BlurUtils.blurAreaRounded(originalX + -x - 5F, originalY + -18F - y, originalX + -x + 8F + textLength, originalY + -y, 3F, strength)
                          GL11.glPopMatrix()
                          GL11.glTranslatef(originalX, originalY, 0F)
                      } 
      
                      RenderUtils.customRounded(-x + 8F + textLength, -y, -x - 2F, -18F - y, 0F, 3F, 3F, 0F, backgroundColor.rgb)
                      RenderUtils.customRounded(-x - 2F, -y, -x - 5F, -18F - y, 3F, 0F, 0F, 3F, when(type) {
                              Type.SUCCESS -> Color(80, 255, 80).rgb
                              Type.ERROR -> Color(255, 80, 80).rgb
                              Type.INFO -> Color(255, 255, 255).rgb
                              Type.WARNING -> Color(255, 255, 0).rgb
                          })  
      
                      GlStateManager.resetColor()
                      Fonts.minecraftFont.drawStringWithShadow(message, -x + 3, -13F - y, -1)
                  }
      
                  "new" -> {
                      val dist = (x + 1 + 26F) - (x - 8 - textLength)
                      val kek = -x - 1 - 20F
      
                      val toolong = dist * if (stayTimer.hasTimePassed(displayTime)) 0F else ((displayTime - (System.currentTimeMillis() - stayTimer.time)).toFloat() / displayTime.toFloat())
      
                      GlStateManager.resetColor()
                      if (blur) {
                          GL11.glTranslatef(-originalX, -originalY, 0F)
                          GL11.glPushMatrix()
                          BlurUtils.blurAreaRounded(originalX + kek, originalY + -28F - y, originalX + -x + 8 + textLength, originalY + -y, 3F, strength)
                          GL11.glPopMatrix()
                          GL11.glTranslatef(originalX, originalY, 0F)
                      } 
      
                      Stencil.write(true)
                      RenderUtils.drawRoundedRect(-x + 8 + textLength, -y, kek, -28F - y, 0F, backgroundColor.rgb)
                      Stencil.erase(true)
      
                      GlStateManager.resetColor()
                      if (fadeState == FadeState.STAY && !stayTimer.hasTimePassed(displayTime))
                          RenderUtils.newDrawRect(kek, -y, kek + toolong, -1.5F - y, when(type) {
                              Type.SUCCESS -> Color(80, 255, 80, 255).rgb
                              Type.ERROR -> Color(255, 80, 80, 255).rgb
                              Type.INFO -> Color(127,174,210).rgb
                              Type.WARNING -> Color(255, 255, 0).rgb
                          })
                      else if (fadeState == FadeState.IN)
                          RenderUtils.newDrawRect(kek, -y, kek + dist, -1.5F - y, when(type) {
                              Type.SUCCESS -> Color(80, 255, 80, 255).rgb
                              Type.ERROR -> Color(255, 80, 80, 255).rgb
                              Type.INFO -> Color(127,174,210).rgb
                              Type.WARNING -> Color(255, 255, 0).rgb
                          })
      
                      Stencil.dispose()
      
                      GL11.glPushMatrix()
                      GlStateManager.disableAlpha()
                      GlStateManager.resetColor()
                      GL11.glColor4f(1F, 1F, 1F, 1F)
                      RenderUtils.drawImage2(when (type) {
                          Type.SUCCESS -> imgSuccess
                          Type.ERROR -> imgError
                          Type.WARNING -> imgWarning
                          Type.INFO -> imgInfo
                      }, kek +2, -24F - y, 18, 18)
                      GlStateManager.enableAlpha()
                      GL11.glPopMatrix()
      
                      Fonts.minecraftFont.drawStringWithShadow(message, -x + 2, -18F - y, -1)
                  }
      
                  "intellij idea lol" -> {
                      val dist = (x + 1 + 26F) - (x - 8 - textLength)
                      val kek = -x - 1 - 20F
      
                      GlStateManager.resetColor()
                      if (blur) {
                          GL11.glTranslatef(-originalX, -originalY, 0F)
                          GL11.glPushMatrix()
                          BlurUtils.blurAreaRounded(originalX + kek, originalY + -28F - y, originalX + -x + 8 + textLength, originalY + -y, 3F, strength)
                          GL11.glPopMatrix()
                          GL11.glTranslatef(originalX, originalY, 0F)
                      }
      
                      Stencil.write(true)
      
                      if (type == Type.ERROR) {
                          RenderUtils.drawRoundedRect(-x + 9 + textLength, -y + 1, kek - 1, -28F - y - 1, 0F, Color(115,69,75).rgb)
                          RenderUtils.drawRoundedRect(-x + 8 + textLength, -y, kek, -28F - y, 0F, Color(89,61,65).rgb)
                          Fonts.minecraftFont.drawStringWithShadow("IDE Error:", -x - 4, -25F - y, Color(249,130,108).rgb)
                      }
                      if (type == Type.INFO) {
                          RenderUtils.drawRoundedRect(-x + 9 + textLength, -y + 1, kek - 1, -28F - y - 1, 0F, Color(70,94,115).rgb)
                          RenderUtils.drawRoundedRect(-x + 8 + textLength, -y, kek, -28F - y, 0F, Color(61,72,87).rgb)
                          Fonts.minecraftFont.drawStringWithShadow("IDE Information:", -x - 4, -25F - y, Color(119,145,147).rgb)
                      }
                      if (type == Type.SUCCESS) {
                          RenderUtils.drawRoundedRect(-x + 9 + textLength, -y + 1, kek - 1, -28F - y - 1, 0F, Color(67,104,67).rgb)
                          RenderUtils.drawRoundedRect(-x + 8 + textLength, -y, kek, -28F - y, 0F, Color(55,78,55).rgb)
                          Fonts.minecraftFont.drawStringWithShadow("IDE Success:", -x - 4, -25F - y, Color(10,142,2).rgb)
                      }
                      if (type == Type.WARNING) {
                          RenderUtils.drawRoundedRect(-x + 9 + textLength, -y + 1, kek - 1, -28F - y - 1, 0F, Color(103,103,63).rgb)
                          RenderUtils.drawRoundedRect(-x + 8 + textLength, -y, kek, -28F - y, 0F, Color(80,80,57).rgb)
                          Fonts.minecraftFont.drawStringWithShadow("IDE Warning:", -x - 4, -25F - y, Color(175,163,0).rgb)
                      }
      
                      Stencil.erase(true)
      
                      GlStateManager.resetColor()
      
                      Stencil.dispose()
      
                      GL11.glPushMatrix()
                      GlStateManager.disableAlpha()
                      GlStateManager.resetColor()
                      GL11.glColor4f(1F, 1F, 1F, 1F)
                      RenderUtils.drawImage2(when (type) {
                          Type.SUCCESS -> imgSuccess
                          Type.ERROR -> imgError
                          Type.WARNING -> imgWarning
                          Type.INFO -> imgInfo
                      }, kek + 5, -25F - y, 7, 7)
                      GlStateManager.enableAlpha()
                      GL11.glPopMatrix()
      
                      Fonts.minecraftFont.drawStringWithShadow(message, -x - 4, -13F - y, -1)
                  }
              }
      
              when (fadeState) {
                  FadeState.IN -> {
                      if (x < width) {
                          if (newAnim) 
                              x = net.ccbluex.liquidbounce.utils.AnimationUtils.animate(width, x, animSpeed * 0.025F * delta)
                          else 
                              x = AnimationUtils.easeOut(fadeStep, width) * width
                          fadeStep += delta / 4F
                      }
                      if (x >= width) {
                          fadeState = FadeState.STAY
                          x = width
                          fadeStep = width
                      }
      
                      stay = 60F
                      stayTimer.reset()
                  }
      
                  FadeState.STAY -> {
                      if (stay > 0) {
                          stay = 0F
                          stayTimer.reset()
                      }
                      if (stayTimer.hasTimePassed(displayTime))
                          fadeState = FadeState.OUT
                  }
      
                  FadeState.OUT -> if (x > 0) {
                      if (newAnim) 
                          x = net.ccbluex.liquidbounce.utils.AnimationUtils.animate(-width, x, animSpeed * 0.025F * delta)
                      else 
                          x = AnimationUtils.easeOut(fadeStep, width) * width
      
                      fadeStep -= delta / 4F
                  } else
                      fadeState = FadeState.END
      
                  FadeState.END -> hud.removeNotification(this)
              }        
          }
      }
      
      

      icon and ending photo!
      58CEA7EF-A755-4D52-9115-48F5C0E45083.png 55D78E4E-2882-4605-9869-8EC44C3B25AD.png 230046AE-FDC0-43BB-B75A-D00AA7872B8F.png 4B50C6C2-7A01-449F-9D0B-7405554E7E10.png 7E15207E-EDCD-438B-A8FA-643925E7C81D.png

      Ali00035 exit scammed Konoha Scarlet Ryannnnn 4 Replies Last reply Reply Quote 16
      • Ali00035
        Ali00035 Banned @Larissa last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • Koitoyuu
          Koitoyuu last edited by

          Very Cute 😄

          Larissa 1 Reply Last reply Reply Quote 0
          • Larissa
            Larissa @Koitoyuu last edited by

            @koitoyuu thx

            1 Reply Last reply Reply Quote 15
            • exit scammed
              exit scammed @Larissa last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 1
              • Konoha Scarlet
                Konoha Scarlet @Larissa last edited by

                @larissa Nice work

                1 Reply Last reply Reply Quote 1
                • Ryannnnn
                  Ryannnnn @Larissa last edited by

                  @larissa code by ryannnnn😎😎

                  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