Advertisement
GamingLVScripts

drawEntityOnScreen

Apr 1st, 2024
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.81 KB | None | 0 0
  1.    /**
  2.      * Draws the entity to the screen. Args: xPos, yPos, scale, mouseX, mouseY, entityLiving
  3.      */
  4.     public static void drawEntityOnScreen(int posX, int posY, int scale, float mouseX, float mouseY, EntityLivingBase ent)
  5.     {
  6.         GlStateManager.enableDepth();
  7.         GlStateManager.enableColorMaterial();
  8.         GlStateManager.pushMatrix();
  9.         GlStateManager.translate((float)posX, (float)posY, 50.0F);
  10.         GlStateManager.scale((float)(-scale), (float)scale, (float)scale);
  11.         GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
  12.         float f = ent.renderYawOffset;
  13.         float f1 = ent.rotationYaw;
  14.         float f2 = ent.rotationPitch;
  15.         float f3 = ent.prevRotationYawHead;
  16.         float f4 = ent.rotationYawHead;
  17.  
  18.         final float beforeYaw = PlayerHandler.yaw;
  19.         final float beforePitch = PlayerHandler.pitch;
  20.         final float beforePrevPitch = PlayerHandler.prevPitch;
  21.  
  22.         GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
  23.         RenderHelper.enableStandardItemLighting();
  24.         GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
  25.         GlStateManager.rotate(-((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
  26.         ent.renderYawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F;
  27.         ent.rotationYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F;
  28.         ent.rotationPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F;
  29.         ent.rotationYawHead = ent.rotationYaw;
  30.         ent.prevRotationYawHead = ent.rotationYaw;
  31.         if(ent == Minecraft.getMinecraft().thePlayer) {
  32.             PlayerHandler.yaw = ent.rotationYawHead;
  33.             PlayerHandler.pitch = ent.rotationPitch;
  34.             PlayerHandler.prevPitch = ent.prevRotationPitch;
  35.         }
  36.         GlStateManager.translate(0.0F, 0.0F, 0.0F);
  37.         RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
  38.         rendermanager.setPlayerViewY(180.0F);
  39.         rendermanager.setRenderShadow(false);
  40.         rendermanager.renderEntityWithPosYaw(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
  41.         rendermanager.setRenderShadow(true);
  42.         ent.renderYawOffset = f;
  43.         ent.rotationYaw = f1;
  44.         ent.rotationPitch = f2;
  45.         ent.prevRotationYawHead = f3;
  46.         ent.rotationYawHead = f4;
  47.         if(ent == Minecraft.getMinecraft().thePlayer) {
  48.             PlayerHandler.yaw = beforeYaw;
  49.             PlayerHandler.pitch = beforePitch;
  50.             PlayerHandler.prevPitch = beforePrevPitch;
  51.         }
  52.         GlStateManager.popMatrix();
  53.         RenderHelper.disableStandardItemLighting();
  54.         GlStateManager.disableRescaleNormal();
  55.         GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
  56.         GlStateManager.disableTexture2D();
  57.         GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement