TerrificTable55

Untitled

Nov 13th, 2022 (edited)
857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.49 KB | None | 0 0
  1. public class NameTags extends Module {
  2.    
  3.     public NameTags() {
  4.         super("NameTags", "Shows the players name and some info about the player", Category.RENDER);
  5.     }
  6.  
  7.  
  8.     @Subscribe
  9.     public void onRender3D(EventRender3D event) {
  10.         if (!isEnabled() || mc.thePlayer == null || mc.theWorld == null) return;
  11.  
  12.         for (Entity entity : mc.theWorld.loadedEntityList) {
  13.             if (entity instanceof AbstractClientPlayer && entity != mc.thePlayer) {
  14.                 EntityLivingBase e = (EntityLivingBase) entity;
  15.  
  16.                 double x = e.lastTickPosX + (e.posX - e.lastTickPosX) * this.mc.timer.renderPartialTicks - this.mc.getRenderManager().renderPosX;
  17.                 double y = e.lastTickPosY + (e.posY - e.lastTickPosY) * this.mc.timer.renderPartialTicks - this.mc.getRenderManager().renderPosY;
  18.                 double z = e.lastTickPosZ + (e.posZ - e.lastTickPosZ) * this.mc.timer.renderPartialTicks - this.mc.getRenderManager().renderPosZ;
  19.  
  20.                 double r = (e.getHealth() / e.getMaxHealth());
  21.                 int c =
  22.                         (r < 0.3)
  23.                             ? Color.red.getRGB()
  24.                             : (r < 0.5)
  25.                             ? Color.orange.getRGB()
  26.                             : (r < 0.7)
  27.                             ? Color.yellow.getRGB()
  28.                             : Color.green.getRGB();
  29.  
  30.                 GL11.glPushMatrix();
  31.                 GL11.glTranslated(x, y + 2.5D, z);
  32.                 GL11.glScalef(-0.03f, -0.03f, -0.03f);
  33.                 GL11.glRotated(-this.mc.getRenderManager().playerViewY, 0.0d, 1.0d, 0.0d);
  34.                 GL11.glRotated(this.mc.getRenderManager().playerViewX, 1.0d, 0.0d, 0.0d);
  35.                 GlStateManager.disableDepth();
  36.  
  37.  
  38.                 float width = (float) FontUtil.two.getStringWidth(e.getName());
  39.                 float progress = e.getHealth() / e.getMaxHealth();
  40.  
  41.                 Gui.drawRect(-width / 2 - 5, 5, width / 2 + 5, FontUtil.two.getHeight() + 8, new Color(0, 0, 0, 80).getRGB());
  42.                 Gui.drawRect(-width / 2 - 5, FontUtil.two.getHeight() + 8,  -width / 2 - 5 + (width / 2 + 5 - -width / 2 + 5) * progress, FontUtil.two.getHeight() + 6, c);
  43.                 FontUtil.two.drawCenteredString(e.getName(), 0, 7, 0xFFFFFFFF);
  44.  
  45.  
  46.                 GL11.glTranslated(-x, -(y + 2.5D), -z);
  47.                 GL11.glScalef(1.0f,1.0f,1.0f);
  48.                 GlStateManager.enableDepth();
  49.                 GL11.glPopMatrix();
  50.  
  51.             }
  52.         }
  53.  
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment