ZornTaov

mod_fps

Oct 12th, 2011
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.86 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import net.minecraft.client.Minecraft;
  4. import org.lwjgl.input.*;
  5.  
  6. public class mod_FPS extends BaseMod
  7. {
  8.  
  9.     public boolean OnTickInGame(Minecraft minecraft)
  10.     {
  11.     ScaledResolution scaledresolution = new ScaledResolution(minecraft.gameSettings,
  12.         minecraft.displayWidth, minecraft.displayHeight);
  13.     int width = scaledresolution.getScaledWidth();
  14.     int height = scaledresolution.getScaledHeight();
  15.     FontRenderer fontRenderer = minecraft.fontRenderer;
  16.  
  17.     if (!minecraft.gameSettings.showDebugInfo && ModLoader.isGUIOpen(null))
  18.     {
  19.         fontRenderer.drawStringWithShadow((new StringBuilder()).append(minecraft.debug)
  20.             .toString(), 2, 10, 0xe0e0e0); //print FPS and chunks
  21.         double iX = minecraft.thePlayer.posX;//get my x,y,z coords
  22.         double iY = minecraft.thePlayer.posY;
  23.         double iZ = minecraft.thePlayer.posZ;
  24.         Vec3D vec3D = Vec3D.createVector(iX, 0, iZ);//make a vector for me
  25.         fontRenderer.drawStringWithShadow((new StringBuilder()).append("Pos: ")
  26.             .append((int) iX).append(", ").append((int) iY).append(", ").append((int) iZ)
  27.             .toString(), 2, 18, 0xe0e0e0);
  28.        
  29.         if ((minecraft.thePlayer instanceof EntityClientPlayerMP))
  30.         {
  31.         for (int i = 0; i < minecraft.theWorld.playerEntities.size(); i++)
  32.         {
  33.             if ((minecraft.theWorld.playerEntities.get(i) instanceof EntityOtherPlayerMP))
  34.             {
  35.             double jX = ((EntityPlayer) minecraft.theWorld.playerEntities.get(i)).posX; //get other players x,y,z coords
  36.             double jY = ((EntityPlayer) minecraft.theWorld.playerEntities.get(i)).posY;
  37.             double jZ = ((EntityPlayer) minecraft.theWorld.playerEntities.get(i)).posZ;
  38.             Vec3D vec3D1 = Vec3D.createVector(jX, 0, jZ);//make a vector for the other player
  39.  
  40.             double dis = Math.sqrt(((iX-jX)*(iX-jX))+((iY-jY)*(iY-jY))+((iZ-jZ)*(iZ-jZ))); //get the distance between us
  41.             Vec3D vec3D2 = vec3D.subtract(vec3D1);          //fun stuff to figure out angles
  42.             vec3D2 = vec3D2.normalize();                    //
  43.             Vec3D vec3D3 = Vec3D.createVector(0, 0, 1);     //
  44.             double a1 = minecraft.thePlayer.rotationYaw;    //
  45.             double a2 = vec3D2.dotProduct(vec3D3);          //
  46.             double a3 = ((Math.acos(a2) * 180D) / Math.PI); //no more fun stuff D:
  47.             if (jX > iX) a3 *= -1;
  48.             double a5;
  49.             for (a5 = a3 - a1; a5 >= 180D; a5 -= 360D)//convert the huge double to only 360 degrees between -180 and 180
  50.             {
  51.             }
  52.             for (; a5 < -180D; a5 += 360D)
  53.             {
  54.             }
  55.             //System.out.printf("me: %.0f you: %.0f both: %.0f\n", a1, a3, a5);//print to cmd prompt the angles
  56.  
  57.             String s = (new StringBuilder())
  58.                 .append(((EntityPlayer) minecraft.theWorld.playerEntities.get(i)).username)
  59.                 .append((int) jX).append(", ").append((int) jY).append(", ")
  60.                 .append((int) jZ).append(" D: ").append((int) dis).toString();
  61.             fontRenderer.drawStringWithShadow(s, 14, (i * 10) + 20, 0xe0e0e0); // print it!
  62.             byte byte1 = 0;//change the direction of the arrow
  63.             byte byte2 = (byte) (i%8); //change the color of the arrow
  64.             if (a5 <= 22.5D && a5 >= -22.5D) {byte1 = 0;}
  65.             else if (a5 >= 22.5D && a5 < 67.5D) {byte1 = 1;}
  66.             else if (a5 >= 67.5D && a5 < 112.5D) {byte1 = 2;}
  67.             else if (a5 >= 112.5D && a5 < 157.5D) {byte1 = 3;}
  68.             else if ((a5 >= 157.5D && a5 < 180D) || (a5 >= -180.5D && a5 < -157.5D))
  69.                 {byte1 = 4;}
  70.             else if (a5 >= -157.5D && a5 < -112.5D) {byte1 = 5;}
  71.             else if (a5 >= -112.5D && a5 < -67.5D) {byte1 = 6;}
  72.             else if (a5 >= -67.5D && a5 < -22.5D) {byte1 = 7;}
  73.             minecraft.renderEngine.bindTexture(minecraft.renderEngine
  74.                 .getTexture("/gui/ArrowIcons.png"));//ready the arrow texture
  75.             minecraft.ingameGUI.drawTexturedModalRect(4, (i * 10) + 20, byte2 * 8,
  76.                 byte1 * 8, 8, 8);//make the arrow
  77.             }
  78.         }
  79.        
  80.         }
  81.     }
  82.     return true;
  83.  
  84.     }
  85.  
  86.     public String Version()
  87.     {
  88.     return "1.8.1";
  89.     }
  90.  
  91.     public mod_FPS()
  92.     {
  93.     ModLoader.SetInGameHook(this, true, false);
  94.     }
  95.  
  96. }
  97.  
  98.  
Advertisement
Add Comment
Please, Sign In to add comment