Advertisement
TerrificTable55

Untitled

Oct 10th, 2022 (edited)
1,325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 7.94 KB | None | 0 0
  1. import net.minecraft.client.entity.AbstractClientPlayer
  2. import net.minecraft.client.renderer.GlStateManager
  3. import org.lwjgl.opengl.GL11
  4. import java.awt.Color
  5.  
  6.  
  7. class ESP2D : Module("2D ESP", 0, Category.RENDER) {
  8.  
  9.     override fun onRender() {
  10.         if (!isEnabled || mc.thePlayer == null || mc.theWorld == null) return
  11.  
  12.         for (entity in mc.theWorld.loadedEntityList) {
  13.             if (entity is AbstractClientPlayer && entity != mc.thePlayer /* && AntiBot.isValidEntity(entity) */) {
  14.                 drawESP(entity)
  15.             }
  16.         }
  17.     }
  18.  
  19.  
  20.  
  21.     private fun drawESP(e: AbstractClientPlayer) {
  22.         if (mc.thePlayer.getDistanceToEntity(e) < 0.75)
  23.             return
  24.  
  25.  
  26.         val x: Double = e.lastTickPosX + (e.posX - e.lastTickPosX) * mc.timer.renderPartialTicks - mc.renderManager.viewerPosX
  27.         val y: Double = e.lastTickPosY + (e.posY - e.lastTickPosY) * mc.timer.renderPartialTicks - mc.renderManager.viewerPosY
  28.         val z: Double = e.lastTickPosZ + (e.posZ - e.lastTickPosZ) * mc.timer.renderPartialTicks - mc.renderManager.viewerPosZ
  29.         GlStateManager.pushMatrix()
  30.  
  31.         // health ratio
  32.         val r = (e.health / e.maxHealth).toDouble()
  33.         val b = (74 * r).toInt()
  34.  
  35.         // health color
  36.         val c: Int =
  37.             if (r < 0.3)
  38.                 Color.red.getRGB()
  39.             else if (r < 0.5)
  40.                 Color.orange.getRGB()
  41.             else if (r < 0.7)
  42.                 Color.yellow.getRGB()
  43.             else Color.green.getRGB() // rgb for health
  44.  
  45.  
  46.  
  47.         GL11.glTranslated(x, y - 0.2, z)
  48.         GL11.glRotated(-mc.renderManager.playerViewY.toDouble(), 0.0, 1.0, 0.0)
  49.         GlStateManager.disableDepth()
  50.         GL11.glScalef(0.03f, 0.03f, 0.03f)
  51.         // HEALTH BAR
  52.         drawRoundedRect(21.0, -1.0, 5.0, 76.0, 3.0, Color.black) // background
  53.         drawRoundedRect(22.0, b.toDouble() - 74, 3.0, 74.0, 3.0, Color.darkGray) // health bg
  54.         drawRoundedRect(22.0, 0.0, 3.0, b.toDouble(), 3.0, Color(c)) // health
  55.         // HEALTH BAR
  56.  
  57.         GlStateManager.enableDepth()
  58.         GlStateManager.popMatrix()
  59.  
  60.  
  61.     }
  62.  
  63.  
  64.     fun drawRoundedRect(x: Double, y: Double, width: Double, height: Double, radius: Double, color: Color) {
  65.         // weird kotin stuff
  66.         var x = x
  67.         var y = y
  68.         var width = width
  69.         var height = height
  70.         var radius = radius
  71.  
  72.         if (height >= radius && width >= radius) {
  73.             GlStateManager.pushMatrix()
  74.             width = x + width
  75.             height = y + height
  76.             GlStateManager.enableBlend()
  77.             GlStateManager.enableTexture2D()
  78.             GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
  79.             var x1 = width
  80.             var y1 = height
  81.             GL11.glPushAttrib(0)
  82.             GL11.glScaled(0.1, 0.1, 0.1)
  83.             x *= 10.0
  84.             y *= 10.0
  85.             x1 *= 10.0
  86.             y1 *= 10.0
  87.             radius *= 5.0
  88.             GL11.glDisable(GL11.GL_TEXTURE_2D)
  89.             GL11.glColor4f(color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f)
  90.             GL11.glEnable(GL11.GL_LINE_SMOOTH)
  91.             GL11.glBegin(GL11.GL_TRIANGLE_FAN)
  92.             RenderUtil.drawCirclePart(x, y, x1, y1, radius)
  93.             GL11.glEnd()
  94.             GL11.glEnable(GL11.GL_TEXTURE_2D)
  95.             GL11.glDisable(GL11.GL_LINE_SMOOTH)
  96.             GL11.glEnable(GL11.GL_TEXTURE_2D)
  97.             GL11.glScaled(10.0, 10.0, 10.0)
  98.             GL11.glPopAttrib()
  99.             GL11.glColor4f(1f, 1f, 1f, 1f)
  100.             GlStateManager.disableBlend()
  101.             x /= 10.0
  102.             y /= 10.0
  103.             x1 /= 10.0
  104.             y1 /= 10.0
  105.             radius /= 5.0
  106.             GlStateManager.popMatrix()
  107.             drawRoundedRectOutline(x, y, width - x, height - y, radius, color, 1f)
  108.         }
  109.     }
  110.  
  111.    
  112.     fun drawRoundedRectOutline(x: Double, y: Double, width: Double, height: Double, radius: Double, color: Color, lineWidth: Float) {
  113.         var x = x
  114.         var y = y
  115.         var width = width
  116.         var height = height
  117.         var radius = radius
  118.         GlStateManager.pushMatrix()
  119.         width = x + width
  120.         height = y + height
  121.         val random = (System.currentTimeMillis() / 5 % 160).toInt()
  122.         GlStateManager.enableBlend()
  123.         GlStateManager.enableTexture2D()
  124.         GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
  125.         var x1 = width
  126.         var y1 = height
  127.         GL11.glPushAttrib(0)
  128.         GL11.glScaled(0.1, 0.1, 0.1)
  129.         x *= 10.0
  130.         y *= 10.0
  131.         x1 *= 10.0
  132.         y1 *= 10.0
  133.         radius *= 5.0
  134.         GL11.glDisable(GL11.GL_TEXTURE_2D)
  135.         GL11.glColor4f(color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f)
  136.         GL11.glEnable(GL11.GL_LINE_SMOOTH)
  137.         GL11.glLineWidth(lineWidth)
  138.         GL11.glBegin(GL11.GL_LINE_STRIP)
  139.         var count = 0
  140.         GL11.glVertex2d(x + radius, y)
  141.         GL11.glVertex2d(x1 - radius, y)
  142.         run {
  143.             var i = 0
  144.             while (i <= 90) {
  145.                 GL11.glVertex2d(
  146.                     x + radius + +(Math.sin(i * Math.PI / 180) * (radius * -1)),
  147.                     y + radius + Math.cos(i * Math.PI / 180) * (radius * -1)
  148.                 )
  149.                 count++
  150.                 i += 3
  151.             }
  152.         }
  153.         run {
  154.             var i = 90
  155.             while (i <= 180) {
  156.                 GL11.glVertex2d(
  157.                     x + radius + Math.sin(i * Math.PI / 180) * (radius * -1),
  158.                     y1 - radius + Math.cos(i * Math.PI / 180) * (radius * -1)
  159.                 )
  160.                 count++
  161.                 i += 3
  162.             }
  163.         }
  164.         run {
  165.             var i = 0
  166.             while (i <= 90) {
  167.                 GL11.glVertex2d(
  168.                     x1 - radius + Math.sin(i * Math.PI / 180) * radius,
  169.                     y1 - radius + Math.cos(i * Math.PI / 180) * radius
  170.                 )
  171.                 count++
  172.                 i += 3
  173.             }
  174.         }
  175.         var i = 90
  176.         while (i <= 180) {
  177.             GL11.glVertex2d(
  178.                 x1 - radius + Math.sin(i * Math.PI / 180) * radius, y + radius + Math.cos(
  179.                     i * Math.PI / 180
  180.                 ) * radius
  181.             )
  182.             count++
  183.             i += 3
  184.         }
  185.         GL11.glEnd()
  186.         GL11.glEnable(GL11.GL_TEXTURE_2D)
  187.         GL11.glDisable(GL11.GL_LINE_SMOOTH)
  188.         GL11.glEnable(GL11.GL_TEXTURE_2D)
  189.         GL11.glScaled(10.0, 10.0, 10.0)
  190.         GL11.glPopAttrib()
  191.         GL11.glColor4f(1f, 1f, 1f, 1f)
  192.         GlStateManager.disableBlend()
  193.         GlStateManager.popMatrix()
  194.     }
  195.  
  196.     fun drawCirclePart(x: Double, y: Double, x1: Double, y1: Double, radius: Double) {
  197.         run {
  198.             var i = 0.0
  199.             while (i <= 90) {
  200.                 GL11.glVertex2d(
  201.                     x + radius + +(Math.sin(i * Math.PI / 180) * (radius * -1)),
  202.                     y + radius + Math.cos(i * Math.PI / 180) * (radius * -1)
  203.                 )
  204.                 i += 0.5
  205.             }
  206.         }
  207.         run {
  208.             var i = 90.0
  209.             while (i <= 180) {
  210.                 GL11.glVertex2d(
  211.                     x + radius + Math.sin(i * Math.PI / 180) * (radius * -1),
  212.                     y1 - radius + Math.cos(i * Math.PI / 180) * (radius * -1)
  213.                 )
  214.                 i += 0.5
  215.             }
  216.         }
  217.         run {
  218.             var i = 0.0
  219.             while (i <= 90) {
  220.                 GL11.glVertex2d(
  221.                     x1 - radius + Math.sin(i * Math.PI / 180) * radius,
  222.                     y1 - radius + Math.cos(i * Math.PI / 180) * radius
  223.                 )
  224.                 i += 0.5
  225.             }
  226.         }
  227.         var i = 90.0
  228.         while (i <= 180) {
  229.             GL11.glVertex2d(
  230.                 x1 - radius + Math.sin(i * Math.PI / 180) * radius, y + radius + Math.cos(
  231.                     i * Math.PI / 180
  232.                 ) * radius
  233.             )
  234.             i += 0.5
  235.         }
  236.     }
  237. }
  238.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement