Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import net.minecraft.client.entity.AbstractClientPlayer
- import net.minecraft.client.renderer.GlStateManager
- import org.lwjgl.opengl.GL11
- import java.awt.Color
- class ESP2D : Module("2D ESP", 0, Category.RENDER) {
- override fun onRender() {
- if (!isEnabled || mc.thePlayer == null || mc.theWorld == null) return
- for (entity in mc.theWorld.loadedEntityList) {
- if (entity is AbstractClientPlayer && entity != mc.thePlayer /* && AntiBot.isValidEntity(entity) */) {
- drawESP(entity)
- }
- }
- }
- private fun drawESP(e: AbstractClientPlayer) {
- if (mc.thePlayer.getDistanceToEntity(e) < 0.75)
- return
- val x: Double = e.lastTickPosX + (e.posX - e.lastTickPosX) * mc.timer.renderPartialTicks - mc.renderManager.viewerPosX
- val y: Double = e.lastTickPosY + (e.posY - e.lastTickPosY) * mc.timer.renderPartialTicks - mc.renderManager.viewerPosY
- val z: Double = e.lastTickPosZ + (e.posZ - e.lastTickPosZ) * mc.timer.renderPartialTicks - mc.renderManager.viewerPosZ
- GlStateManager.pushMatrix()
- // health ratio
- val r = (e.health / e.maxHealth).toDouble()
- val b = (74 * r).toInt()
- // health color
- val c: Int =
- if (r < 0.3)
- Color.red.getRGB()
- else if (r < 0.5)
- Color.orange.getRGB()
- else if (r < 0.7)
- Color.yellow.getRGB()
- else Color.green.getRGB() // rgb for health
- GL11.glTranslated(x, y - 0.2, z)
- GL11.glRotated(-mc.renderManager.playerViewY.toDouble(), 0.0, 1.0, 0.0)
- GlStateManager.disableDepth()
- GL11.glScalef(0.03f, 0.03f, 0.03f)
- // HEALTH BAR
- drawRoundedRect(21.0, -1.0, 5.0, 76.0, 3.0, Color.black) // background
- drawRoundedRect(22.0, b.toDouble() - 74, 3.0, 74.0, 3.0, Color.darkGray) // health bg
- drawRoundedRect(22.0, 0.0, 3.0, b.toDouble(), 3.0, Color(c)) // health
- // HEALTH BAR
- GlStateManager.enableDepth()
- GlStateManager.popMatrix()
- }
- fun drawRoundedRect(x: Double, y: Double, width: Double, height: Double, radius: Double, color: Color) {
- // weird kotin stuff
- var x = x
- var y = y
- var width = width
- var height = height
- var radius = radius
- if (height >= radius && width >= radius) {
- GlStateManager.pushMatrix()
- width = x + width
- height = y + height
- GlStateManager.enableBlend()
- GlStateManager.enableTexture2D()
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
- var x1 = width
- var y1 = height
- GL11.glPushAttrib(0)
- GL11.glScaled(0.1, 0.1, 0.1)
- x *= 10.0
- y *= 10.0
- x1 *= 10.0
- y1 *= 10.0
- radius *= 5.0
- GL11.glDisable(GL11.GL_TEXTURE_2D)
- GL11.glColor4f(color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f)
- GL11.glEnable(GL11.GL_LINE_SMOOTH)
- GL11.glBegin(GL11.GL_TRIANGLE_FAN)
- RenderUtil.drawCirclePart(x, y, x1, y1, radius)
- GL11.glEnd()
- GL11.glEnable(GL11.GL_TEXTURE_2D)
- GL11.glDisable(GL11.GL_LINE_SMOOTH)
- GL11.glEnable(GL11.GL_TEXTURE_2D)
- GL11.glScaled(10.0, 10.0, 10.0)
- GL11.glPopAttrib()
- GL11.glColor4f(1f, 1f, 1f, 1f)
- GlStateManager.disableBlend()
- x /= 10.0
- y /= 10.0
- x1 /= 10.0
- y1 /= 10.0
- radius /= 5.0
- GlStateManager.popMatrix()
- drawRoundedRectOutline(x, y, width - x, height - y, radius, color, 1f)
- }
- }
- fun drawRoundedRectOutline(x: Double, y: Double, width: Double, height: Double, radius: Double, color: Color, lineWidth: Float) {
- var x = x
- var y = y
- var width = width
- var height = height
- var radius = radius
- GlStateManager.pushMatrix()
- width = x + width
- height = y + height
- val random = (System.currentTimeMillis() / 5 % 160).toInt()
- GlStateManager.enableBlend()
- GlStateManager.enableTexture2D()
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
- var x1 = width
- var y1 = height
- GL11.glPushAttrib(0)
- GL11.glScaled(0.1, 0.1, 0.1)
- x *= 10.0
- y *= 10.0
- x1 *= 10.0
- y1 *= 10.0
- radius *= 5.0
- GL11.glDisable(GL11.GL_TEXTURE_2D)
- GL11.glColor4f(color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f)
- GL11.glEnable(GL11.GL_LINE_SMOOTH)
- GL11.glLineWidth(lineWidth)
- GL11.glBegin(GL11.GL_LINE_STRIP)
- var count = 0
- GL11.glVertex2d(x + radius, y)
- GL11.glVertex2d(x1 - radius, y)
- run {
- var i = 0
- while (i <= 90) {
- GL11.glVertex2d(
- x + radius + +(Math.sin(i * Math.PI / 180) * (radius * -1)),
- y + radius + Math.cos(i * Math.PI / 180) * (radius * -1)
- )
- count++
- i += 3
- }
- }
- run {
- var i = 90
- while (i <= 180) {
- GL11.glVertex2d(
- x + radius + Math.sin(i * Math.PI / 180) * (radius * -1),
- y1 - radius + Math.cos(i * Math.PI / 180) * (radius * -1)
- )
- count++
- i += 3
- }
- }
- run {
- var i = 0
- while (i <= 90) {
- GL11.glVertex2d(
- x1 - radius + Math.sin(i * Math.PI / 180) * radius,
- y1 - radius + Math.cos(i * Math.PI / 180) * radius
- )
- count++
- i += 3
- }
- }
- var i = 90
- while (i <= 180) {
- GL11.glVertex2d(
- x1 - radius + Math.sin(i * Math.PI / 180) * radius, y + radius + Math.cos(
- i * Math.PI / 180
- ) * radius
- )
- count++
- i += 3
- }
- GL11.glEnd()
- GL11.glEnable(GL11.GL_TEXTURE_2D)
- GL11.glDisable(GL11.GL_LINE_SMOOTH)
- GL11.glEnable(GL11.GL_TEXTURE_2D)
- GL11.glScaled(10.0, 10.0, 10.0)
- GL11.glPopAttrib()
- GL11.glColor4f(1f, 1f, 1f, 1f)
- GlStateManager.disableBlend()
- GlStateManager.popMatrix()
- }
- fun drawCirclePart(x: Double, y: Double, x1: Double, y1: Double, radius: Double) {
- run {
- var i = 0.0
- while (i <= 90) {
- GL11.glVertex2d(
- x + radius + +(Math.sin(i * Math.PI / 180) * (radius * -1)),
- y + radius + Math.cos(i * Math.PI / 180) * (radius * -1)
- )
- i += 0.5
- }
- }
- run {
- var i = 90.0
- while (i <= 180) {
- GL11.glVertex2d(
- x + radius + Math.sin(i * Math.PI / 180) * (radius * -1),
- y1 - radius + Math.cos(i * Math.PI / 180) * (radius * -1)
- )
- i += 0.5
- }
- }
- run {
- var i = 0.0
- while (i <= 90) {
- GL11.glVertex2d(
- x1 - radius + Math.sin(i * Math.PI / 180) * radius,
- y1 - radius + Math.cos(i * Math.PI / 180) * radius
- )
- i += 0.5
- }
- }
- var i = 90.0
- while (i <= 180) {
- GL11.glVertex2d(
- x1 - radius + Math.sin(i * Math.PI / 180) * radius, y + radius + Math.cos(
- i * Math.PI / 180
- ) * radius
- )
- i += 0.5
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement