TerrificTable55

Untitled

Oct 10th, 2022 (edited)
1,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.85 KB | None | 0 0
  1. import net.minecraft.client.entity.AbstractClientPlayer;
  2. import net.minecraft.client.renderer.GlStateManager;
  3. import net.minecraft.entity.Entity;
  4. import org.lwjgl.opengl.GL11;
  5.  
  6. import java.awt.*;
  7.  
  8. import static org.lwjgl.opengl.GL11.*;
  9.  
  10.  
  11. class ESP2D extends Module {
  12.  
  13.     public ESP2D() {
  14.         super("2D ESP", 0, Category.RENDER);
  15.     }
  16.  
  17.     @Override
  18.     public void onRender() {
  19.         if (!this.isEnabled() || mc.thePlayer == null || mc.theWorld == null) return;
  20.  
  21.         for (Entity entity : mc.theWorld.loadedEntityList) {
  22.             if (entity instanceof AbstractClientPlayer && entity != mc.thePlayer /* && AntiBot.isValidEntity(entity) */) {
  23.                 drawESP((AbstractClientPlayer) (entity));
  24.             }
  25.         }
  26.     }
  27.  
  28.  
  29.  
  30.     private void drawESP(AbstractClientPlayer e) {
  31.         if (mc.thePlayer.getDistanceToEntity(e) < 0.75)
  32.             return;
  33.  
  34.  
  35.         double x = e.lastTickPosX + (e.posX - e.lastTickPosX) * mc.timer.renderPartialTicks - mc.getRenderManager().viewerPosX;
  36.         double y = e.lastTickPosY + (e.posY - e.lastTickPosY) * mc.timer.renderPartialTicks - mc.getRenderManager().viewerPosY;
  37.         double z = e.lastTickPosZ + (e.posZ - e.lastTickPosZ) * mc.timer.renderPartialTicks - mc.getRenderManager().viewerPosZ;
  38.         GlStateManager.pushMatrix();
  39.  
  40.         // health ratio
  41.         double r = (double)(e.getHealth() / e.getMaxHealth());
  42.         int b = (int)(74 * r);
  43.  
  44.         // health color
  45.         int c =
  46.                 (r < 0.3) ? Color.red.getRGB()
  47.                         : (r < 0.5) ? Color.orange.getRGB()
  48.                         : (r < 0.7) ? Color.yellow.getRGB()
  49.                         : Color.green.getRGB(); // rgb for health
  50.  
  51.  
  52.  
  53.         GL11.glTranslated(x, y - 0.2, z);
  54.         GL11.glRotated(-mc.getRenderManager().playerViewY, 0.0, 1.0, 0.0);
  55.         GlStateManager.disableDepth();
  56.         GL11.glScalef(0.03f, 0.03f, 0.03f);
  57.  
  58.         // HEALTH BAR
  59.         drawRoundedRect(21.0, -1.0, 5.0, 76.0, 3.0, Color.black); // background
  60.         drawRoundedRect(22.0, b - 74, 3.0, 74.0, 3.0, Color.darkGray); // health bg
  61.         drawRoundedRect(22.0, 0.0, 3.0, b, 3.0, new Color(c)); // health
  62.         // HEALTH BAR
  63.  
  64.         GlStateManager.enableDepth();
  65.         GlStateManager.popMatrix();
  66.  
  67.  
  68.     }
  69.  
  70.  
  71.     public static void drawRoundedRect(double x, double y, double width, double height, double radius, Color color) {
  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.             double x1 = width;
  80.             double y1 = height;
  81.             glPushAttrib(0);
  82.             glScaled(0.1, 0.1, 0.1);
  83.  
  84.             x *= 10;
  85.             y *= 10;
  86.             x1 *= 10;
  87.             y1 *= 10;
  88.             radius *= 5;
  89.  
  90.             glDisable(GL_TEXTURE_2D);
  91.             glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F);
  92.             glEnable(GL_LINE_SMOOTH);
  93.  
  94.             glBegin(GL_TRIANGLE_FAN);
  95.             drawCirclePart(x, y, x1, y1, radius);
  96.             glEnd();
  97.  
  98.             glEnable(GL_TEXTURE_2D);
  99.             glDisable(GL_LINE_SMOOTH);
  100.             glEnable(GL_TEXTURE_2D);
  101.  
  102.             glScaled(10, 10, 10);
  103.  
  104.             glPopAttrib();
  105.             glColor4f(1, 1, 1, 1);
  106.             GlStateManager.disableBlend();
  107.             x /= 10;
  108.             y /= 10;
  109.             x1 /= 10;
  110.             y1 /= 10;
  111.             radius /= 5;
  112.             GlStateManager.popMatrix();
  113.             drawRoundedRectOutline(x, y, width - x, height - y, radius, color, 1);
  114.         }
  115.     }
  116.  
  117.     public static void drawRoundedRectOutline(double x, double y, double width, double height, double radius, Color color, float lineWidth) {
  118.         GlStateManager.pushMatrix();
  119.         width = x + width;
  120.         height = y + height;
  121.  
  122.         int random = (int) ((System.currentTimeMillis() / 5) % 160);
  123.         GlStateManager.enableBlend();
  124.         GlStateManager.enableTexture2D();
  125.         GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  126.         double x1 = width;
  127.         double y1 = height;
  128.         glPushAttrib(0);
  129.         glScaled(0.1, 0.1, 0.1);
  130.  
  131.         x *= 10;
  132.         y *= 10;
  133.         x1 *= 10;
  134.         y1 *= 10;
  135.         radius *= 5;
  136.  
  137.         glDisable(GL_TEXTURE_2D);
  138.         glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F);
  139.         glEnable(GL_LINE_SMOOTH);
  140.         glLineWidth(lineWidth);
  141.  
  142.         glBegin(GL_LINE_STRIP);
  143.  
  144.         int count = 0;
  145.         glVertex2d(x + radius, y);
  146.         glVertex2d(x1 - radius, y);
  147.  
  148.         for (int i = 0; i <= 90; i += 3) {
  149.             glVertex2d(x + radius + +(Math.sin((i * Math.PI / 180)) * (radius * -1)), y + radius + (Math.cos((i * Math.PI / 180)) * (radius * -1)));
  150.             count++;
  151.         }
  152.  
  153.         for (int i = 90; i <= 180; i += 3) {
  154.             glVertex2d(x + radius + (Math.sin((i * Math.PI / 180)) * (radius * -1)), y1 - radius + (Math.cos((i * Math.PI / 180)) * (radius * -1)));
  155.             count++;
  156.         }
  157.  
  158.         for (int i = 0; i <= 90; i += 3) {
  159.             glVertex2d(x1 - radius + (Math.sin((i * Math.PI / 180)) * radius), y1 - radius + (Math.cos((i * Math.PI / 180)) * radius));
  160.             count++;
  161.         }
  162.  
  163.         for (int i = 90; i <= 180; i += 3) {
  164.             glVertex2d(x1 - radius + (Math.sin((i * Math.PI / 180)) * radius), y + radius + (Math.cos((i * Math.PI / 180)) * radius));
  165.             count++;
  166.         }
  167.  
  168.         glEnd();
  169.  
  170.         glEnable(GL_TEXTURE_2D);
  171.         glDisable(GL_LINE_SMOOTH);
  172.         glEnable(GL_TEXTURE_2D);
  173.  
  174.         glScaled(10, 10, 10);
  175.  
  176.         glPopAttrib();
  177.         glColor4f(1, 1, 1, 1);
  178.         GlStateManager.disableBlend();
  179.         GlStateManager.popMatrix();
  180.     }
  181.  
  182.     public static void drawCirclePart(double x, double y, double x1, double y1, double radius) {
  183.         for (double i = 0; i <= 90; i += 0.5) {
  184.             glVertex2d(x + radius + +(Math.sin((i * Math.PI / 180)) * (radius * -1)), y + radius + (Math.cos((i * Math.PI / 180)) * (radius * -1)));
  185.         }
  186.  
  187.         for (double i = 90; i <= 180; i += 0.5) {
  188.             glVertex2d(x + radius + (Math.sin((i * Math.PI / 180)) * (radius * -1)), y1 - radius + (Math.cos((i * Math.PI / 180)) * (radius * -1)));
  189.         }
  190.  
  191.         for (double i = 0; i <= 90; i += 0.5) {
  192.             glVertex2d(x1 - radius + (Math.sin((i * Math.PI / 180)) * radius), y1 - radius + (Math.cos((i * Math.PI / 180)) * radius));
  193.         }
  194.  
  195.         for (double i = 90; i <= 180; i += 0.5) {
  196.             glVertex2d(x1 - radius + (Math.sin((i * Math.PI / 180)) * radius), y + radius + (Math.cos((i * Math.PI / 180)) * radius));
  197.         }
  198.     }
  199. }
  200.  
  201.  
Advertisement
Add Comment
Please, Sign In to add comment