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. General Discussion
  3. [Kotlin] New Notifications

[Kotlin] New Notifications

Scheduled Pinned Locked Moved General Discussion
29 Posts 20 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • GameBoyG Offline
    GameBoyG Offline
    GameBoy
    wrote on last edited by
    #1
    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 1 Reply Last reply
    3
    • GameBoyG Offline
      GameBoyG Offline
      GameBoy
      wrote on last edited by
      #2

      8f83f336-05da-4a7d-b862-5557314733cb-image.png

      B Димон 100кД 2 Replies Last reply
      0
      • exit scammedE Offline
        exit scammedE Offline
        exit scammed
        wrote on last edited by
        #3

        nice notification animation, btw you should post the topic in Kotlin/Java category instead of Scripts

        E 1 Reply Last reply
        0
        • E Offline
          E Offline
          Ender__Flash
          replied to exit scammed on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • A Offline
            A Offline
            Aftery
            wrote on last edited by
            #5

            cant code^

            1 Reply Last reply
            0
            • LitelyL Offline
              LitelyL Offline
              Litely
              wrote on last edited by
              #6

              cant code^

              worked fine with me

              ? 1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                replied to Litely on last edited by
                #7

                @idkmyname said in [Kotlin] New Notifications:

                cant code^

                worked fine with me

                epic liquidsense paster coder

                1 Reply Last reply
                0
                • LitelyL Offline
                  LitelyL Offline
                  Litely
                  wrote on last edited by
                  #8

                  im not event have liquidsense

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    Boneshadow
                    replied to GameBoy on last edited by
                    #9

                    @gameboy And how to put them I do not understand this

                    Plumer ManP 1 Reply Last reply
                    0
                    • Plumer ManP Offline
                      Plumer ManP Offline
                      Plumer Man
                      replied to Boneshadow on last edited by
                      #10

                      @codd3r-cheat-minecraft Liquid bounce source

                      1 Reply Last reply
                      0
                      • Димон 100кД Offline
                        Димон 100кД Offline
                        Димон 100к
                        replied to GameBoy on last edited by
                        #11

                        @gameboy best notifications But not enough time before disappearing notifications

                        1 Reply Last reply
                        0
                        • HKTBH Offline
                          HKTBH Offline
                          HKTB
                          replied to GameBoy 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
                            • W Offline
                              W Offline
                              wangtian297
                              replied to HKTB on last edited by
                              #14

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

                              1 Reply Last reply
                              0
                              • exit scammedE Offline
                                exit scammedE Offline
                                exit scammed
                                replied to HKTB on last edited by
                                #15

                                @hktb crossversion moment

                                classProvider.isGuiHudDesigner(mc.currentScreen)
                                
                                1 Reply Last reply
                                0
                                • GameBoyG Offline
                                  GameBoyG Offline
                                  GameBoy
                                  replied to Gking 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
                                    • ? Offline
                                      ? Offline
                                      A Former User
                                      replied to Patrik Stettner 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

                                          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