Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • 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. General Discussion
  3. [Kotlin] New Notifications

[Kotlin] New Notifications

Scheduled Pinned Locked Moved General Discussion
29 Posts 20 Posters 13.7k Views 1 Watching
  • 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.
  • GameBoyG GameBoy
    package net.ccbluex.liquidbounce.ui.client.hud.element.elements
    import net.ccbluex.liquidbounce.LiquidBounce
    import net.ccbluex.liquidbounce.utils.timer.MSTimer
    import net.ccbluex.liquidbounce.LiquidBounce.hud
    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.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
    @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) {
    
        /**
         * Example notification for CustomHUD designer
         */
        private val exampleNotification = Notification("Example Notification", Notification.Type.INFO)
    
        /**
         * Draw element
         */
        override fun drawElement(): Border? {
            var animationY = 30F
            val notifications = mutableListOf<Notification>()
            for(i in hud.notifications)
                notifications.add(i)
            for(i in notifications)
                if(mc.currentScreen !is GuiHudDesigner)
                i.drawNotification(animationY).also { animationY += 32 }
            else
                exampleNotification.drawNotification(animationY)
            if (mc.currentScreen is GuiHudDesigner) {
                if (!hud.notifications.contains(exampleNotification))
                    hud.addNotification(exampleNotification)
    
                exampleNotification.fadeState = Notification.FadeState.STAY
                exampleNotification.x = exampleNotification.textLength + 8F
    
                return Border(-98F, -58F, 0F, -30F)
            }
    
            return null
        }
    
    }
    class Notification(message : String,type : Type) {
        var x = 0f
        var textLength = 0
        private var stay = 0f
        private var fadeStep = 0f
        var fadeState = FadeState.IN
        private var stayTimer = MSTimer()
        private var firstY = 0f
        private var animeTime: Long = 0
        private var message: String = ""
        private var type: Type
        init {
            this.message = message
            this.type = type
            this.firstY = 1919F
            this.stayTimer.reset()
            this.textLength = Fonts.font35.getStringWidth(message)
        }
        enum class Type {
            SUCCESS,
            INFO,
            WARNING,
            ERROR
        }
    
        enum class FadeState {
            IN,STAY,OUT,END
        }
    
        fun drawNotification(animationY: Float) {
            val delta = RenderUtils.deltaTime
            val width = textLength.toFloat() + 8.0f
            var y = animationY
            if (firstY == 1919.0F) {
                firstY = y
            }
            if (firstY > y) {
                val cacheY = firstY - (firstY - y) * ((System.currentTimeMillis() - animeTime).toFloat() / 300.0f)
                if (cacheY <= y) {
                    firstY = cacheY
                }
                y = cacheY
            } else {
                firstY = y
                animeTime = System.currentTimeMillis()
            }
            RenderUtils.drawRect(-x + 8 + textLength, -y, -x - 5, -28F - y, Color(255,255,255).rgb)
            RenderUtils.drawRect(-x -1, -y, -x - 5, -28F - y, when(type) {
                Type.SUCCESS -> Color(80, 255, 80).rgb
                Type.ERROR -> Color(255, 80, 80).rgb
                Type.INFO -> Color(80, 80, 255).rgb
                Type.WARNING -> Color(255, 255, 80).rgb
            })
            var replacedMessage = message
            replacedMessage = replacedMessage.replace("Enabled ", "")
            replacedMessage = replacedMessage.replace("Disabled ", "")
            if(message.contains("Enabled", true) || message.contains("Disabled", true)) {
                val stringBuilder = StringBuilder()
                stringBuilder.append("$replacedMessage Module")
                replacedMessage = stringBuilder.toString()
            }
            Fonts.font35.drawString(replacedMessage, -x + 2, -11F - y, Color(110, 110, 110).rgb)
            Fonts.font40.drawString(if(message.contains("Enabled")) "Enabled" else if(message.contains("Disabled")) "Disabled" else type.toString(), -x + 2, -23F - y,
                if(!message.contains("Enabled") && !message.contains("Disabled"))
                    when(type) {
                    Type.SUCCESS -> Color(80, 255, 80).rgb
                    Type.ERROR -> Color(255, 80, 80).rgb
                    Type.INFO -> Color(80, 80, 255).rgb
                    Type.WARNING -> Color(255, 255, 0).rgb
                    }
                else
                    if(message.contains("Enabled"))
                        Color(80, 255, 80).rgb
                    else
                        Color(255, 80, 80).rgb
            )
            GlStateManager.resetColor()
            when (fadeState) {
                FadeState.IN -> {
                    if (x < width) {
                        x = AnimationUtils.easeOut(fadeStep, width) * width
                        fadeStep += delta / 4F
                    }
                    if (x >= width) {
                        fadeState = FadeState.STAY
                        x = width
                        fadeStep = width
                    }
    
                    stay = 60F
                }
    
                FadeState.STAY -> {
                    if (stay > 0) {
                        stay = 0F
                        stayTimer.reset()
                    }
                    if (stayTimer.hasTimePassed(1500L))
                        fadeState = FadeState.OUT
                }
    
                FadeState.OUT -> if (x > 0) {
                    x = AnimationUtils.easeOut(fadeStep, width) * width
                    fadeStep -= delta / 4F
                } else
                    fadeState = FadeState.END
    
                FadeState.END -> hud.removeNotification(this)
            }
        }
    }
    
    
    HKTBH Offline
    HKTBH Offline
    HKTB
    wrote on last edited by
    #12

    @gameboy how to fix?
    d2fbd5c0-ea3b-4127-8ce6-eacd9f59dd14-image.png

    W exit scammedE 2 Replies Last reply
    0
    • GkingG Offline
      GkingG Offline
      Gking
      wrote on last edited by
      #13

      ok skidit

      GameBoyG 1 Reply Last reply
      1
      • HKTBH HKTB

        @gameboy how to fix?
        d2fbd5c0-ea3b-4127-8ce6-eacd9f59dd14-image.png

        W Offline
        W Offline
        wangtian297
        wrote on last edited by
        #14

        @hktb b73复制b72码子,没谁了

        1 Reply Last reply
        0
        • HKTBH HKTB

          @gameboy how to fix?
          d2fbd5c0-ea3b-4127-8ce6-eacd9f59dd14-image.png

          exit scammedE Offline
          exit scammedE Offline
          exit scammed
          wrote on last edited by
          #15

          @hktb crossversion moment

          classProvider.isGuiHudDesigner(mc.currentScreen)
          
          1 Reply Last reply
          0
          • GkingG Gking

            ok skidit

            GameBoyG Offline
            GameBoyG Offline
            GameBoy
            wrote on last edited by
            #16

            @gking oh my god

            1 Reply Last reply
            0
            • Patrik StettnerP Offline
              Patrik StettnerP Offline
              Patrik Stettner
              wrote on last edited by
              #17

              how do i use it?

              ? 1 Reply Last reply
              0
              • Patrik StettnerP Patrik Stettner

                how do i use it?

                ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #18

                cant code^

                1 Reply Last reply
                0
                • Sigmaclient infoS Offline
                  Sigmaclient infoS Offline
                  Sigmaclient info
                  wrote on last edited by
                  #19

                  export to javaskript

                  1 Reply Last reply
                  0
                  • Enderman202020E Offline
                    Enderman202020E Offline
                    Enderman202020
                    wrote on last edited by
                    #20
                    This post is deleted!
                    Q Enderman202020E 2 Replies Last reply
                    0
                    • Enderman202020E Enderman202020

                      This post is deleted!

                      Q Offline
                      Q Offline
                      quadro
                      wrote on last edited by
                      #21

                      @enderman202020 i just-
                      wha- what
                      i dont understand

                      1 Reply Last reply
                      0
                      • Enderman202020E Enderman202020

                        This post is deleted!

                        Enderman202020E Offline
                        Enderman202020E Offline
                        Enderman202020
                        wrote on last edited by
                        #22
                        This post is deleted!
                        Q 1 Reply Last reply
                        0
                        • ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #23

                          brain stopped working

                          1 Reply Last reply
                          0
                          • Enderman202020E Enderman202020

                            This post is deleted!

                            Q Offline
                            Q Offline
                            quadro
                            wrote on last edited by
                            #24

                            @enderman202020 either stop being arrogant or use a proper translator
                            or try to think for yourself but ymmv

                            Enderman202020E 1 Reply Last reply
                            2
                            • Q quadro

                              @enderman202020 either stop being arrogant or use a proper translator
                              or try to think for yourself but ymmv

                              Enderman202020E Offline
                              Enderman202020E Offline
                              Enderman202020
                              wrote on last edited by
                              #25
                              This post is deleted!
                              1 Reply Last reply
                              0
                              • ? Offline
                                ? Offline
                                A Former User
                                wrote on last edited by
                                #26

                                wtf turbo cope????

                                1 Reply Last reply
                                0
                                • sed_oikS Offline
                                  sed_oikS Offline
                                  sed_oik
                                  wrote on last edited by
                                  #27

                                  how can you use it?

                                  skiddermaster412S 1 Reply Last reply
                                  0
                                  • sed_oikS sed_oik

                                    how can you use it?

                                    skiddermaster412S Offline
                                    skiddermaster412S Offline
                                    skiddermaster412
                                    wrote on last edited by
                                    #28

                                    @sed_oik edit src, and no you can't

                                    1 Reply Last reply
                                    0
                                    • T Offline
                                      T Offline
                                      tpzimin
                                      wrote on last edited by
                                      #29

                                      316a38e6-92e3-4464-aa7d-01bca333252f-image.png
                                      🤔

                                      1 Reply Last reply
                                      0

                                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                      With your input, this post could be even better 💗

                                      Register Login
                                      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