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 net.minecraft.entity.Entity;
- import org.lwjgl.opengl.GL11;
- import java.awt.*;
- import static org.lwjgl.opengl.GL11.*;
- class ESP2D extends Module {
- public ESP2D() {
- super("2D ESP", 0, Category.RENDER);
- }
- @Override
- public void onRender() {
- if (!this.isEnabled() || mc.thePlayer == null || mc.theWorld == null) return;
- for (Entity entity : mc.theWorld.loadedEntityList) {
- if (entity instanceof AbstractClientPlayer && entity != mc.thePlayer /* && AntiBot.isValidEntity(entity) */) {
- drawESP((AbstractClientPlayer) (entity));
- }
- }
- }
- private void drawESP(AbstractClientPlayer e) {
- if (mc.thePlayer.getDistanceToEntity(e) < 0.75)
- return;
- double x = e.lastTickPosX + (e.posX - e.lastTickPosX) * mc.timer.renderPartialTicks - mc.getRenderManager().viewerPosX;
- double y = e.lastTickPosY + (e.posY - e.lastTickPosY) * mc.timer.renderPartialTicks - mc.getRenderManager().viewerPosY;
- double z = e.lastTickPosZ + (e.posZ - e.lastTickPosZ) * mc.timer.renderPartialTicks - mc.getRenderManager().viewerPosZ;
- GlStateManager.pushMatrix();
- // health ratio
- double r = (double)(e.getHealth() / e.getMaxHealth());
- int b = (int)(74 * r);
- // health color
- int c =
- (r < 0.3) ? Color.red.getRGB()
- : (r < 0.5) ? Color.orange.getRGB()
- : (r < 0.7) ? Color.yellow.getRGB()
- : Color.green.getRGB(); // rgb for health
- GL11.glTranslated(x, y - 0.2, z);
- GL11.glRotated(-mc.getRenderManager().playerViewY, 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 - 74, 3.0, 74.0, 3.0, Color.darkGray); // health bg
- drawRoundedRect(22.0, 0.0, 3.0, b, 3.0, new Color(c)); // health
- // HEALTH BAR
- GlStateManager.enableDepth();
- GlStateManager.popMatrix();
- }
- public static void drawRoundedRect(double x, double y, double width, double height, double radius, Color color) {
- if(height >= radius && width >= radius) {
- GlStateManager.pushMatrix();
- width = x + width;
- height = y + height;
- GlStateManager.enableBlend();
- GlStateManager.enableTexture2D();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- double x1 = width;
- double y1 = height;
- glPushAttrib(0);
- glScaled(0.1, 0.1, 0.1);
- x *= 10;
- y *= 10;
- x1 *= 10;
- y1 *= 10;
- radius *= 5;
- glDisable(GL_TEXTURE_2D);
- glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F);
- glEnable(GL_LINE_SMOOTH);
- glBegin(GL_TRIANGLE_FAN);
- drawCirclePart(x, y, x1, y1, radius);
- glEnd();
- glEnable(GL_TEXTURE_2D);
- glDisable(GL_LINE_SMOOTH);
- glEnable(GL_TEXTURE_2D);
- glScaled(10, 10, 10);
- glPopAttrib();
- glColor4f(1, 1, 1, 1);
- GlStateManager.disableBlend();
- x /= 10;
- y /= 10;
- x1 /= 10;
- y1 /= 10;
- radius /= 5;
- GlStateManager.popMatrix();
- drawRoundedRectOutline(x, y, width - x, height - y, radius, color, 1);
- }
- }
- public static void drawRoundedRectOutline(double x, double y, double width, double height, double radius, Color color, float lineWidth) {
- GlStateManager.pushMatrix();
- width = x + width;
- height = y + height;
- int random = (int) ((System.currentTimeMillis() / 5) % 160);
- GlStateManager.enableBlend();
- GlStateManager.enableTexture2D();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- double x1 = width;
- double y1 = height;
- glPushAttrib(0);
- glScaled(0.1, 0.1, 0.1);
- x *= 10;
- y *= 10;
- x1 *= 10;
- y1 *= 10;
- radius *= 5;
- glDisable(GL_TEXTURE_2D);
- glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F);
- glEnable(GL_LINE_SMOOTH);
- glLineWidth(lineWidth);
- glBegin(GL_LINE_STRIP);
- int count = 0;
- glVertex2d(x + radius, y);
- glVertex2d(x1 - radius, y);
- for (int i = 0; i <= 90; i += 3) {
- glVertex2d(x + radius + +(Math.sin((i * Math.PI / 180)) * (radius * -1)), y + radius + (Math.cos((i * Math.PI / 180)) * (radius * -1)));
- count++;
- }
- for (int i = 90; i <= 180; i += 3) {
- glVertex2d(x + radius + (Math.sin((i * Math.PI / 180)) * (radius * -1)), y1 - radius + (Math.cos((i * Math.PI / 180)) * (radius * -1)));
- count++;
- }
- for (int i = 0; i <= 90; i += 3) {
- glVertex2d(x1 - radius + (Math.sin((i * Math.PI / 180)) * radius), y1 - radius + (Math.cos((i * Math.PI / 180)) * radius));
- count++;
- }
- for (int i = 90; i <= 180; i += 3) {
- glVertex2d(x1 - radius + (Math.sin((i * Math.PI / 180)) * radius), y + radius + (Math.cos((i * Math.PI / 180)) * radius));
- count++;
- }
- glEnd();
- glEnable(GL_TEXTURE_2D);
- glDisable(GL_LINE_SMOOTH);
- glEnable(GL_TEXTURE_2D);
- glScaled(10, 10, 10);
- glPopAttrib();
- glColor4f(1, 1, 1, 1);
- GlStateManager.disableBlend();
- GlStateManager.popMatrix();
- }
- public static void drawCirclePart(double x, double y, double x1, double y1, double radius) {
- for (double i = 0; i <= 90; i += 0.5) {
- glVertex2d(x + radius + +(Math.sin((i * Math.PI / 180)) * (radius * -1)), y + radius + (Math.cos((i * Math.PI / 180)) * (radius * -1)));
- }
- for (double i = 90; i <= 180; i += 0.5) {
- glVertex2d(x + radius + (Math.sin((i * Math.PI / 180)) * (radius * -1)), y1 - radius + (Math.cos((i * Math.PI / 180)) * (radius * -1)));
- }
- for (double i = 0; i <= 90; i += 0.5) {
- glVertex2d(x1 - radius + (Math.sin((i * Math.PI / 180)) * radius), y1 - radius + (Math.cos((i * Math.PI / 180)) * radius));
- }
- for (double i = 90; i <= 180; i += 0.5) {
- glVertex2d(x1 - radius + (Math.sin((i * Math.PI / 180)) * radius), y + radius + (Math.cos((i * Math.PI / 180)) * radius));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment